From 86b3a022378ddd8db439d075b3ca2eddb0fc155a Mon Sep 17 00:00:00 2001 From: Zhoujiahui <539943419@qq.com> Date: Thu, 29 Aug 2024 12:24:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AE=E4=BA=86?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=8A=A8=E6=80=81=E5=AF=BC=E5=85=A5=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E4=B8=80=E4=B8=AA=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=BA=A6=E4=B8=8D=E9=AB=98=E7=9A=84=E4=BB=A3=E7=A0=81=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 + pnpm-lock.yaml | 241 +++++++++++++++++++++++++++++++++++ src/App.vue | 2 +- src/class/PluginCenter.ts | 44 +++++-- src/hooks/init.ts | 42 ++++-- src/hooks/useMiaoFetchApi.ts | 22 +++- src/views/miaoCodeMirror.vue | 63 +++++++++ src/views/miaoPDF.vue | 4 +- vite.config.ts | 25 +++- 9 files changed, 414 insertions(+), 35 deletions(-) create mode 100644 src/views/miaoCodeMirror.vue diff --git a/package.json b/package.json index f75c6a2..d34939f 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,19 @@ "preview": "vite preview" }, "dependencies": { + "@codemirror/lang-css": "^6.2.1", + "@codemirror/lang-html": "^6.4.9", + "@codemirror/lang-javascript": "^6.2.2", + "@codemirror/lang-python": "^6.1.6", "@vicons/ionicons5": "^0.12.0", "axios": "^1.7.3", + "codemirror": "^6.0.1", "lodash": "^4.17.21", "naive-ui": "^2.39.0", "pdfjs-dist": "^4.5.136", "sass": "^1.77.8", "vue": "^3.4.35", + "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 d356f13..fc6fa9c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,12 +8,27 @@ importers: .: dependencies: + '@codemirror/lang-css': + specifier: ^6.2.1 + version: 6.2.1(@codemirror/view@6.33.0) + '@codemirror/lang-html': + specifier: ^6.4.9 + version: 6.4.9 + '@codemirror/lang-javascript': + specifier: ^6.2.2 + version: 6.2.2 + '@codemirror/lang-python': + specifier: ^6.1.6 + version: 6.1.6(@codemirror/view@6.33.0) '@vicons/ionicons5': specifier: ^0.12.0 version: 0.12.0 axios: specifier: ^1.7.3 version: 1.7.3 + codemirror: + specifier: ^6.0.1 + version: 6.0.1(@lezer/common@1.2.1) lodash: specifier: ^4.17.21 version: 4.17.21 @@ -29,6 +44,9 @@ importers: vue: specifier: ^3.4.35 version: 3.4.37(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.4.37(typescript@5.5.4)) xgplayer: specifier: ^3.0.20 version: 3.0.20(core-js@3.38.1) @@ -84,6 +102,44 @@ packages: resolution: {integrity: sha512-YTnYtra7W9e6/oAZEHj0bJehPRUlLH9/fbpT5LfB0NhQXyALCRkRs3zH9v07IYhkgpqX6Z78FnuccZr/l4Fs4Q==} engines: {node: '>=6.9.0'} + '@codemirror/autocomplete@6.18.0': + resolution: {integrity: sha512-5DbOvBbY4qW5l57cjDsmmpDh3/TeK1vXfTHa+BUMrRzdWdcxKZ4U4V7vQaTtOpApNU4kLS4FQ6cINtLg245LXA==} + peerDependencies: + '@codemirror/language': ^6.0.0 + '@codemirror/state': ^6.0.0 + '@codemirror/view': ^6.0.0 + '@lezer/common': ^1.0.0 + + '@codemirror/commands@6.6.0': + resolution: {integrity: sha512-qnY+b7j1UNcTS31Eenuc/5YJB6gQOzkUoNmJQc0rznwqSRpeaWWpjkWy2C/MPTcePpsKJEM26hXrOXl1+nceXg==} + + '@codemirror/lang-css@6.2.1': + resolution: {integrity: sha512-/UNWDNV5Viwi/1lpr/dIXJNWiwDxpw13I4pTUAsNxZdg6E0mI2kTQb0P2iHczg1Tu+H4EBgJR+hYhKiHKko7qg==} + + '@codemirror/lang-html@6.4.9': + resolution: {integrity: sha512-aQv37pIMSlueybId/2PVSP6NPnmurFDVmZwzc7jszd2KAF8qd4VBbvNYPXWQq90WIARjsdVkPbw29pszmHws3Q==} + + '@codemirror/lang-javascript@6.2.2': + resolution: {integrity: sha512-VGQfY+FCc285AhWuwjYxQyUQcYurWlxdKYT4bqwr3Twnd5wP5WSeu52t4tvvuWmljT4EmgEgZCqSieokhtY8hg==} + + '@codemirror/lang-python@6.1.6': + resolution: {integrity: sha512-ai+01WfZhWqM92UqjnvorkxosZ2aq2u28kHvr+N3gu012XqY2CThD67JPMHnGceRfXPDBmn1HnyqowdpF57bNg==} + + '@codemirror/language@6.10.2': + resolution: {integrity: sha512-kgbTYTo0Au6dCSc/TFy7fK3fpJmgHDv1sG1KNQKJXVi+xBTEeBPY/M30YXiU6mMXeH+YIDLsbrT4ZwNRdtF+SA==} + + '@codemirror/lint@6.8.1': + resolution: {integrity: sha512-IZ0Y7S4/bpaunwggW2jYqwLuHj0QtESf5xcROewY6+lDNwZ/NzvR4t+vpYgg9m7V8UXLPYqG+lu3DF470E5Oxg==} + + '@codemirror/search@6.5.6': + resolution: {integrity: sha512-rpMgcsh7o0GuCDUXKPvww+muLA1pDJaFrpq/CCHtpQJYz8xopu4D1hPcKRoDD0YlF8gZaqTNIRa4VRBWyhyy7Q==} + + '@codemirror/state@6.4.1': + resolution: {integrity: sha512-QkEyUiLhsJoZkbumGZlswmAhA7CBU02Wrz7zvH4SrcifbsqwlXShVXg65f3v/ts57W3dqyamEriMhij1Z3Zz4A==} + + '@codemirror/view@6.33.0': + resolution: {integrity: sha512-AroaR3BvnjRW8fiZBalAaK+ZzB5usGgI014YKElYZvQdNH5ZIidHlO+cyf/2rWzyBFRkvG6VhiXeAEbC53P2YQ==} + '@css-render/plugin-bem@0.15.14': resolution: {integrity: sha512-QK513CJ7yEQxm/P3EwsI+d+ha8kSOcjGvD6SevM41neEMxdULE+18iuQK6tEChAWMOQNQPLG/Rw3Khb69r5neg==} peerDependencies: @@ -241,6 +297,27 @@ packages: '@juggle/resize-observer@3.4.0': resolution: {integrity: sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==} + '@lezer/common@1.2.1': + resolution: {integrity: sha512-yemX0ZD2xS/73llMZIK6KplkjIjf2EvAHcinDi/TfJ9hS25G0388+ClHt6/3but0oOxinTcQHJLDXh6w1crzFQ==} + + '@lezer/css@1.1.8': + resolution: {integrity: sha512-7JhxupKuMBaWQKjQoLtzhGj83DdnZY9MckEOG5+/iLKNK2ZJqKc6hf6uc0HjwCX7Qlok44jBNqZhHKDhEhZYLA==} + + '@lezer/highlight@1.2.1': + resolution: {integrity: sha512-Z5duk4RN/3zuVO7Jq0pGLJ3qynpxUVsh7IbUbGj88+uV2ApSAn6kWg2au3iJb+0Zi7kKtqffIESgNcRXWZWmSA==} + + '@lezer/html@1.3.10': + resolution: {integrity: sha512-dqpT8nISx/p9Do3AchvYGV3qYc4/rKr3IBZxlHmpIKam56P47RSHkSF5f13Vu9hebS1jM0HmtJIwLbWz1VIY6w==} + + '@lezer/javascript@1.4.17': + resolution: {integrity: sha512-bYW4ctpyGK+JMumDApeUzuIezX01H76R1foD6LcRX224FWfyYit/HYxiPGDjXXe/wQWASjCvVGoukTH68+0HIA==} + + '@lezer/lr@1.4.2': + resolution: {integrity: sha512-pu0K1jCIdnQ12aWNaAVU5bzi7Bd1w54J3ECgANPmYLtQKP0HBj2cE/5coBD66MT10xbtIuUr7tg0Shbsvk0mDA==} + + '@lezer/python@1.1.14': + resolution: {integrity: sha512-ykDOb2Ti24n76PJsSa4ZoDF0zH12BSw1LGfQXCYJhJyOGiFTfGaX0Du66Ze72R+u/P35U+O6I9m8TFXov1JzsA==} + '@mapbox/node-pre-gyp@1.0.11': resolution: {integrity: sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==} hasBin: true @@ -473,6 +550,9 @@ packages: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} engines: {node: '>=10'} + codemirror@6.0.1: + resolution: {integrity: sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==} + color-support@1.1.3: resolution: {integrity: sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==} hasBin: true @@ -493,6 +573,9 @@ packages: core-js@3.38.1: resolution: {integrity: sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==} + crelt@1.0.6: + resolution: {integrity: sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==} + css-render@0.15.14: resolution: {integrity: sha512-9nF4PdUle+5ta4W5SyZdLCCmFd37uVimSjg1evcTqKJCyvCEEj12WKzOSBNak6r4im4J4iYXKH1OWpUV5LBYFg==} @@ -881,6 +964,9 @@ packages: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} + style-mod@4.1.2: + resolution: {integrity: sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==} + tar@6.2.1: resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} @@ -964,6 +1050,12 @@ packages: vscode-uri@3.0.8: resolution: {integrity: sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==} + vue-codemirror@6.1.1: + resolution: {integrity: sha512-rTAYo44owd282yVxKtJtnOi7ERAcXTeviwoPXjIc6K/IQYUsoDkzPvw/JDFtSP6T7Cz/2g3EHaEyeyaQCKoDMg==} + peerDependencies: + codemirror: 6.x + vue: 3.x + vue-tsc@2.0.29: resolution: {integrity: sha512-MHhsfyxO3mYShZCGYNziSbc63x7cQ5g9kvijV7dRe1TTXBRLxXyL0FnXWpUF1xII2mJ86mwYpYsUmMwkmerq7Q==} hasBin: true @@ -983,6 +1075,9 @@ packages: peerDependencies: vue: ^3.0.11 + w3c-keyname@2.2.8: + resolution: {integrity: sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==} + webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} @@ -1028,6 +1123,91 @@ snapshots: '@babel/helper-validator-identifier': 7.24.7 to-fast-properties: 2.0.0 + '@codemirror/autocomplete@6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1)': + dependencies: + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + '@lezer/common': 1.2.1 + + '@codemirror/commands@6.6.0': + dependencies: + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + '@lezer/common': 1.2.1 + + '@codemirror/lang-css@6.2.1(@codemirror/view@6.33.0)': + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@lezer/common': 1.2.1 + '@lezer/css': 1.1.8 + transitivePeerDependencies: + - '@codemirror/view' + + '@codemirror/lang-html@6.4.9': + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/lang-css': 6.2.1(@codemirror/view@6.33.0) + '@codemirror/lang-javascript': 6.2.2 + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + '@lezer/common': 1.2.1 + '@lezer/css': 1.1.8 + '@lezer/html': 1.3.10 + + '@codemirror/lang-javascript@6.2.2': + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/language': 6.10.2 + '@codemirror/lint': 6.8.1 + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + '@lezer/common': 1.2.1 + '@lezer/javascript': 1.4.17 + + '@codemirror/lang-python@6.1.6(@codemirror/view@6.33.0)': + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@lezer/common': 1.2.1 + '@lezer/python': 1.1.14 + transitivePeerDependencies: + - '@codemirror/view' + + '@codemirror/language@6.10.2': + dependencies: + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + style-mod: 4.1.2 + + '@codemirror/lint@6.8.1': + dependencies: + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + crelt: 1.0.6 + + '@codemirror/search@6.5.6': + dependencies: + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + crelt: 1.0.6 + + '@codemirror/state@6.4.1': {} + + '@codemirror/view@6.33.0': + dependencies: + '@codemirror/state': 6.4.1 + style-mod: 4.1.2 + w3c-keyname: 2.2.8 + '@css-render/plugin-bem@0.15.14(css-render@0.15.14)': dependencies: css-render: 0.15.14 @@ -1111,6 +1291,40 @@ snapshots: '@juggle/resize-observer@3.4.0': {} + '@lezer/common@1.2.1': {} + + '@lezer/css@1.1.8': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + + '@lezer/highlight@1.2.1': + dependencies: + '@lezer/common': 1.2.1 + + '@lezer/html@1.3.10': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + + '@lezer/javascript@1.4.17': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + + '@lezer/lr@1.4.2': + dependencies: + '@lezer/common': 1.2.1 + + '@lezer/python@1.1.14': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + '@mapbox/node-pre-gyp@1.0.11': dependencies: detect-libc: 2.0.3 @@ -1369,6 +1583,18 @@ snapshots: chownr@2.0.0: optional: true + codemirror@6.0.1(@lezer/common@1.2.1): + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/commands': 6.6.0 + '@codemirror/language': 6.10.2 + '@codemirror/lint': 6.8.1 + '@codemirror/search': 6.5.6 + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + transitivePeerDependencies: + - '@lezer/common' + color-support@1.1.3: optional: true @@ -1386,6 +1612,8 @@ snapshots: core-js@3.38.1: {} + crelt@1.0.6: {} + css-render@0.15.14: dependencies: '@emotion/hash': 0.8.0 @@ -1833,6 +2061,8 @@ snapshots: ansi-regex: 5.0.1 optional: true + style-mod@4.1.2: {} + tar@6.2.1: dependencies: chownr: 2.0.0 @@ -1891,6 +2121,15 @@ snapshots: vscode-uri@3.0.8: {} + vue-codemirror@6.1.1(codemirror@6.0.1(@lezer/common@1.2.1))(vue@3.4.37(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.4.37(typescript@5.5.4) + vue-tsc@2.0.29(typescript@5.5.4): dependencies: '@volar/typescript': 2.4.0-alpha.18 @@ -1919,6 +2158,8 @@ snapshots: vooks: 0.2.12(vue@3.4.37(typescript@5.5.4)) vue: 3.4.37(typescript@5.5.4) + w3c-keyname@2.2.8: {} + webidl-conversions@3.0.1: optional: true diff --git a/src/App.vue b/src/App.vue index fffe030..5c51614 100644 --- a/src/App.vue +++ b/src/App.vue @@ -327,7 +327,7 @@ $tag-width: 170px; display: flex; // flex-direction: column; height: calc(100% - $controller-height); - overflow-y: overlay; + overflow-y: hidden; overflow-x: overlay; .view-container-item { diff --git a/src/class/PluginCenter.ts b/src/class/PluginCenter.ts index f27c07d..985d84e 100644 --- a/src/class/PluginCenter.ts +++ b/src/class/PluginCenter.ts @@ -1,5 +1,5 @@ -import useViretualPages from "@/hooks/useVirtualPages" -import VirtualDirectory, { VirtualFile } from "./VirtualDirectory" +import useVirtualPages from '@/hooks/useVirtualPages' +import VirtualDirectory, { VirtualFile } from './VirtualDirectory' type plugin = { // 用于显示的名字 @@ -18,7 +18,7 @@ export default class PluginCenter { [key: string]: plugin } - register(key: string, plugin: plugin){ + register(key: string, plugin: plugin) { this.pluginsMap[key] = plugin console.log(this.pluginsMap) } @@ -26,35 +26,51 @@ export default class PluginCenter { /** * 便捷地注册一个组件为插件,触发时直接用新页面打开 */ - registerComponent(key: string,name: string, component: any, filter:(VDirectorys: VirtualDirectory[], VFiles: VirtualFile[]) => boolean): void { + registerComponent( + key: string, + name: string, + getComponent: () => any, + filter: ( + VDirectorys: VirtualDirectory[], + VFiles: VirtualFile[] + ) => boolean + ): void { + let _component: any + const views = useVirtualPages() this.register(key, { name, filter, - func: (VDirectorys: VirtualDirectory[], VFiles: VirtualFile[]) => { - if(filter(VDirectorys, VFiles) === false){ + func: async ( + VDirectorys: VirtualDirectory[], + VFiles: VirtualFile[] + ) => { + if (filter(VDirectorys, VFiles) === false) { return } - const views = useViretualPages() - views.push(component, VDirectorys, VFiles) + if (_component === undefined) _component = await getComponent() + views.push(_component, VDirectorys, VFiles) } }) } getUsablePlugin(VDirectorys: VirtualDirectory[], VFiles: VirtualFile[]) { const usableList = [] - for(let key of Object.keys(this.pluginsMap)) { - if(this.pluginsMap[key].filter(VDirectorys, VFiles)) { + for (let key of Object.keys(this.pluginsMap)) { + if (this.pluginsMap[key].filter(VDirectorys, VFiles)) { usableList.push(key) } } - return usableList.map(key=>({ + return usableList.map((key) => ({ key, ...this.pluginsMap[key] })) } - usePlugin(key: string, VDirectorys: VirtualDirectory[], VFiles: VirtualFile[]) { + usePlugin( + key: string, + VDirectorys: VirtualDirectory[], + VFiles: VirtualFile[] + ) { this.pluginsMap[key].func(VDirectorys, VFiles) } - -} \ No newline at end of file +} diff --git a/src/hooks/init.ts b/src/hooks/init.ts index 781a206..859bd3d 100644 --- a/src/hooks/init.ts +++ b/src/hooks/init.ts @@ -1,15 +1,12 @@ -import MiaoDirectory from '@/views/miaoDirectory.vue' +// import MiaoDirectory from '@/views/miaoDirectory.vue' import usePluginCenter from './usePluginCenter' -import MiaoVideoPlayer from '@/views/miaoVideoPlayer.vue' -import MiaoIframe from '@/views/miaoIframe.vue' -import MiaoPDF from '@/views/miaoPDF.vue' export default function init() { const pluginCenter = usePluginCenter() pluginCenter.registerComponent( 'miaoDirectory', '文件夹', - MiaoDirectory, + async() => (await import('@/views/miaoDirectory.vue')).default, (vDirs, vFiles) => { if (vFiles.length) { return false @@ -20,7 +17,7 @@ export default function init() { pluginCenter.registerComponent( 'miaoVideoPlayer', '视频', - MiaoVideoPlayer, + async () => (await import('@/views/miaoVideoPlayer.vue')).default, (vDirs, vFiles) => { if (vDirs.length !== 0) { return false @@ -41,15 +38,21 @@ export default function init() { pluginCenter.registerComponent( 'miaoIframe', '框架', - MiaoIframe, - () => { - return false + async () => (await import('@/views/miaoIframe.vue')).default, + (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false + } + if (vFiles.length !== 1) { + return false + } + return vFiles[0].name.endsWith('html') } ) pluginCenter.registerComponent( 'miaoPDF', 'PDF浏览', - MiaoPDF, + async () => (await import('@/views/miaoPDF.vue')).default, (vDirs, vFiles) => { if (vDirs.length !== 0) { return false @@ -60,4 +63,23 @@ export default function init() { return vFiles[0].name.endsWith('pdf') } ) + pluginCenter.registerComponent( + 'miaoCodeMirror', + '代码编辑', + async () => (await import('@/views/miaoCodeMirror.vue')).default, + (vDirs, vFiles) => { + if (vDirs.length !== 0) { + return false + } + if (vFiles.length !== 1) { + return false + } + for (let end of ['js', 'ts', 'py', 'html', 'css']) { + if (vFiles[0].name.endsWith(end)) { + return true + } + } + return false + } + ) } diff --git a/src/hooks/useMiaoFetchApi.ts b/src/hooks/useMiaoFetchApi.ts index f1a5bd4..50e4a25 100644 --- a/src/hooks/useMiaoFetchApi.ts +++ b/src/hooks/useMiaoFetchApi.ts @@ -67,9 +67,29 @@ const miaoFetchApi = { return response.data }, + /** + * 获取对应文件夹下的数据 + */ + async getFile( + vFile: VirtualFile, + option?: getOption + ): Promise { + // const { baseUrl, api } = Config + const url = vFile.url + const retry = option?.retry ?? 0 + + const { miaoFetch } = useMiaoFetch({ + retry + }) + const response = await miaoFetch({ + url + }) + return response.data + }, + /** * 上传单个文件到对应文件夹, 后续要将data类型改成buffer以支持分片上传 - * 正常上传文件请使用uploadQueue + * 正常上传文件请使用uploadQueue */ upload(data: File, targetVDir: VirtualDirectory, option?: uploadOption) { const { baseUrl, api } = Config diff --git a/src/views/miaoCodeMirror.vue b/src/views/miaoCodeMirror.vue new file mode 100644 index 0000000..94b437b --- /dev/null +++ b/src/views/miaoCodeMirror.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/views/miaoPDF.vue b/src/views/miaoPDF.vue index 8c03d66..e592561 100644 --- a/src/views/miaoPDF.vue +++ b/src/views/miaoPDF.vue @@ -13,7 +13,7 @@ -
{{ loadingPercent === -1 ? '缓存中' : +
{{ loadingPercent === -1 ? '加载插件中' : `渲染进度:${canvasList.length}/${pdfPageCount}` }}
@@ -103,7 +103,7 @@ onMounted(async () => { .miao-container { width: 100%; height: 100%; - background-color: rgb(53, 53, 53); + background-color: rgb(201, 201, 201); overflow: hidden; display: flex; flex-direction: column; diff --git a/vite.config.ts b/vite.config.ts index f33024e..8db9e01 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,11 +1,15 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { resolve } from 'path' -import { viteSingleFile } from 'vite-plugin-singlefile' +// import { viteSingleFile } from 'vite-plugin-singlefile' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [vue(), viteSingleFile()], + base: './', + plugins: [ + vue() + // viteSingleFile() + ], resolve: { alias: { '@': resolve(__dirname, 'src') @@ -59,11 +63,18 @@ export default defineConfig({ }, output: { // 配置输出为单文件 - inlineDynamicImports: true, - manualChunks: undefined, - entryFileNames: 'bundle.js', - format: 'iife', // 立即执行函数格式 - name: 'MyBundle' + // inlineDynamicImports: true, + // manualChunks(id) { + // if (id.includes('node_modules')) { + // return 'vendor' + // } + // if (id.includes('@codemirror')) { + // return 'codemirror' + // } + // }, + // entryFileNames: 'bundle.js', + // format: 'iife', // 立即执行函数格式 + // name: 'MyBundle' } } } From ef5a8f1a9e698278d1c143e4936839ec15fa8a05 Mon Sep 17 00:00:00 2001 From: Zhoujiahui <539943419@qq.com> Date: Thu, 29 Aug 2024 15:19:36 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E4=B8=BA=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=8F=92=E4=BB=B6=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E7=9A=84=E8=AF=AD=E8=A8=80=E6=94=AF=E6=8C=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80=E4=BA=9Bbug?= =?UTF-8?q?=EF=BC=8C=E6=A0=B7=E5=BC=8F=E8=BF=98=E6=B2=A1=E5=86=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 9 +- pnpm-lock.yaml | 179 ++++++++++++++++++++++++++++++++++- src/class/PluginCenter.ts | 3 +- src/hooks/init.ts | 22 ++++- src/hooks/useMiaoFetchApi.ts | 3 +- src/types/fetch.ts | 6 +- src/views/miaoCodeMirror.vue | 71 ++++++++++++-- 7 files changed, 275 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index d34939f..fcf1342 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,17 @@ "preview": "vite preview" }, "dependencies": { - "@codemirror/lang-css": "^6.2.1", + "@codemirror/lang-go": "^6.0.1", "@codemirror/lang-html": "^6.4.9", "@codemirror/lang-javascript": "^6.2.2", + "@codemirror/lang-json": "^6.0.1", + "@codemirror/lang-markdown": "^6.2.5", "@codemirror/lang-python": "^6.1.6", + "@codemirror/lang-sass": "^6.0.2", + "@codemirror/lang-sql": "^6.7.1", + "@codemirror/lang-vue": "^0.1.3", + "@codemirror/lang-xml": "^6.1.0", + "@codemirror/lang-yaml": "^6.1.1", "@vicons/ionicons5": "^0.12.0", "axios": "^1.7.3", "codemirror": "^6.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fc6fa9c..dfdad0b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,18 +8,39 @@ importers: .: dependencies: - '@codemirror/lang-css': - specifier: ^6.2.1 - version: 6.2.1(@codemirror/view@6.33.0) + '@codemirror/lang-go': + specifier: ^6.0.1 + version: 6.0.1(@codemirror/view@6.33.0) '@codemirror/lang-html': specifier: ^6.4.9 version: 6.4.9 '@codemirror/lang-javascript': specifier: ^6.2.2 version: 6.2.2 + '@codemirror/lang-json': + specifier: ^6.0.1 + version: 6.0.1 + '@codemirror/lang-markdown': + specifier: ^6.2.5 + version: 6.2.5 '@codemirror/lang-python': specifier: ^6.1.6 version: 6.1.6(@codemirror/view@6.33.0) + '@codemirror/lang-sass': + specifier: ^6.0.2 + version: 6.0.2(@codemirror/view@6.33.0) + '@codemirror/lang-sql': + specifier: ^6.7.1 + version: 6.7.1(@codemirror/view@6.33.0) + '@codemirror/lang-vue': + specifier: ^0.1.3 + version: 0.1.3 + '@codemirror/lang-xml': + specifier: ^6.1.0 + version: 6.1.0 + '@codemirror/lang-yaml': + specifier: ^6.1.1 + version: 6.1.1(@codemirror/view@6.33.0) '@vicons/ionicons5': specifier: ^0.12.0 version: 0.12.0 @@ -116,15 +137,39 @@ packages: '@codemirror/lang-css@6.2.1': resolution: {integrity: sha512-/UNWDNV5Viwi/1lpr/dIXJNWiwDxpw13I4pTUAsNxZdg6E0mI2kTQb0P2iHczg1Tu+H4EBgJR+hYhKiHKko7qg==} + '@codemirror/lang-go@6.0.1': + resolution: {integrity: sha512-7fNvbyNylvqCphW9HD6WFnRpcDjr+KXX/FgqXy5H5ZS0eC5edDljukm/yNgYkwTsgp2busdod50AOTIy6Jikfg==} + '@codemirror/lang-html@6.4.9': resolution: {integrity: sha512-aQv37pIMSlueybId/2PVSP6NPnmurFDVmZwzc7jszd2KAF8qd4VBbvNYPXWQq90WIARjsdVkPbw29pszmHws3Q==} '@codemirror/lang-javascript@6.2.2': resolution: {integrity: sha512-VGQfY+FCc285AhWuwjYxQyUQcYurWlxdKYT4bqwr3Twnd5wP5WSeu52t4tvvuWmljT4EmgEgZCqSieokhtY8hg==} + '@codemirror/lang-json@6.0.1': + resolution: {integrity: sha512-+T1flHdgpqDDlJZ2Lkil/rLiRy684WMLc74xUnjJH48GQdfJo/pudlTRreZmKwzP8/tGdKf83wlbAdOCzlJOGQ==} + + '@codemirror/lang-markdown@6.2.5': + resolution: {integrity: sha512-Hgke565YcO4fd9pe2uLYxnMufHO5rQwRr+AAhFq8ABuhkrjyX8R5p5s+hZUTdV60O0dMRjxKhBLxz8pu/MkUVA==} + '@codemirror/lang-python@6.1.6': resolution: {integrity: sha512-ai+01WfZhWqM92UqjnvorkxosZ2aq2u28kHvr+N3gu012XqY2CThD67JPMHnGceRfXPDBmn1HnyqowdpF57bNg==} + '@codemirror/lang-sass@6.0.2': + resolution: {integrity: sha512-l/bdzIABvnTo1nzdY6U+kPAC51czYQcOErfzQ9zSm9D8GmNPD0WTW8st/CJwBTPLO8jlrbyvlSEcN20dc4iL0Q==} + + '@codemirror/lang-sql@6.7.1': + resolution: {integrity: sha512-flQa7zemrLKk0TIrOJnpeyH/b29BcVybtsTeZMgAo40O6kGbrnUSCgwI3TF5iJY3O9VXJKKCA+i0CBVvDfr88w==} + + '@codemirror/lang-vue@0.1.3': + resolution: {integrity: sha512-QSKdtYTDRhEHCfo5zOShzxCmqKJvgGrZwDQSdbvCRJ5pRLWBS7pD/8e/tH44aVQT6FKm0t6RVNoSUWHOI5vNug==} + + '@codemirror/lang-xml@6.1.0': + resolution: {integrity: sha512-3z0blhicHLfwi2UgkZYRPioSgVTo9PV5GP5ducFH6FaHy0IAJRg+ixj5gTR1gnT/glAIC8xv4w2VL1LoZfs+Jg==} + + '@codemirror/lang-yaml@6.1.1': + resolution: {integrity: sha512-HV2NzbK9bbVnjWxwObuZh5FuPCowx51mEfoFT9y3y+M37fA3+pbxx4I7uePuygFzDsAmCTwQSc/kXh/flab4uw==} + '@codemirror/language@6.10.2': resolution: {integrity: sha512-kgbTYTo0Au6dCSc/TFy7fK3fpJmgHDv1sG1KNQKJXVi+xBTEeBPY/M30YXiU6mMXeH+YIDLsbrT4ZwNRdtF+SA==} @@ -303,6 +348,9 @@ packages: '@lezer/css@1.1.8': resolution: {integrity: sha512-7JhxupKuMBaWQKjQoLtzhGj83DdnZY9MckEOG5+/iLKNK2ZJqKc6hf6uc0HjwCX7Qlok44jBNqZhHKDhEhZYLA==} + '@lezer/go@1.0.0': + resolution: {integrity: sha512-co9JfT3QqX1YkrMmourYw2Z8meGC50Ko4d54QEcQbEYpvdUvN4yb0NBZdn/9ertgvjsySxHsKzH3lbm3vqJ4Jw==} + '@lezer/highlight@1.2.1': resolution: {integrity: sha512-Z5duk4RN/3zuVO7Jq0pGLJ3qynpxUVsh7IbUbGj88+uV2ApSAn6kWg2au3iJb+0Zi7kKtqffIESgNcRXWZWmSA==} @@ -312,12 +360,27 @@ packages: '@lezer/javascript@1.4.17': resolution: {integrity: sha512-bYW4ctpyGK+JMumDApeUzuIezX01H76R1foD6LcRX224FWfyYit/HYxiPGDjXXe/wQWASjCvVGoukTH68+0HIA==} + '@lezer/json@1.0.2': + resolution: {integrity: sha512-xHT2P4S5eeCYECyKNPhr4cbEL9tc8w83SPwRC373o9uEdrvGKTZoJVAGxpOsZckMlEh9W23Pc72ew918RWQOBQ==} + '@lezer/lr@1.4.2': resolution: {integrity: sha512-pu0K1jCIdnQ12aWNaAVU5bzi7Bd1w54J3ECgANPmYLtQKP0HBj2cE/5coBD66MT10xbtIuUr7tg0Shbsvk0mDA==} + '@lezer/markdown@1.3.0': + resolution: {integrity: sha512-ErbEQ15eowmJUyT095e9NJc3BI9yZ894fjSDtHftD0InkfUBGgnKSU6dvan9jqsZuNHg2+ag/1oyDRxNsENupQ==} + '@lezer/python@1.1.14': resolution: {integrity: sha512-ykDOb2Ti24n76PJsSa4ZoDF0zH12BSw1LGfQXCYJhJyOGiFTfGaX0Du66Ze72R+u/P35U+O6I9m8TFXov1JzsA==} + '@lezer/sass@1.0.6': + resolution: {integrity: sha512-w/RCO2dIzZH1To8p+xjs8cE+yfgGus8NZ/dXeWl/QzHyr+TeBs71qiE70KPImEwvTsmEjoWh0A5SxMzKd5BWBQ==} + + '@lezer/xml@1.0.5': + resolution: {integrity: sha512-VFouqOzmUWfIg+tfmpcdV33ewtK+NSwd4ngSe1aG7HFb4BN0ExyY1b8msp+ndFrnlG4V4iC8yXacjFtrwERnaw==} + + '@lezer/yaml@1.0.3': + resolution: {integrity: sha512-GuBLekbw9jDBDhGur82nuwkxKQ+a3W5H0GfaAthDXcAu+XdpS43VlnxA9E9hllkpSP5ellRDKjLLj7Lu9Wr6xA==} + '@mapbox/node-pre-gyp@1.0.11': resolution: {integrity: sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==} hasBin: true @@ -1147,6 +1210,16 @@ snapshots: transitivePeerDependencies: - '@codemirror/view' + '@codemirror/lang-go@6.0.1(@codemirror/view@6.33.0)': + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@lezer/common': 1.2.1 + '@lezer/go': 1.0.0 + transitivePeerDependencies: + - '@codemirror/view' + '@codemirror/lang-html@6.4.9': dependencies: '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) @@ -1169,6 +1242,21 @@ snapshots: '@lezer/common': 1.2.1 '@lezer/javascript': 1.4.17 + '@codemirror/lang-json@6.0.1': + dependencies: + '@codemirror/language': 6.10.2 + '@lezer/json': 1.0.2 + + '@codemirror/lang-markdown@6.2.5': + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/lang-html': 6.4.9 + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + '@lezer/common': 1.2.1 + '@lezer/markdown': 1.3.0 + '@codemirror/lang-python@6.1.6(@codemirror/view@6.33.0)': dependencies: '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) @@ -1179,6 +1267,56 @@ snapshots: transitivePeerDependencies: - '@codemirror/view' + '@codemirror/lang-sass@6.0.2(@codemirror/view@6.33.0)': + dependencies: + '@codemirror/lang-css': 6.2.1(@codemirror/view@6.33.0) + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@lezer/common': 1.2.1 + '@lezer/sass': 1.0.6 + transitivePeerDependencies: + - '@codemirror/view' + + '@codemirror/lang-sql@6.7.1(@codemirror/view@6.33.0)': + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + transitivePeerDependencies: + - '@codemirror/view' + + '@codemirror/lang-vue@0.1.3': + dependencies: + '@codemirror/lang-html': 6.4.9 + '@codemirror/lang-javascript': 6.2.2 + '@codemirror/language': 6.10.2 + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + + '@codemirror/lang-xml@6.1.0': + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@codemirror/view': 6.33.0 + '@lezer/common': 1.2.1 + '@lezer/xml': 1.0.5 + + '@codemirror/lang-yaml@6.1.1(@codemirror/view@6.33.0)': + dependencies: + '@codemirror/autocomplete': 6.18.0(@codemirror/language@6.10.2)(@codemirror/state@6.4.1)(@codemirror/view@6.33.0)(@lezer/common@1.2.1) + '@codemirror/language': 6.10.2 + '@codemirror/state': 6.4.1 + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/yaml': 1.0.3 + transitivePeerDependencies: + - '@codemirror/view' + '@codemirror/language@6.10.2': dependencies: '@codemirror/state': 6.4.1 @@ -1299,6 +1437,12 @@ snapshots: '@lezer/highlight': 1.2.1 '@lezer/lr': 1.4.2 + '@lezer/go@1.0.0': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + '@lezer/highlight@1.2.1': dependencies: '@lezer/common': 1.2.1 @@ -1315,16 +1459,45 @@ snapshots: '@lezer/highlight': 1.2.1 '@lezer/lr': 1.4.2 + '@lezer/json@1.0.2': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + '@lezer/lr@1.4.2': dependencies: '@lezer/common': 1.2.1 + '@lezer/markdown@1.3.0': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/python@1.1.14': dependencies: '@lezer/common': 1.2.1 '@lezer/highlight': 1.2.1 '@lezer/lr': 1.4.2 + '@lezer/sass@1.0.6': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + + '@lezer/xml@1.0.5': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + + '@lezer/yaml@1.0.3': + dependencies: + '@lezer/common': 1.2.1 + '@lezer/highlight': 1.2.1 + '@lezer/lr': 1.4.2 + '@mapbox/node-pre-gyp@1.0.11': dependencies: detect-libc: 2.0.3 diff --git a/src/class/PluginCenter.ts b/src/class/PluginCenter.ts index 985d84e..f5f1505 100644 --- a/src/class/PluginCenter.ts +++ b/src/class/PluginCenter.ts @@ -20,7 +20,6 @@ export default class PluginCenter { register(key: string, plugin: plugin) { this.pluginsMap[key] = plugin - console.log(this.pluginsMap) } /** @@ -29,7 +28,7 @@ export default class PluginCenter { registerComponent( key: string, name: string, - getComponent: () => any, + getComponent: () => Promise, filter: ( VDirectorys: VirtualDirectory[], VFiles: VirtualFile[] diff --git a/src/hooks/init.ts b/src/hooks/init.ts index 859bd3d..ac28ef5 100644 --- a/src/hooks/init.ts +++ b/src/hooks/init.ts @@ -1,4 +1,4 @@ -// import MiaoDirectory from '@/views/miaoDirectory.vue' +import MiaoDirectory from '@/views/miaoDirectory.vue' import usePluginCenter from './usePluginCenter' export default function init() { @@ -6,7 +6,7 @@ export default function init() { pluginCenter.registerComponent( 'miaoDirectory', '文件夹', - async() => (await import('@/views/miaoDirectory.vue')).default, + async () => MiaoDirectory, (vDirs, vFiles) => { if (vFiles.length) { return false @@ -74,7 +74,23 @@ export default function init() { if (vFiles.length !== 1) { return false } - for (let end of ['js', 'ts', 'py', 'html', 'css']) { + 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 } diff --git a/src/hooks/useMiaoFetchApi.ts b/src/hooks/useMiaoFetchApi.ts index 50e4a25..e336d22 100644 --- a/src/hooks/useMiaoFetchApi.ts +++ b/src/hooks/useMiaoFetchApi.ts @@ -77,12 +77,13 @@ const miaoFetchApi = { // const { baseUrl, api } = Config const url = vFile.url const retry = option?.retry ?? 0 + const axiosOption = option?.axiosOption ?? {} const { miaoFetch } = useMiaoFetch({ retry }) const response = await miaoFetch({ - url + url, ...axiosOption }) return response.data }, diff --git a/src/types/fetch.ts b/src/types/fetch.ts index 9fc1508..cfea9e2 100644 --- a/src/types/fetch.ts +++ b/src/types/fetch.ts @@ -1,8 +1,10 @@ +import { AxiosRequestConfig } from "axios"; import { directory, file } from "./type"; export type miaoFetchConfig = { - retry?: number; -}; + retry?: number + axiosOption?: AxiosRequestConfig +} export type getOption = {} & miaoFetchConfig; diff --git a/src/views/miaoCodeMirror.vue b/src/views/miaoCodeMirror.vue index 94b437b..89dd5f6 100644 --- a/src/views/miaoCodeMirror.vue +++ b/src/views/miaoCodeMirror.vue @@ -1,5 +1,6 @@