From 3267f596030260a4fe0f3ff6be8fca93c9cc2466 Mon Sep 17 00:00:00 2001
From: LiuHao <liuhaoai545@gmail.com>
Date: 星期二, 06 六月 2023 20:54:52 +0800
Subject: [PATCH] add vue全局声明、Ele全局实例、类型声明

---
 src/types/element.d.ts |   33 ++++++++++++++++++++++++++++++++-
 src/types/global.d.ts  |   26 ++++++++++++++++----------
 2 files changed, 48 insertions(+), 11 deletions(-)

diff --git a/src/types/element.d.ts b/src/types/element.d.ts
index 8632484..fdc6578 100644
--- a/src/types/element.d.ts
+++ b/src/types/element.d.ts
@@ -1 +1,32 @@
-declare type ElTagType = '' | 'success' | 'warning' | 'info' | 'danger' | 'default' | 'primary';
+import type * as ep from 'element-plus';
+declare global {
+  declare type ElTagType = '' | 'success' | 'warning' | 'info' | 'danger' | 'default' | 'primary';
+  declare type ElFormInstance = InstanceType<typeof ep.ElForm>;
+  declare type ElTableInstance = InstanceType<typeof ep.ElTable>;
+  declare type ElTreeInstance = InstanceType<typeof ep.ElTree>;
+  declare type ElTreeSelectInstance = InstanceType<typeof ep.ElTreeSelect>;
+  declare type ElSelectInstance = InstanceType<typeof ep.ElSelect>;
+  declare type ElUploadInstance = InstanceType<typeof ep.ElUpload>;
+  declare type ElCardInstance = InstanceType<typeof ep.ElCard>;
+  declare type ElDialogInstance = InstanceType<typeof ep.ElDialog>;
+  declare type ElInputInstance = InstanceType<typeof ep.ElInput>;
+  declare type ElInputNumberInstance = InstanceType<typeof ep.ElInputNumber>;
+  declare type ElRadioInstance = InstanceType<typeof ep.ElRadio>;
+  declare type ElRadioGroupInstance = InstanceType<typeof ep.ElRadioGroup>;
+  declare type ElRadioButtonInstance = InstanceType<typeof ep.ElRadioButton>;
+  declare type ElCheckboxInstance = InstanceType<typeof ep.ElCheckbox>;
+  declare type ElCheckboxGroupInstance = InstanceType<typeof ep.ElCheckboxGroup>;
+  declare type ElSwitchInstance = InstanceType<typeof ep.ElSwitch>;
+  declare type ElDatePickerInstance = InstanceType<typeof ep.ElDatePicker>;
+  declare type ElTimePickerInstance = InstanceType<typeof ep.ElTimePicker>;
+  declare type ElTimeSelectInstance = InstanceType<typeof ep.ElTimeSelect>;
+  declare type ElCascaderInstance = InstanceType<typeof ep.ElCascader>;
+  declare type ElColorPickerInstance = InstanceType<typeof ep.ElColorPicker>;
+  declare type ElRateInstance = InstanceType<typeof ep.ElRate>;
+  declare type ElSliderInstance = InstanceType<typeof ep.ElSlider>;
+  declare type ElUploadInstance = InstanceType<typeof ep.ElUpload>;
+
+  declare type ElFormRules = ep.FormRules;
+  declare type DateModelType = ep.DateModelType;
+  declare type UploadFile = typeof ep.UploadFile;
+}
diff --git a/src/types/global.d.ts b/src/types/global.d.ts
index 5a972a3..b9bc5f4 100644
--- a/src/types/global.d.ts
+++ b/src/types/global.d.ts
@@ -1,9 +1,15 @@
-import { FormRules } from 'element-plus';
+import type { ComponentInternalInstance as ComponentInstance, PropType as VuePropType } from 'vue';
+
 declare global {
+  /** vue Instance */
+  declare type ComponentInternalInstance = ComponentInstance;
+  /**vue */
+  declare type PropType<T> = VuePropType<T>;
+
   /**
    * 鐣岄潰瀛楁闅愯棌灞炴��
    */
-  interface FieldOption {
+  declare interface FieldOption {
     key: number;
     label: string;
     visible: boolean;
@@ -12,7 +18,7 @@
   /**
    * 寮圭獥灞炴��
    */
-  interface DialogOption {
+  declare interface DialogOption {
     /**
      * 寮圭獥鏍囬
      */
@@ -23,7 +29,7 @@
     visible: boolean;
   }
 
-  interface UploadOption {
+  declare interface UploadOption {
     /** 璁剧疆涓婁紶鐨勮姹傚ご閮� */
     headers: { [key: string]: any };
 
@@ -34,7 +40,7 @@
   /**
    * 瀵煎叆灞炴��
    */
-  interface ImportOption extends UploadOption {
+  declare interface ImportOption extends UploadOption {
     /** 鏄惁鏄剧ず寮瑰嚭灞� */
     open: boolean;
     /** 寮瑰嚭灞傛爣棰� */
@@ -48,14 +54,14 @@
   /**
    * 瀛楀吀鏁版嵁  鏁版嵁閰嶇疆
    */
-  interface DictDataOption {
+  declare interface DictDataOption {
     label: string;
     value: string;
     elTagType?: ElTagType;
     elTagClass?: string;
   }
 
-  interface BaseEntity {
+  declare interface BaseEntity {
     createBy?: any;
     createDept?: any;
     createTime?: string;
@@ -68,15 +74,15 @@
    * T : 琛ㄥ崟鏁版嵁
    * D : 鏌ヨ鍙傛暟
    */
-  interface PageData<T, D> {
+  declare interface PageData<T, D> {
     form: T;
     queryParams: D;
-    rules: FormRules;
+    rules: ElFormRules;
   }
   /**
    * 鍒嗛〉鏌ヨ鍙傛暟
    */
-  interface PageQuery {
+  declare interface PageQuery {
     pageNum: number;
     pageSize: number;
   }

--
Gitblit v1.9.3