Skip to content

Commit

Permalink
feat: use CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsuk1ko committed Apr 16, 2024
1 parent 81c1133 commit f0fd24f
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 151 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module.exports = {
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
},
settings: {
'import/resolver': {
Expand Down
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,23 @@
"@intlify/unplugin-vue-i18n": "^4.0.0",
"@vitejs/plugin-vue": "^5.0.4",
"@vueuse/core": "^10.9.0",
"clean-css": "^5.3.3",
"comlink": "^4.4.1",
"detect-browser": "^5.3.0",
"element-plus": "^2.7.0",
"eslint-config-love": "^47.0.0",
"eventemitter3": "^5.0.1",
"file-saver": "^2.0.5",
"jquery": "^3.7.1",
"jquery-pjax": "^2.0.1",
"jszip": "^3.10.1",
"less": "^4.2.0",
"localforage": "^1.10.0",
"localforage-setitems": "^1.4.0",
"lodash-es": "^4.17.21",
"md5": "^2.3.0",
"noty": "3.1.4",
"rollup-plugin-copy": "^3.5.0",
"streamsaver": "^2.0.6",
"typescript": "^5.4.5",
"unplugin-vue-components": "^0.26.0",
"uuid": "^9.0.1",
"vite": "^5.2.8",
"vite-plugin-monkey": "^3.5.2",
"vue": "^3.4.21",
"vue-i18n": "^9.12.1",
"vue-tsc": "^2.0.13"
"vue": "^3.4.22",
"vue-i18n": "^9.12.1"
},
"devDependencies": {
"@commitlint/cli": "^19.2.2",
Expand All @@ -57,17 +48,24 @@
"@types/node": "^20.12.7",
"@types/streamsaver": "^2.0.4",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"eslint": "^8.57.0",
"eslint-config-love": "^47.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.2.0",
"eslint-plugin-n": "^17.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-vue": "^9.25.0",
"less": "^4.2.0",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"rollup-plugin-copy": "^3.5.0",
"typescript": "^5.4.5",
"vite": "^5.2.8",
"vite-plugin-monkey": "^3.5.2",
"vue-tsc": "^2.0.13",
"yorkie": "^2.0.0"
},
"gitHooks": {
Expand Down
19 changes: 19 additions & 0 deletions src/app/SettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,25 @@
<script setup lang="ts">
import { GM_openInTab } from '$';
import { computed, ref, watch } from 'vue';
import {
ElDialog,
ElButton,
ElForm,
ElFormItem,
ElOption,
ElSelect,
ElSlider,
ElInput,
ElInputNumber,
ElSwitch,
ElCheckbox,
ElCheckboxGroup,
ElDivider,
ElCollapse,
ElCollapseItem,
ElTable,
ElTableColumn,
} from 'element-plus';
import { Delete, Download, Upload } from '@element-plus/icons-vue';
import { useI18n } from 'vue-i18n';
import ConfirmPopup from '@/components/ConfirmPopup.vue';
Expand Down
1 change: 1 addition & 0 deletions src/components/ConfirmPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</template>

<script setup lang="ts">
import { ElPopconfirm } from 'element-plus';
import { useI18n } from 'vue-i18n';
const emit = defineEmits(['confirm']);
Expand Down
1 change: 1 addition & 0 deletions src/components/LanguageFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<script setup lang="ts">
import { watch } from 'vue';
import { ElSelect, ElOption } from 'element-plus';
import { useSessionStorage } from '@vueuse/core';
import { IS_NHENTAI_TO } from '@/const';
import { filterLanguage } from '@/utils/languageFilter';
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './utils/hacks';
import './index.less';
import 'noty/lib/noty.css';
import 'element-plus/dist/index.css';
import { GM_registerMenuCommand } from '$';
import type { App, Component } from 'vue';
import { createApp } from 'vue';
Expand Down
4 changes: 1 addition & 3 deletions src/utils/hacks/jquery.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { unsafeWindow, monkeyWindow } from '$';
import { unsafeWindow } from '$';
import $ from 'jquery';
import { IS_DEV } from '@/const';

if (IS_DEV) {
unsafeWindow.jQuery = $;
} else {
monkeyWindow.jQuery = $;
}
1 change: 0 additions & 1 deletion src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="vite/client" />
/// <reference types="element-plus/global" />
/// <reference types="vue/jsx" />

type GlobalThis = typeof globalThis;
Expand Down
23 changes: 14 additions & 9 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import monkey from 'vite-plugin-monkey';
import monkey, { cdn, util } from 'vite-plugin-monkey';
import copy from 'rollup-plugin-copy';
import components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import vueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import workerDevLoader from './plugins/workerDevLoader';

Expand All @@ -18,7 +16,6 @@ export default defineConfig(async ({ mode }) => ({
open: true,
},
build: {
minify: true, // GreasyFork 有代码长度限制,没办法
cssMinify: true,
},
resolve: {
Expand All @@ -33,11 +30,6 @@ export default defineConfig(async ({ mode }) => ({
include: resolve(dirname(fileURLToPath(import.meta.url)), './src/i18n/locales/**'),
strictMessage: false,
}),
components({
dts: false,
dirs: [],
resolvers: [ElementPlusResolver()],
}),
monkey({
entry: 'src/main.ts',
userscript: {
Expand Down Expand Up @@ -78,6 +70,19 @@ export default defineConfig(async ({ mode }) => ({
build: {
fileName: 'script.user.js',
metaFileName: true,
externalGlobals: {
vue: cdn.unpkg('Vue', 'dist/vue.global.prod.js').concat(
await util.fn2dataUrl(() => {
// @ts-expect-error
window.Vue = Vue;
}),
),
'element-plus': cdn.unpkg('ElementPlus', 'dist/index.full.min.js'),
jquery: cdn.unpkg('jQuery', 'dist/jquery.slim.min.js'),
},
externalResource: {
'element-plus/dist/index.css': cdn.unpkg('element-plus-css'),
},
},
}),
copy({
Expand Down
Loading

0 comments on commit f0fd24f

Please sign in to comment.