mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-07 17:07:19 +08:00
types: complete dirctives and v-auth custom color
This commit is contained in:
parent
a8377f8d45
commit
577b2d3977
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"christian-kohler.path-intellisense",
|
"christian-kohler.path-intellisense",
|
||||||
|
"warmthsea.vscode-custom-code-color",
|
||||||
"vscode-icons-team.vscode-icons",
|
"vscode-icons-team.vscode-icons",
|
||||||
"davidanson.vscode-markdownlint",
|
"davidanson.vscode-markdownlint",
|
||||||
"ms-azuretools.vscode-docker",
|
"ms-azuretools.vscode-docker",
|
||||||
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -43,5 +43,7 @@
|
|||||||
"port": 1883,
|
"port": 1883,
|
||||||
"clientId": "vsmqtt_client_db34"
|
"clientId": "vsmqtt_client_db34"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"vscodeCustomCodeColor.highlightValue": "v-auth",
|
||||||
|
"vscodeCustomCodeColor.highlightValueColor": "#6366f1",
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { hasAuth } from "@/router/utils";
|
|||||||
import type { Directive, DirectiveBinding } from "vue";
|
import type { Directive, DirectiveBinding } from "vue";
|
||||||
|
|
||||||
export const auth: Directive = {
|
export const auth: Directive = {
|
||||||
mounted(el: HTMLElement, binding: DirectiveBinding) {
|
mounted(el: HTMLElement, binding: DirectiveBinding<string | Array<string>>) {
|
||||||
const { value } = binding;
|
const { value } = binding;
|
||||||
if (value) {
|
if (value) {
|
||||||
!hasAuth(value) && el.parentNode?.removeChild(el);
|
!hasAuth(value) && el.parentNode?.removeChild(el);
|
||||||
|
@ -3,13 +3,13 @@ import { useEventListener } from "@vueuse/core";
|
|||||||
import { copyTextToClipboard } from "@pureadmin/utils";
|
import { copyTextToClipboard } from "@pureadmin/utils";
|
||||||
import type { Directive, DirectiveBinding } from "vue";
|
import type { Directive, DirectiveBinding } from "vue";
|
||||||
|
|
||||||
interface CopyEl extends HTMLElement {
|
export interface CopyEl extends HTMLElement {
|
||||||
copyValue: string;
|
copyValue: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 文本复制指令(默认双击复制) */
|
/** 文本复制指令(默认双击复制) */
|
||||||
export const copy: Directive = {
|
export const copy: Directive = {
|
||||||
mounted(el: CopyEl, binding: DirectiveBinding) {
|
mounted(el: CopyEl, binding: DirectiveBinding<string>) {
|
||||||
const { value } = binding;
|
const { value } = binding;
|
||||||
if (value) {
|
if (value) {
|
||||||
el.copyValue = value;
|
el.copyValue = value;
|
||||||
|
@ -3,7 +3,7 @@ import type { Directive, DirectiveBinding } from "vue";
|
|||||||
import { subBefore, subAfter, isFunction } from "@pureadmin/utils";
|
import { subBefore, subAfter, isFunction } from "@pureadmin/utils";
|
||||||
|
|
||||||
export const longpress: Directive = {
|
export const longpress: Directive = {
|
||||||
mounted(el: HTMLElement, binding: DirectiveBinding) {
|
mounted(el: HTMLElement, binding: DirectiveBinding<Function>) {
|
||||||
const cb = binding.value;
|
const cb = binding.value;
|
||||||
if (cb && isFunction(cb)) {
|
if (cb && isFunction(cb)) {
|
||||||
let timer = null;
|
let timer = null;
|
||||||
|
13
types/directives.d.ts
vendored
Normal file
13
types/directives.d.ts
vendored
Normal 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 {};
|
Loading…
x
Reference in New Issue
Block a user