From afb2440d8b4b575a8d49dc0ffb23e08a72c99d2d Mon Sep 17 00:00:00 2001 From: Zhoujiahui <539943419@qq.com> Date: Wed, 4 Sep 2024 10:38:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=8F=92=E4=BB=B6=EF=BC=88=E5=B7=B2=E7=A6=81?= =?UTF-8?q?=E7=94=A8=EF=BC=89,=20=E6=9B=B4=E6=96=B0vue=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +- pnpm-lock.yaml | 172 +++++++------ src/components/miaoMessageProvider.vue | 4 +- src/hooks/init.ts | 328 ++++++++++++------------- vite.config.ts | 23 +- 5 files changed, 263 insertions(+), 268 deletions(-) diff --git a/package.json b/package.json index 0cf985d..531242e 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "vite", "dev:host": "vite --host 0.0.0.0", "build": "vue-tsc -b && vite build", - "build:auto": "pnpm run build && rm -rf ./serve/web/* && cp -r ./dist/* ./serve/web/ && cd ./serve && go env -w GOOS=windows && go build -o ../miao-directory.exe", + "build:auto": "pnpm run build && go env -w GOOS=windows GOARCH=amd64 && rm -rf ./serve/web/* && cp -r ./dist/* ./serve/web/ && cd ./serve && go env -w GOOS=windows && go build -o ../miao-directory.exe", "build:auto:release": "pnpm run build && rm -rf ./serve/web/* && cp -r ./dist/* ./serve/web/ && cd ./serve && go env -w GOOS=windows GOARCH=amd64 && go build -o ../miao-directory-amd64-win.exe && go env -w GOOS=linux GOARCH=amd64 && go build -o ../miao-directory-amd64-linux", "preview": "vite preview" }, @@ -31,7 +31,7 @@ "naive-ui": "^2.39.0", "pdfjs-dist": "^4.5.136", "sass": "^1.77.8", - "vue": "3.5.0-rc.1", + "vue": "3.5.0", "vue-codemirror": "^6.1.1", "xgplayer": "^3.0.20", "xgplayer-subtitles": "^3.0.20" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b465f52..599b3dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -58,7 +58,7 @@ importers: version: 14.1.0 naive-ui: specifier: ^2.39.0 - version: 2.39.0(vue@3.5.0-rc.1(typescript@5.5.4)) + version: 2.39.0(vue@3.5.0(typescript@5.5.4)) pdfjs-dist: specifier: ^4.5.136 version: 4.5.136 @@ -66,11 +66,11 @@ importers: specifier: ^1.77.8 version: 1.77.8 vue: - specifier: 3.5.0-rc.1 - version: 3.5.0-rc.1(typescript@5.5.4) + specifier: 3.5.0 + version: 3.5.0(typescript@5.5.4) vue-codemirror: specifier: ^6.1.1 - version: 6.1.1(codemirror@6.0.1(@lezer/common@1.2.1))(vue@3.5.0-rc.1(typescript@5.5.4)) + version: 6.1.1(codemirror@6.0.1(@lezer/common@1.2.1))(vue@3.5.0(typescript@5.5.4)) xgplayer: specifier: ^3.0.20 version: 3.0.20(core-js@3.38.1) @@ -92,7 +92,7 @@ importers: version: 2.10.378 '@vitejs/plugin-vue': specifier: ^5.1.2 - version: 5.1.2(vite@5.4.0(@types/node@22.1.0)(sass@1.77.8))(vue@3.5.0-rc.1(typescript@5.5.4)) + version: 5.1.2(vite@5.4.0(@types/node@22.1.0)(sass@1.77.8))(vue@3.5.0(typescript@5.5.4)) typescript: specifier: ^5.5.3 version: 5.5.4 @@ -530,20 +530,20 @@ packages: '@vue/compiler-core@3.4.37': resolution: {integrity: sha512-ZDDT/KiLKuCRXyzWecNzC5vTcubGz4LECAtfGPENpo0nrmqJHwuWtRLxk/Sb9RAKtR9iFflFycbkjkY+W/PZUQ==} - '@vue/compiler-core@3.5.0-rc.1': - resolution: {integrity: sha512-TtFvqdQmY5tn1GpQJrMmOR5b41Fi7kqNkG5V49B8nO69ceBmH3SmHVIt626dJRwr6d0WYw2Zsur+qRcdXlpwMg==} + '@vue/compiler-core@3.5.0': + resolution: {integrity: sha512-ja7cpqAOfw4tyFAxgBz70Z42miNDeaqTxExTsnXDLomRpqfyCgyvZvFp482fmsElpfvsoMJUsvzULhvxUTW6Iw==} '@vue/compiler-dom@3.4.37': resolution: {integrity: sha512-rIiSmL3YrntvgYV84rekAtU/xfogMUJIclUMeIKEtVBFngOL3IeZHhsH3UaFEgB5iFGpj6IW+8YuM/2Up+vVag==} - '@vue/compiler-dom@3.5.0-rc.1': - resolution: {integrity: sha512-o9ubpTXA7gRsfOLvqd5mghSAvX83zn+cpwpEjjNdrj5xNvuiwnYFa3IZ2jL+AO1AfqZRO4ar/qQ+HKbmujn6XA==} + '@vue/compiler-dom@3.5.0': + resolution: {integrity: sha512-xYjUybWZXl+1R/toDy815i4PbeehL2hThiSGkcpmIOCy2HoYyeeC/gAWK/Y/xsoK+GSw198/T5O31bYuQx5uvQ==} - '@vue/compiler-sfc@3.5.0-rc.1': - resolution: {integrity: sha512-lncE6PA0YYa5N2CGK8trkW8oj5REJIiz7foEVKAcDTHprSK0FoWw+aO/FrPkgG5i+7OOsPZ+q41DUizp2EfrgQ==} + '@vue/compiler-sfc@3.5.0': + resolution: {integrity: sha512-B9DgLtrqok2GLuaFjLlSL15ZG3ZDBiitUH1ecex9guh/ZcA5MCdwuVE6nsfQxktuZY/QY0awJ35/ripIviCQTQ==} - '@vue/compiler-ssr@3.5.0-rc.1': - resolution: {integrity: sha512-BsLWobytzgvjYjPjJDB2/VdK5P8Lzg/SwMGQaNgbfNa7E3fHqn4Vyd0Id69GdDrtP9hFf5+EuzbzuVgOwC0L/w==} + '@vue/compiler-ssr@3.5.0': + resolution: {integrity: sha512-E263QZmA1dqRd7c3u/sWTLRMpQOT0aZ8av/L9SoD/v/BVMZaWFHPUUBswS+bzrfvG2suJF8vSLKx6k6ba5SUdA==} '@vue/compiler-vue2@2.7.16': resolution: {integrity: sha512-qYC3Psj9S/mfu9uVi5WvNZIzq+xnXMhOwbTFKKDD7b1lhpnn71jXSFdTQ+WsIEk0ONCd7VV2IMm7ONl6tbQ86A==} @@ -556,25 +556,25 @@ packages: typescript: optional: true - '@vue/reactivity@3.5.0-rc.1': - resolution: {integrity: sha512-aE5Yvz/2oez2b02LvB9INUQLhjAMYYK87LjvzKkCDXjBQOdW8vzATJ4MJ1Rxm9RdNN5KQI8yK8F2hStycvULWg==} + '@vue/reactivity@3.5.0': + resolution: {integrity: sha512-Ew3F5riP3B3ZDGjD3ZKb9uZylTTPSqt8hAf4sGbvbjrjDjrFb3Jm15Tk1/w7WwTE5GbQ2Qhwxx1moc9hr8A/OQ==} - '@vue/runtime-core@3.5.0-rc.1': - resolution: {integrity: sha512-Cs9bfZu37WIljVZIEQ5aQc8SF4tLgCcnfRFpgVnoqRc9EKZ1zrTLGib/AOkpqeK4f+AUgs08xx49fib/hUtuBg==} + '@vue/runtime-core@3.5.0': + resolution: {integrity: sha512-mQyW0F9FaNRdt8ghkAs+BMG3iQ7LGgWKOpkzUzR5AI5swPNydHGL5hvVTqFaeMzwecF1g0c86H4yFQsSxJhH1w==} - '@vue/runtime-dom@3.5.0-rc.1': - resolution: {integrity: sha512-oOhonQQRakCNaF47wFgYKFg7aGzKW5sQM3YtiC6r4aF9s9BqPkuDNGW3VtjeJjg3wnRuuC42CH+E4E9a9ckq4A==} + '@vue/runtime-dom@3.5.0': + resolution: {integrity: sha512-NQQXjpdXgyYVJ2M56FJ+lSJgZiecgQ2HhxhnQBN95FymXegRNY/N2htI7vOTwpP75pfxhIeYOJ8mE8sW8KAW6A==} - '@vue/server-renderer@3.5.0-rc.1': - resolution: {integrity: sha512-jzPARtHkRms3qDsOqvc60oIDKSZw/6NhRXBL9pz3aFzibLC2/kG4n0tjGwlbE9AOxkqj8zINsMWh6gb0CToIpg==} + '@vue/server-renderer@3.5.0': + resolution: {integrity: sha512-HyDIFUg+l7L4PKrEnJlCYWHUOlm6NxZhmSxIefZ5MTYjkIPfDfkwhX7hqxAQHfgIAE1uLMLQZwuNR/ozI0NhZg==} peerDependencies: - vue: 3.5.0-rc.1 + vue: 3.5.0 '@vue/shared@3.4.37': resolution: {integrity: sha512-nIh8P2fc3DflG8+5Uw8PT/1i17ccFn0xxN/5oE9RfV5SVnd7G0XEFRwakrnNFE/jlS95fpGXDVG5zDETS26nmg==} - '@vue/shared@3.5.0-rc.1': - resolution: {integrity: sha512-iulYMVPJ+gYaK+PjkM7mNXr+DKkniGH0F3LyuyBak3X2amiG/gMDbnqTEH5ScTbV5DuzpQJMuFgW6VtIzKprTg==} + '@vue/shared@3.5.0': + resolution: {integrity: sha512-m9IgiteBpCkFaMNwCOBkFksA7z8QiKc30ooRuoXWUFRDu0mGyNPlFHmbncF0/Kra1RlX8QrmBbRaIxVvikaR0Q==} abbrev@1.1.1: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} @@ -997,6 +997,10 @@ packages: resolution: {integrity: sha512-TesUflQ0WKZqAvg52PWL6kHgLKP6xB6heTOdoYM0Wt2UHyxNa4K25EZZMgKns3BH1RLVbZCREPpLY0rhnNoHVQ==} engines: {node: ^10 || ^12 || >=14} + postcss@8.4.44: + resolution: {integrity: sha512-Aweb9unOEpQ3ezu4Q00DPvvM2ZTUitJdNKeP/+uQgr1IBIqu574IaZoURId7BKtWMREwzKa9OgzPzezWGPWFQw==} + engines: {node: ^10 || ^12 || >=14} + proxy-from-env@1.1.0: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} @@ -1173,8 +1177,8 @@ packages: peerDependencies: typescript: '>=5.0.0' - vue@3.5.0-rc.1: - resolution: {integrity: sha512-8p8+hzDP8AejAzxFRQWfTYkOeJmHLmMcqRcWvfglPo9YaSqzDswVpA+sj5k0n/2p5jF3kmf8VeW+GcySxgrBEQ==} + vue@3.5.0: + resolution: {integrity: sha512-1t70favYoFijwfWJ7g81aTd32obGaAnKYE9FNyMgnEzn3F4YncRi/kqAHHKloG0VXTD8vBYMhbgLKCA+Sk6QDw==} peerDependencies: typescript: '*' peerDependenciesMeta: @@ -1398,9 +1402,9 @@ snapshots: dependencies: css-render: 0.15.14 - '@css-render/vue3-ssr@0.15.14(vue@3.5.0-rc.1(typescript@5.5.4))': + '@css-render/vue3-ssr@0.15.14(vue@3.5.0(typescript@5.5.4))': dependencies: - vue: 3.5.0-rc.1(typescript@5.5.4) + vue: 3.5.0(typescript@5.5.4) '@emotion/hash@0.8.0': {} @@ -1642,10 +1646,10 @@ snapshots: '@vicons/ionicons5@0.12.0': {} - '@vitejs/plugin-vue@5.1.2(vite@5.4.0(@types/node@22.1.0)(sass@1.77.8))(vue@3.5.0-rc.1(typescript@5.5.4))': + '@vitejs/plugin-vue@5.1.2(vite@5.4.0(@types/node@22.1.0)(sass@1.77.8))(vue@3.5.0(typescript@5.5.4))': dependencies: vite: 5.4.0(@types/node@22.1.0)(sass@1.77.8) - vue: 3.5.0-rc.1(typescript@5.5.4) + vue: 3.5.0(typescript@5.5.4) '@volar/language-core@2.4.0-alpha.18': dependencies: @@ -1667,10 +1671,10 @@ snapshots: estree-walker: 2.0.2 source-map-js: 1.2.0 - '@vue/compiler-core@3.5.0-rc.1': + '@vue/compiler-core@3.5.0': dependencies: '@babel/parser': 7.25.3 - '@vue/shared': 3.5.0-rc.1 + '@vue/shared': 3.5.0 entities: 4.5.0 estree-walker: 2.0.2 source-map-js: 1.2.0 @@ -1680,27 +1684,27 @@ snapshots: '@vue/compiler-core': 3.4.37 '@vue/shared': 3.4.37 - '@vue/compiler-dom@3.5.0-rc.1': + '@vue/compiler-dom@3.5.0': dependencies: - '@vue/compiler-core': 3.5.0-rc.1 - '@vue/shared': 3.5.0-rc.1 + '@vue/compiler-core': 3.5.0 + '@vue/shared': 3.5.0 - '@vue/compiler-sfc@3.5.0-rc.1': + '@vue/compiler-sfc@3.5.0': dependencies: '@babel/parser': 7.25.3 - '@vue/compiler-core': 3.5.0-rc.1 - '@vue/compiler-dom': 3.5.0-rc.1 - '@vue/compiler-ssr': 3.5.0-rc.1 - '@vue/shared': 3.5.0-rc.1 + '@vue/compiler-core': 3.5.0 + '@vue/compiler-dom': 3.5.0 + '@vue/compiler-ssr': 3.5.0 + '@vue/shared': 3.5.0 estree-walker: 2.0.2 magic-string: 0.30.11 - postcss: 8.4.41 + postcss: 8.4.44 source-map-js: 1.2.0 - '@vue/compiler-ssr@3.5.0-rc.1': + '@vue/compiler-ssr@3.5.0': dependencies: - '@vue/compiler-dom': 3.5.0-rc.1 - '@vue/shared': 3.5.0-rc.1 + '@vue/compiler-dom': 3.5.0 + '@vue/shared': 3.5.0 '@vue/compiler-vue2@2.7.16': dependencies: @@ -1720,31 +1724,31 @@ snapshots: optionalDependencies: typescript: 5.5.4 - '@vue/reactivity@3.5.0-rc.1': + '@vue/reactivity@3.5.0': dependencies: - '@vue/shared': 3.5.0-rc.1 + '@vue/shared': 3.5.0 - '@vue/runtime-core@3.5.0-rc.1': + '@vue/runtime-core@3.5.0': dependencies: - '@vue/reactivity': 3.5.0-rc.1 - '@vue/shared': 3.5.0-rc.1 + '@vue/reactivity': 3.5.0 + '@vue/shared': 3.5.0 - '@vue/runtime-dom@3.5.0-rc.1': + '@vue/runtime-dom@3.5.0': dependencies: - '@vue/reactivity': 3.5.0-rc.1 - '@vue/runtime-core': 3.5.0-rc.1 - '@vue/shared': 3.5.0-rc.1 + '@vue/reactivity': 3.5.0 + '@vue/runtime-core': 3.5.0 + '@vue/shared': 3.5.0 csstype: 3.1.3 - '@vue/server-renderer@3.5.0-rc.1(vue@3.5.0-rc.1(typescript@5.5.4))': + '@vue/server-renderer@3.5.0(vue@3.5.0(typescript@5.5.4))': dependencies: - '@vue/compiler-ssr': 3.5.0-rc.1 - '@vue/shared': 3.5.0-rc.1 - vue: 3.5.0-rc.1(typescript@5.5.4) + '@vue/compiler-ssr': 3.5.0 + '@vue/shared': 3.5.0 + vue: 3.5.0(typescript@5.5.4) '@vue/shared@3.4.37': {} - '@vue/shared@3.5.0-rc.1': {} + '@vue/shared@3.5.0': {} abbrev@1.1.1: optional: true @@ -2148,10 +2152,10 @@ snapshots: muggle-string@0.4.1: {} - naive-ui@2.39.0(vue@3.5.0-rc.1(typescript@5.5.4)): + naive-ui@2.39.0(vue@3.5.0(typescript@5.5.4)): dependencies: '@css-render/plugin-bem': 0.15.14(css-render@0.15.14) - '@css-render/vue3-ssr': 0.15.14(vue@3.5.0-rc.1(typescript@5.5.4)) + '@css-render/vue3-ssr': 0.15.14(vue@3.5.0(typescript@5.5.4)) '@types/katex': 0.16.7 '@types/lodash': 4.17.7 '@types/lodash-es': 4.17.12 @@ -2166,10 +2170,10 @@ snapshots: lodash-es: 4.17.21 seemly: 0.3.8 treemate: 0.3.11 - vdirs: 0.1.8(vue@3.5.0-rc.1(typescript@5.5.4)) - vooks: 0.2.12(vue@3.5.0-rc.1(typescript@5.5.4)) - vue: 3.5.0-rc.1(typescript@5.5.4) - vueuc: 0.4.58(vue@3.5.0-rc.1(typescript@5.5.4)) + vdirs: 0.1.8(vue@3.5.0(typescript@5.5.4)) + vooks: 0.2.12(vue@3.5.0(typescript@5.5.4)) + vue: 3.5.0(typescript@5.5.4) + vueuc: 0.4.58(vue@3.5.0(typescript@5.5.4)) nan@2.20.0: optional: true @@ -2232,6 +2236,12 @@ snapshots: picocolors: 1.0.1 source-map-js: 1.2.0 + postcss@8.4.44: + dependencies: + nanoid: 3.3.7 + picocolors: 1.0.1 + source-map-js: 1.2.0 + proxy-from-env@1.1.0: {} punycode.js@2.3.1: {} @@ -2361,10 +2371,10 @@ snapshots: util-deprecate@1.0.2: optional: true - vdirs@0.1.8(vue@3.5.0-rc.1(typescript@5.5.4)): + vdirs@0.1.8(vue@3.5.0(typescript@5.5.4)): dependencies: evtd: 0.2.4 - vue: 3.5.0-rc.1(typescript@5.5.4) + vue: 3.5.0(typescript@5.5.4) vite-plugin-singlefile@2.0.2(rollup@4.20.0)(vite@5.4.0(@types/node@22.1.0)(sass@1.77.8)): dependencies: @@ -2382,21 +2392,21 @@ snapshots: fsevents: 2.3.3 sass: 1.77.8 - vooks@0.2.12(vue@3.5.0-rc.1(typescript@5.5.4)): + vooks@0.2.12(vue@3.5.0(typescript@5.5.4)): dependencies: evtd: 0.2.4 - vue: 3.5.0-rc.1(typescript@5.5.4) + vue: 3.5.0(typescript@5.5.4) vscode-uri@3.0.8: {} - vue-codemirror@6.1.1(codemirror@6.0.1(@lezer/common@1.2.1))(vue@3.5.0-rc.1(typescript@5.5.4)): + vue-codemirror@6.1.1(codemirror@6.0.1(@lezer/common@1.2.1))(vue@3.5.0(typescript@5.5.4)): dependencies: '@codemirror/commands': 6.6.0 '@codemirror/language': 6.10.2 '@codemirror/state': 6.4.1 '@codemirror/view': 6.33.0 codemirror: 6.0.1(@lezer/common@1.2.1) - vue: 3.5.0-rc.1(typescript@5.5.4) + vue: 3.5.0(typescript@5.5.4) vue-tsc@2.0.29(typescript@5.5.4): dependencies: @@ -2405,26 +2415,26 @@ snapshots: semver: 7.6.3 typescript: 5.5.4 - vue@3.5.0-rc.1(typescript@5.5.4): + vue@3.5.0(typescript@5.5.4): dependencies: - '@vue/compiler-dom': 3.5.0-rc.1 - '@vue/compiler-sfc': 3.5.0-rc.1 - '@vue/runtime-dom': 3.5.0-rc.1 - '@vue/server-renderer': 3.5.0-rc.1(vue@3.5.0-rc.1(typescript@5.5.4)) - '@vue/shared': 3.5.0-rc.1 + '@vue/compiler-dom': 3.5.0 + '@vue/compiler-sfc': 3.5.0 + '@vue/runtime-dom': 3.5.0 + '@vue/server-renderer': 3.5.0(vue@3.5.0(typescript@5.5.4)) + '@vue/shared': 3.5.0 optionalDependencies: typescript: 5.5.4 - vueuc@0.4.58(vue@3.5.0-rc.1(typescript@5.5.4)): + vueuc@0.4.58(vue@3.5.0(typescript@5.5.4)): dependencies: - '@css-render/vue3-ssr': 0.15.14(vue@3.5.0-rc.1(typescript@5.5.4)) + '@css-render/vue3-ssr': 0.15.14(vue@3.5.0(typescript@5.5.4)) '@juggle/resize-observer': 3.4.0 css-render: 0.15.14 evtd: 0.2.4 seemly: 0.3.8 - vdirs: 0.1.8(vue@3.5.0-rc.1(typescript@5.5.4)) - vooks: 0.2.12(vue@3.5.0-rc.1(typescript@5.5.4)) - vue: 3.5.0-rc.1(typescript@5.5.4) + vdirs: 0.1.8(vue@3.5.0(typescript@5.5.4)) + vooks: 0.2.12(vue@3.5.0(typescript@5.5.4)) + vue: 3.5.0(typescript@5.5.4) w3c-keyname@2.2.8: {} diff --git a/src/components/miaoMessageProvider.vue b/src/components/miaoMessageProvider.vue index 6961adf..5210b2e 100644 --- a/src/components/miaoMessageProvider.vue +++ b/src/components/miaoMessageProvider.vue @@ -43,7 +43,7 @@ const rootRef = ref() const maxMessageWidth = ref(-1) const messageList = computed(() => { - return Object.keys(messageMap).filter(v => messageMap[v] !== undefined).map(v => ({ + return Object.keys(messageMap).map(v => ({ id: v, ...messageMap[v], })) @@ -54,7 +54,7 @@ const message = (content: string, options?: MessageOptions) => { if (timeout > 0) { messageMap[id]?.timer && clearTimeout(messageMap[id]?.timer) timer = setTimeout(() => { - messageMap[id] = undefined + delete messageMap[id] }, timeout) } messageMap[id] = { diff --git a/src/hooks/init.ts b/src/hooks/init.ts index a141b5c..e0fcd52 100644 --- a/src/hooks/init.ts +++ b/src/hooks/init.ts @@ -1,177 +1,167 @@ -import MiaoDirectory from '@/views/miaoDirectory.vue' -import usePluginCenter from './usePluginCenter' -import { - DocumentText, - FileTray, - Image, - LogoChrome, - CodeOutline, - PlayCircle, -} from '@vicons/ionicons5' +import MiaoDirectory from "@/views/miaoDirectory.vue"; +import usePluginCenter from "./usePluginCenter"; +import { DocumentText, FileTray, Image, LogoChrome, CodeOutline, PlayCircle } from "@vicons/ionicons5"; +import { PluginGroup } from "@/class/PluginCenter"; export default function init() { - const pluginCenter = usePluginCenter() - pluginCenter.registerComponent({ - key: 'miaoDirectory', - name: '文件夹', - icon: FileTray, - getComponent: async () => MiaoDirectory, - filter: (vDirs, vFiles) => { - if (vFiles.length) { - return false - } - return vDirs.length === 1 - } - }) - pluginCenter.registerComponent({ - key: 'miaoVideoPlayer', - name: '视频', - icon: PlayCircle, - getComponent: async () => - (await import('@/views/miaoVideoPlayer.vue')).default, - filter: (vDirs, vFiles) => { - if (vDirs.length !== 0) { - return false - } - if (vFiles.length === 0) { - return false - } - for (let i of vFiles) { - for (let s of ['mp4', 'm3u8', 'hls']) { - if (i.name.endsWith(s)) { - return true - } - } - } - return false - } - }) + const pluginCenter = usePluginCenter(); + pluginCenter.registerComponent({ + key: "miaoDirectory", + name: "文件夹", + icon: FileTray, + getComponent: async () => MiaoDirectory, + filter: (vDirs, vFiles) => { + if (vFiles.length) { + return false; + } + return vDirs.length === 1; + } + }); + pluginCenter.registerComponent({ + key: "miaoVideoPlayer", + name: "视频", + icon: PlayCircle, + getComponent: async () => (await import("@/views/miaoVideoPlayer.vue")).default, + filter: (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false; + } + if (vFiles.length === 0) { + return false; + } + for (let i of vFiles) { + for (let s of ["mp4", "m3u8", "hls"]) { + if (i.name.endsWith(s)) { + return true; + } + } + } + return false; + } + }); - pluginCenter.registerComponent({ - key: 'miaoIframe', - name: '框架', - icon: LogoChrome, - getComponent: async () => - (await import('@/views/miaoIframe.vue')).default, - filter: (vDirs, vFiles) => { - if (vDirs.length !== 0) { - return false - } - if (vFiles.length !== 1) { - return false - } - return vFiles[0].name.endsWith('html') - } - }) + pluginCenter.registerComponent({ + key: "miaoIframe", + name: "框架", + icon: LogoChrome, + getComponent: async () => (await import("@/views/miaoIframe.vue")).default, + filter: (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false; + } + if (vFiles.length !== 1) { + return false; + } + return vFiles[0].name.endsWith("html"); + } + }); - pluginCenter.registerComponent({ - key: 'miaoPDF', - name: 'PDF浏览', - icon: DocumentText, - getComponent: async () => (await import('@/views/miaoPDF.vue')).default, - filter: (vDirs, vFiles) => { - if (vDirs.length !== 0) { - return false - } - if (vFiles.length !== 1) { - return false - } - return vFiles[0].name.endsWith('pdf') - } - }) + pluginCenter.registerComponent({ + key: "miaoPDF", + name: "PDF浏览", + icon: DocumentText, + getComponent: async () => (await import("@/views/miaoPDF.vue")).default, + filter: (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false; + } + if (vFiles.length !== 1) { + return false; + } + return vFiles[0].name.endsWith("pdf"); + } + }); - pluginCenter.registerComponent({ - key: 'miaoCodeMirror', - name: '代码编辑', - icon: CodeOutline, - getComponent: async () => - (await import('@/views/miaoCodeMirror.vue')).default, - filter: (vDirs, vFiles) => { - if (vDirs.length !== 0) { - return false - } - if (vFiles.length !== 1) { - return false - } - for (let end of [ - 'js', - 'ts', - 'jsx', - 'tsx', - 'py', - 'html', - 'css', - 'scss', - 'go', - 'json', - 'md', - 'yaml', - 'txt', - 'xml', - 'vue' - ]) { - if (vFiles[0].name.endsWith(end)) { - return true - } - } - return false - } - }) + pluginCenter.registerComponent({ + key: "miaoCodeMirror", + name: "代码编辑", + icon: CodeOutline, + getComponent: async () => (await import("@/views/miaoCodeMirror.vue")).default, + filter: (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false; + } + if (vFiles.length !== 1) { + return false; + } + for (let end of ["js", "ts", "jsx", "tsx", "py", "html", "css", "scss", "go", "json", "md", "yaml", "txt", "xml", "vue"]) { + if (vFiles[0].name.endsWith(end)) { + return true; + } + } + return false; + } + }); - pluginCenter.registerComponent({ - key: 'miaoImages', - name: '图片浏览', - icon: Image, - getComponent: async () => - (await import('@/views/miaoImages.vue')).default, - filter: (vDirs, vFiles) => { - if (vDirs.length === 0 && vFiles.length === 0) { - return false - } - if (vDirs.length) { - return true - } - for (let vf of vFiles) - for (let end of [ - 'xbm', - 'tif', - 'pjp', - 'svgz', - 'jpg', - 'jpeg', - 'ico', - 'tiff', - 'gif', - 'svg', - 'jfif', - 'webp', - 'png', - '.bmp', - 'pjpeg', - 'avif' - ]) { - if (vf.name.endsWith(end)) { - return true - } - } - return false - } - }) + pluginCenter.registerComponent({ + key: "miaoImages", + name: "图片浏览", + icon: Image, + getComponent: async () => (await import("@/views/miaoImages.vue")).default, + filter: (vDirs, vFiles) => { + if (vDirs.length === 0 && vFiles.length === 0) { + return false; + } + if (vDirs.length) { + return true; + } + for (let vf of vFiles) + for (let end of ["xbm", "tif", "pjp", "svgz", "jpg", "jpeg", "ico", "tiff", "gif", "svg", "jfif", "webp", "png", ".bmp", "pjpeg", "avif"]) { + if (vf.name.endsWith(end)) { + return true; + } + } + return false; + } + }); - - pluginCenter.registerComponent({ - key: 'miaoMarkdown', - name: 'markdown浏览', - icon: DocumentText, - getComponent: async () => (await import('@/views/miaoMarkdown.vue')).default, - filter: (vDirs, vFiles) => { - if (vDirs.length !== 0) { - return false - } - if (vFiles.length !== 1) { - return false - } - return vFiles[0].name.endsWith('md') - } - }) + pluginCenter.registerComponent({ + key: "miaoMarkdown", + name: "markdown浏览", + icon: DocumentText, + getComponent: async () => (await import("@/views/miaoMarkdown.vue")).default, + filter: (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false; + } + if (vFiles.length !== 1) { + return false; + } + return vFiles[0].name.endsWith("md"); + } + }); + + pluginCenter.register("test", { + name: "测试导入", + filter: (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false; + } + if (vFiles.length !== 1) { + return false; + } + return vFiles[0].name.endsWith("js"); + }, + disable: true, + group: [PluginGroup.default], + func: async (__, vfs) => { + const c = (await import(/* @vite-ignore */ vfs[0].url)).default; + console.log(c); + pluginCenter.registerComponent({ + key: `test-${Math.random()}`, + name: `test-${Math.random()}`, + icon: DocumentText, + getComponent: async () => (await import(/* @vite-ignore */ vfs[0].url)).default, + filter: (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false; + } + if (vFiles.length !== 1) { + return false; + } + return vFiles[0].name.endsWith("html"); + } + }); + } + }); } diff --git a/vite.config.ts b/vite.config.ts index fe92d62..24fd3e0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -59,21 +59,16 @@ export default defineConfig({ build: { rollupOptions: { input: { - main: resolve(__dirname, 'index.html') + main: '/src/index.ts' }, - output: { - // 配置输出为单文件 - // inlineDynamicImports: true, - // manualChunks(id) { - // 加了会有bug - // if (id.includes('@codemirror')) { - // return id.split('@')[1].replace('+', '-') - // } - // } - // entryFileNames: 'bundle.js', - // format: 'iife', // 立即执行函数格式 - // name: 'MyBundle' - } + // output: { + // entryFileNames: (chunkInfo) => { + // if (chunkInfo.name === 'main') { + // return 'main.js' + // } + // return '[name].[hash].js' + // } + // } } } })