feat: 1.现在miaoFetchApi.getFile始终返回Promise<uint8array>. 2.增加文件加/解密插件,样式还没写,加密功能是挺正常的。3.加了个插件模板
This commit is contained in:
1 parent
282bf327bb
commit
3a18bb3cbd
12 files changed
+313
-16
No files matched your search
@@ -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<any>) => {
|
||||
miaoFetch: async (
|
||||
config: AxiosRequestConfig<any>
|
||||
): Promise<AxiosResponse<any, any>> => {
|
||||
let counter = 0
|
||||
let response: any
|
||||
let errList = []
|
||||
@@ -68,12 +70,12 @@ const miaoFetchApi = {
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取对应文件夹下的数据
|
||||
* 获取对应文件下的数据
|
||||
*/
|
||||
async getFile(
|
||||
vFile: VirtualFile,
|
||||
option?: getOption
|
||||
): Promise<getResponse> {
|
||||
) {
|
||||
// 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)
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user