chore: prettier & lint

Former-commit-id: 486f65e137348f400d7b95067bd3cd5a2f23ff44
This commit is contained in:
Jachin
2023-08-04 17:50:25 +08:00
parent a240ff04d2
commit f797606c44
72 changed files with 1234 additions and 484 deletions

View File

@@ -1,9 +1,9 @@
import type { App } from 'vue';
import type { App } from "vue";
import { hasPerm } from './permission';
import { hasPerm } from "./permission";
// 全局注册 directive
export function setupDirective(app: App<Element>) {
// 使 v-hasPerm 在所有组件中都可用
app.directive('hasPerm', hasPerm);
app.directive("hasPerm", hasPerm);
}

View File

@@ -1,5 +1,5 @@
import { useUserStoreHook } from '@/store/modules/user';
import { Directive, DirectiveBinding } from 'vue';
import { useUserStoreHook } from "@/store/modules/user";
import { Directive, DirectiveBinding } from "vue";
/**
* 按钮权限
@@ -8,7 +8,7 @@ export const hasPerm: Directive = {
mounted(el: HTMLElement, binding: DirectiveBinding) {
// 「超级管理员」拥有所有的按钮权限
const { roles, perms } = useUserStoreHook();
if (roles.includes('ROOT')) {
if (roles.includes("ROOT")) {
return true;
}
// 「其他角色」按钮权限校验
@@ -16,7 +16,7 @@ export const hasPerm: Directive = {
if (value) {
const requiredPerms = value; // DOM绑定需要的按钮权限标识
const hasPerm = perms?.some(perm => {
const hasPerm = perms?.some((perm) => {
return requiredPerms.includes(perm);
});
@@ -28,7 +28,7 @@ export const hasPerm: Directive = {
"need perms! Like v-has-perm=\"['sys:user:add','sys:user:edit']\""
);
}
}
},
};
/**
@@ -41,7 +41,7 @@ export const hasRole: Directive = {
if (value) {
const requiredRoles = value; // DOM绑定需要的角色编码
const { roles } = useUserStoreHook();
const hasRole = roles.some(perm => {
const hasRole = roles.some((perm) => {
return requiredRoles.includes(perm);
});
@@ -51,5 +51,5 @@ export const hasRole: Directive = {
} else {
throw new Error("need roles! Like v-has-role=\"['admin','test']\"");
}
}
},
};