123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- // types/global.d.ts
- import { AxiosRequestConfig, AxiosResponse } from "axios";
- import { VueConstructor } from "vue";
- import { ElMessageBox, ElMessage, ElNotification, ElLoading } from "element-ui";
- // 声明全局类型
- declare global {
- // Vue 实例类型扩展
- interface Vue {
- $message: typeof ElMessage;
- $msgbox: typeof ElMessageBox;
- $alert: typeof ElMessageBox.alert;
- $confirm: typeof ElMessageBox.confirm;
- $prompt: typeof ElMessageBox.prompt;
- $notify: typeof ElNotification;
- $loading: typeof ElLoading.service;
- $refs: {
- [key: string]: Vue | Element | Vue[] | Element[] | {
- validate?: () => Promise<boolean>;
- resetFields?: () => void;
- clearValidate?: () => void;
- [key: string]: any;
- };
- };
- $set: (target: any, key: string | number, value: any) => any;
- $delete: (target: any, key: string | number) => void;
- $nextTick(
- callback?: (this: this) => any
- ): Promise<void> | void;
- $emit: (event: string, ...args: any[]) => void;
- $on: (event: string, callback: Function) => void;
- $off: (event?: string, callback?: Function) => void;
- $once: (event: string, callback: Function) => void;
- }
- // 导出Axios类型供全局使用
- type AxiosResponse<T = any> = import('axios').AxiosResponse<T>;
- type AxiosRequestConfig = import('axios').AxiosRequestConfig;
- // 通用API响应类型
- interface ApiResponse<T = any> {
- code: number;
- message: string;
- msg?: string;
- data: T;
- success?: boolean;
- timestamp?: number;
- }
- // 分页数据类型
- interface PageResult<T = any> {
- records: T[];
- total: number;
- size: number;
- current: number;
- pages: number;
- orders?: any[];
- optimizeCountSql?: boolean;
- hitCount?: boolean;
- countId?: string | null;
- maxLimit?: number | null;
- searchCount?: boolean;
- }
- // 基础查询参数
- interface BaseQueryParams {
- current?: number;
- size?: number;
- [key: string]: any;
- }
- // 基础实体类型
- interface BaseEntity {
- /** 创建用户ID */
- createUser?: string;
- /** 创建部门ID */
- createDept?: string;
- /** 创建时间 */
- createTime?: string;
- /** 更新用户ID */
- updateUser?: string;
- /** 更新时间 */
- updateTime?: string;
- /** 状态 */
- status?: number;
- /** 是否删除 0-未删除 1-已删除 */
- isDeleted?: number;
- }
- // 下拉选择器选项
- interface SelectOption<T = any> {
- label: string;
- value: T;
- disabled?: boolean;
- description?: string;
- }
- // 表单验证规则
- interface ValidationRule {
- required?: boolean;
- message?: string;
- trigger?: 'blur' | 'change' | 'submit';
- min?: number;
- max?: number;
- type?: 'string' | 'number' | 'boolean' | 'method' | 'regexp' | 'integer' | 'float' | 'array' | 'object' | 'enum' | 'date' | 'url' | 'hex' | 'email';
- minimum?: number;
- maximum?: number;
- pattern?: RegExp;
- validator?: (rule: ValidationRule, value: any, callback: (error?: Error) => void) => void;
- }
- // Avue 相关类型
- interface AvueFormColumn {
- prop: string;
- label: string;
- type?: string;
- dicData?: Array<SelectOption>;
- rules?: ValidationRule[];
- span?: number;
- disabled?: boolean;
- display?: boolean;
- [key: string]: any;
- }
- interface AvueFormOption {
- column: AvueFormColumn[];
- labelWidth?: number;
- gutter?: number;
- menuBtn?: boolean;
- submitBtn?: boolean;
- emptyBtn?: boolean;
- [key: string]: any;
- }
- interface AvueCrudColumn extends AvueFormColumn {
- width?: number;
- minWidth?: number;
- fixed?: boolean | 'left' | 'right';
- sortable?: boolean;
- search?: boolean;
- hide?: boolean;
- [key: string]: any;
- }
- interface AvueCrudOption {
- column: AvueCrudColumn[];
- border?: boolean;
- stripe?: boolean;
- menuAlign?: 'left' | 'center' | 'right';
- align?: 'left' | 'center' | 'right';
- addBtn?: boolean;
- editBtn?: boolean;
- delBtn?: boolean;
- viewBtn?: boolean;
- searchBtn?: boolean;
- refreshBtn?: boolean;
- columnBtn?: boolean;
- page?: boolean;
- [key: string]: any;
- }
- // 用户信息类型
- interface UserInfo {
- /** 访问令牌 */
- access_token?: string;
- /** 令牌类型 */
- token_type?: string;
- /** 刷新令牌 */
- refresh_token?: string;
- /** 过期时间(秒) */
- expires_in?: number;
- /** 权限范围 */
- scope?: string;
- /** 租户ID */
- tenant_id?: string;
- /** 用户名 */
- user_name?: string;
- /** 部门父级ID */
- dept_pid?: string;
- /** 真实姓名 */
- real_name?: string;
- /** 头像 */
- avatar?: string;
- /** 公司名称 */
- corp_name?: string;
- /** 客户端ID */
- client_id?: string;
- /** 角色名称 */
- role_name?: string;
- /** 许可证信息 */
- license?: string;
- /** 岗位ID(多个用逗号分隔) */
- post_id?: string;
- /** 用户ID */
- user_id?: string;
- /** 角色ID */
- role_id?: string;
- /** 昵称 */
- nick_name?: string;
- /** 公司地址 */
- corp_address?: string;
- /** OAuth ID */
- oauth_id?: string;
- /** 详细信息 */
- detail?: {
- /** 类型 */
- type?: string;
- [key: string]: any;
- };
- /** 部门ID */
- dept_id?: string;
- /** 公司ID */
- corp_id?: string | null;
- /** 账户名 */
- account?: string;
- /** JWT ID */
- jti?: string;
- }
- }
- export {};
|