feat: add pure-admin-thin

This commit is contained in:
xiaoxian521
2021-10-16 16:16:58 +08:00
parent 7067396ade
commit f4b5150b03
127 changed files with 11709 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
import { Directive } from "vue";
import type { DirectiveBinding, VNode } from "vue";
import elementResizeDetectorMaker from "element-resize-detector";
import type { Erd } from "element-resize-detector";
import { emitter } from "/@/utils/mitt";
const erd: Erd = elementResizeDetectorMaker({
strategy: "scroll"
});
export const resize: Directive = {
mounted(el: HTMLElement, binding?: DirectiveBinding, vnode?: VNode) {
erd.listenTo(el, elem => {
const width = elem.offsetWidth;
const height = elem.offsetHeight;
if (binding?.instance) {
emitter.emit("resize", { detail: { width, height } });
} else {
vnode.el.dispatchEvent(
new CustomEvent("resize", { detail: { width, height } })
);
}
});
},
unmounted(el: HTMLElement) {
erd.uninstall(el);
}
};

2
src/directives/index.ts Normal file
View File

@@ -0,0 +1,2 @@
export * from "./permission";
export * from "./elResizeDetector";

View File

@@ -0,0 +1,18 @@
import { usePermissionStoreHook } from "/@/store/modules/permission";
import { Directive } from "vue";
import type { DirectiveBinding } from "vue";
export const auth: Directive = {
mounted(el: HTMLElement, binding: DirectiveBinding) {
const { value } = binding;
if (value) {
const authRoles = value;
const hasAuth = usePermissionStoreHook().buttonAuth.includes(authRoles);
if (!hasAuth) {
el.style.display = "none";
}
} else {
throw new Error("need roles! Like v-auth=\"['admin','test']\"");
}
}
};