types: complete dirctives and v-auth custom color

This commit is contained in:
warmthsea 2024-05-29 10:03:03 +08:00
parent a8377f8d45
commit 577b2d3977
6 changed files with 21 additions and 5 deletions

View File

@ -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",

View File

@ -43,5 +43,7 @@
"port": 1883,
"clientId": "vsmqtt_client_db34"
}
]
],
"vscodeCustomCodeColor.highlightValue": "v-auth",
"vscodeCustomCodeColor.highlightValueColor": "#6366f1",
}

View File

@ -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<string | Array<string>>) {
const { value } = binding;
if (value) {
!hasAuth(value) && el.parentNode?.removeChild(el);

View File

@ -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<string>) {
const { value } = binding;
if (value) {
el.copyValue = value;

View File

@ -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<Function>) {
const cb = binding.value;
if (cb && isFunction(cb)) {
let timer = null;

13
types/directives.d.ts vendored Normal file
View File

@ -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<Element, boolean>;
vAuth: Directive<HTMLElement, string | Array<string>>;
vCopy: Directive<CopyEl, string>;
vLongpress: Directive<HTMLElement, Function>;
}
}
export {};