diff --git a/README.md b/README.md index e46d872..7994f83 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ | 完善PDF插件 | ✅ | | 完善Code插件 | ✅ | | 实现miaoDirectory的搜索功能 | ✅ | +| 重构miaoFetchApi.getFile, 增加进度 | ❌ | | plugin增加些属性,icon, disable, group之类的 | ❌ | | 完善miaoDirectory的搜索功能 | ❌ | | 实现miaoDirectory的排序功能 | ❌ | diff --git a/package.json b/package.json index 531242e..773f364 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@codemirror/lang-xml": "^6.1.0", "@codemirror/lang-yaml": "^6.1.1", "@vicons/ionicons5": "^0.12.0", + "aes-js": "^3.1.2", "axios": "^1.7.3", "codemirror": "^6.0.1", "lodash": "^4.17.21", @@ -37,6 +38,7 @@ "xgplayer-subtitles": "^3.0.20" }, "devDependencies": { + "@types/aes-js": "^3.1.4", "@types/lodash": "^4.17.7", "@types/markdown-it": "^14.1.2", "@types/node": "^22.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 599b3dd..3c8726e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: '@vicons/ionicons5': specifier: ^0.12.0 version: 0.12.0 + aes-js: + specifier: ^3.1.2 + version: 3.1.2 axios: specifier: ^1.7.3 version: 1.7.3 @@ -78,6 +81,9 @@ importers: specifier: ^3.0.20 version: 3.0.20(core-js@3.38.1) devDependencies: + '@types/aes-js': + specifier: ^3.1.4 + version: 3.1.4 '@types/lodash': specifier: ^4.17.7 version: 4.17.7 @@ -480,6 +486,9 @@ packages: cpu: [x64] os: [win32] + '@types/aes-js@3.1.4': + resolution: {integrity: sha512-v3D66IptpUqh+pHKVNRxY8yvp2ESSZXe0rTzsGdzUhEwag7ljVfgCllkWv2YgiYXDhWFBrEywll4A5JToyTNFA==} + '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} @@ -579,6 +588,9 @@ packages: abbrev@1.1.1: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} + aes-js@3.1.2: + resolution: {integrity: sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==} + agent-base@6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} @@ -1614,6 +1626,8 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.20.0': optional: true + '@types/aes-js@3.1.4': {} + '@types/estree@1.0.5': {} '@types/katex@0.16.7': {} @@ -1753,6 +1767,8 @@ snapshots: abbrev@1.1.1: optional: true + aes-js@3.1.2: {} + agent-base@6.0.2: dependencies: debug: 4.3.6 diff --git a/src/hooks/useMiaoFetchApi.ts b/src/hooks/useMiaoFetchApi.ts index e336d22..016019e 100644 --- a/src/hooks/useMiaoFetchApi.ts +++ b/src/hooks/useMiaoFetchApi.ts @@ -11,14 +11,16 @@ import { mkdirOption } from '@/types/fetch' import Config from '@/config' -import axios, { AxiosRequestConfig } from 'axios' +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios' export const useMiaoFetch = (option?: miaoFetchConfig) => { const retry = option?.retry ?? 0 const controller = new AbortController() let flag = true return { - miaoFetch: async (config: AxiosRequestConfig) => { + miaoFetch: async ( + config: AxiosRequestConfig + ): Promise> => { let counter = 0 let response: any let errList = [] @@ -68,12 +70,12 @@ const miaoFetchApi = { }, /** - * 获取对应文件夹下的数据 + * 获取对应文件下的数据 */ async getFile( vFile: VirtualFile, option?: getOption - ): Promise { + ) { // const { baseUrl, api } = Config const url = vFile.url const retry = option?.retry ?? 0 @@ -83,9 +85,11 @@ const miaoFetchApi = { retry }) const response = await miaoFetch({ - url, ...axiosOption + url, + responseType: 'arraybuffer', + ...axiosOption }) - return response.data + return new Uint8Array(response.data) }, /** diff --git a/src/plugins/miaoCodeMirror/miaoCodeMirror.vue b/src/plugins/miaoCodeMirror/miaoCodeMirror.vue index 60f9325..92b3bdb 100644 --- a/src/plugins/miaoCodeMirror/miaoCodeMirror.vue +++ b/src/plugins/miaoCodeMirror/miaoCodeMirror.vue @@ -1,12 +1,23 @@