From 577b2d3977b3e61e67095cff512e3ad720315d15 Mon Sep 17 00:00:00 2001 From: warmthsea <2586244885@qq.com> Date: Wed, 29 May 2024 10:03:03 +0800 Subject: [PATCH] types: complete dirctives and v-auth custom color --- .vscode/extensions.json | 1 + .vscode/settings.json | 4 +++- src/directives/auth/index.ts | 2 +- src/directives/copy/index.ts | 4 ++-- src/directives/longpress/index.ts | 2 +- types/directives.d.ts | 13 +++++++++++++ 6 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 types/directives.d.ts diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 99f21c9ab..a793646e6 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,7 @@ { "recommendations": [ "christian-kohler.path-intellisense", + "warmthsea.vscode-custom-code-color", "vscode-icons-team.vscode-icons", "davidanson.vscode-markdownlint", "ms-azuretools.vscode-docker", diff --git a/.vscode/settings.json b/.vscode/settings.json index 9752f8985..a8e0ca819 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -43,5 +43,7 @@ "port": 1883, "clientId": "vsmqtt_client_db34" } - ] + ], + "vscodeCustomCodeColor.highlightValue": "v-auth", + "vscodeCustomCodeColor.highlightValueColor": "#6366f1", } diff --git a/src/directives/auth/index.ts b/src/directives/auth/index.ts index a7a4f2216..2fc649047 100644 --- a/src/directives/auth/index.ts +++ b/src/directives/auth/index.ts @@ -2,7 +2,7 @@ import { hasAuth } from "@/router/utils"; import type { Directive, DirectiveBinding } from "vue"; export const auth: Directive = { - mounted(el: HTMLElement, binding: DirectiveBinding) { + mounted(el: HTMLElement, binding: DirectiveBinding>) { const { value } = binding; if (value) { !hasAuth(value) && el.parentNode?.removeChild(el); diff --git a/src/directives/copy/index.ts b/src/directives/copy/index.ts index 8e9783381..b71fa1901 100644 --- a/src/directives/copy/index.ts +++ b/src/directives/copy/index.ts @@ -3,13 +3,13 @@ import { useEventListener } from "@vueuse/core"; import { copyTextToClipboard } from "@pureadmin/utils"; import type { Directive, DirectiveBinding } from "vue"; -interface CopyEl extends HTMLElement { +export interface CopyEl extends HTMLElement { copyValue: string; } /** 文本复制指令(默认双击复制) */ export const copy: Directive = { - mounted(el: CopyEl, binding: DirectiveBinding) { + mounted(el: CopyEl, binding: DirectiveBinding) { const { value } = binding; if (value) { el.copyValue = value; diff --git a/src/directives/longpress/index.ts b/src/directives/longpress/index.ts index 544278448..4eec6a22b 100644 --- a/src/directives/longpress/index.ts +++ b/src/directives/longpress/index.ts @@ -3,7 +3,7 @@ import type { Directive, DirectiveBinding } from "vue"; import { subBefore, subAfter, isFunction } from "@pureadmin/utils"; export const longpress: Directive = { - mounted(el: HTMLElement, binding: DirectiveBinding) { + mounted(el: HTMLElement, binding: DirectiveBinding) { const cb = binding.value; if (cb && isFunction(cb)) { let timer = null; diff --git a/types/directives.d.ts b/types/directives.d.ts new file mode 100644 index 000000000..f7b9caebf --- /dev/null +++ b/types/directives.d.ts @@ -0,0 +1,13 @@ +import type { Directive } from "vue"; +import type { CopyEl } from "../src/directives/copy/index"; + +declare module "vue" { + export interface ComponentCustomProperties { + vLoading: Directive; + vAuth: Directive>; + vCopy: Directive; + vLongpress: Directive; + } +} + +export {};