// Import the core alova instance import { BASE_URL } from "@/config"; import alovaInstance from "./core/instance"; // Export the global Apis object from the generated code import { createApis, withConfigType } from "./createApis"; // Export the alova instance for direct use if needed export { alovaInstance }; // Configure method options for specific APIs export const $$userConfigMap = withConfigType({}); // Create the global Apis object const Apis = createApis(alovaInstance, $$userConfigMap); // Export both default and named export for AutoImport export default Apis; export { Apis }; type Data = { code: number; message: string; result: T; }; export function uploadFile(options: UniApp.UploadFileOption) { uni.showLoading({ title: "上传中...", mask: true }); return new Promise>((resolve, reject) => { uni.uploadFile({ url: BASE_URL + options.url, filePath: options.filePath, name: "file", method: "POST", header: { "Content-Type": "multipart/form-data", "X-Access-Token": useUserStore().token, }, success(res) { uni.hideLoading(); resolve(JSON.parse(res.data)); }, fail(err) { uni.hideLoading(); reject(err); uni.showToast({ title: err.errMsg, icon: "none" }); }, }); }); }