提交 b34fdbe6 编写于 作者: Q qiang

fix(h5): filePath

上级 6047d964
import { getRealPath } from '@dcloudio/uni-platform'
export const API_GET_FILE_INFO = 'getFileInfo'
export type API_TYPE_GET_FILE_INFO = typeof uni.getFileInfo
export const GetFileInfoOptions: ApiOptions<API_TYPE_GET_FILE_INFO> = {
formatArgs: {
filePath(filePath, params) {
params.filePath = getRealPath(filePath)
},
},
}
export const GetFileInfoProtocol: ApiProtocol<API_TYPE_GET_FILE_INFO> = {
filePath: {
type: String,
......
import { getRealPath } from '@dcloudio/uni-platform'
export const API_OPEN_DOCUMENT = 'openDocument'
export type API_TYPE_OPEN_DOCUMENT = typeof uni.openDocument
export const OpenDocumentOptions: ApiOptions<API_TYPE_OPEN_DOCUMENT> = {
formatArgs: {
filePath(filePath, params) {
params.filePath = getRealPath(filePath)
},
},
}
export const OpenDocumentProtocol: ApiProtocol<API_TYPE_OPEN_DOCUMENT> = {
filePath: {
type: String,
......
import { getRealPath } from '@dcloudio/uni-platform'
export const API_UPLOAD_FILE = 'uploadFile'
export type API_TYPE_UPLOAD_FILE = typeof uni.uploadFile
export const UploadFileOptions: ApiOptions<API_TYPE_UPLOAD_FILE> = {
formatArgs: {
filePath(filePath, params) {
if (filePath) {
params.filePath = getRealPath(filePath)
}
},
header(value: Record<string, any>, params: Record<string, any>) {
params.header = value || {}
},
......
......@@ -4550,6 +4550,13 @@ const API_REMOVE_STORAGE = "removeStorage";
const RemoveStorageProtocol = GetStorageProtocol;
const RemoveStorageSyncProtocol = GetStorageSyncProtocol;
const API_GET_FILE_INFO = "getFileInfo";
const GetFileInfoOptions = {
formatArgs: {
filePath(filePath, params) {
params.filePath = getRealPath(filePath);
}
}
};
const GetFileInfoProtocol = {
filePath: {
type: String,
......@@ -4557,6 +4564,13 @@ const GetFileInfoProtocol = {
}
};
const API_OPEN_DOCUMENT = "openDocument";
const OpenDocumentOptions = {
formatArgs: {
filePath(filePath, params) {
params.filePath = getRealPath(filePath);
}
}
};
const OpenDocumentProtocol = {
filePath: {
type: String,
......@@ -4797,6 +4811,11 @@ const DownloadFileProtocol = {
const API_UPLOAD_FILE = "uploadFile";
const UploadFileOptions = {
formatArgs: {
filePath(filePath, params) {
if (filePath) {
params.filePath = getRealPath(filePath);
}
},
header(value, params) {
params.header = value || {};
},
......@@ -11078,11 +11097,11 @@ const getFileInfo = defineAsyncApi(API_GET_FILE_INFO, ({filePath}, {resolve, rej
}).catch((err) => {
reject(String(err));
});
}, GetFileInfoProtocol);
}, GetFileInfoProtocol, GetFileInfoOptions);
const openDocument = defineAsyncApi(API_OPEN_DOCUMENT, ({filePath}, {resolve}) => {
window.open(filePath);
return resolve();
}, OpenDocumentProtocol);
}, OpenDocumentProtocol, OpenDocumentOptions);
function getServiceAddress() {
return window.location.protocol + "//" + window.location.host;
}
......
......@@ -3,6 +3,7 @@ import {
API_GET_FILE_INFO,
API_TYPE_GET_FILE_INFO,
GetFileInfoProtocol,
GetFileInfoOptions,
} from '@dcloudio/uni-api'
import { urlToFile } from '../../../helpers/file'
......@@ -20,5 +21,6 @@ export const getFileInfo = defineAsyncApi<API_TYPE_GET_FILE_INFO>(
reject(String(err))
})
},
GetFileInfoProtocol
GetFileInfoProtocol,
GetFileInfoOptions
)
......@@ -3,6 +3,7 @@ import {
API_TYPE_OPEN_DOCUMENT,
defineAsyncApi,
OpenDocumentProtocol,
OpenDocumentOptions,
} from '@dcloudio/uni-api'
export const openDocument = defineAsyncApi<API_TYPE_OPEN_DOCUMENT>(
......@@ -11,5 +12,6 @@ export const openDocument = defineAsyncApi<API_TYPE_OPEN_DOCUMENT>(
window.open(filePath)
return resolve()
},
OpenDocumentProtocol
OpenDocumentProtocol,
OpenDocumentOptions
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册