///
import 'vue';
// ---- globalData 类型定义 ----
interface AppRequestTool {
request: (method: string, url: string, data?: any, options?: any) => Promise;
get: (url: string, params?: any, options?: any) => Promise;
post: (url: string, data?: any, options?: any) => Promise;
put: (url: string, data?: any, options?: any) => Promise;
del: (url: string, params?: any, options?: any) => Promise;
}
interface AppWebviewTool {
getUrl: () => string;
setUrl: (url: string) => string;
}
interface AppTool {
Request: AppRequestTool;
Api: Record;
Env: {
API_BASE_URL: string;
WEBVIEW_BASE_URL: string;
REQUEST_TIMEOUT: number;
APP_NAME: string;
APP_SUBTITLE: string;
PROJECT_CODE: string;
SECURITY_ENABLE: boolean;
SECURITY_SECRET_KEY: string;
};
Webview: AppWebviewTool;
}
interface UserInfo {
[key: string]: any;
}
interface UserStorage {
getUserInfo: () => UserInfo | null;
setUserInfo: (userInfo: UserInfo) => UserInfo | null;
clearUserInfo: () => void;
getUserField: (field: string) => any;
setUserField: (field: string, value: any) => any;
removeUserField: (field: string) => void;
}
interface AppGlobalData {
Tool: AppTool;
ENV: {
API_BASE_URL: string;
WEBVIEW_BASE_URL: string;
REQUEST_TIMEOUT: number;
APP_NAME: string;
APP_SUBTITLE: string;
PROJECT_CODE: string;
SECURITY_ENABLE: boolean;
SECURITY_SECRET_KEY: string;
};
UserStorage: UserStorage;
appConfigReady: Promise;
[key: string]: any;
}
interface AppInstance {
Tool: AppTool;
globalData: AppGlobalData;
}
// 扩展 getApp() 返回类型
declare function getApp(): AppInstance;
// ---- Vue 组件选项扩展 ----
declare module '@vue/runtime-core' {
type Hooks = App.AppInstance & Page.PageInstance;
interface ComponentCustomOptions extends Hooks {}
}