首次提交

This commit is contained in:
2023-06-04 20:01:58 +08:00
parent 00c64c53bb
commit 587f078d21
560 changed files with 106725 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
import { useUserStore } from "@/store"
const auth = (name) => {
const userStore = useUserStore()
return (userStore.codes && userStore.codes.includes(name)) || (userStore.codes && userStore.codes.includes("*"))
}
export default auth

View File

@@ -0,0 +1,29 @@
import auth from "./auth"
const checkAuth = (el, binding) => {
const { value } = binding
if (Array.isArray(value)) {
if (value.length > 0) {
let isHas = false
value.map((item) => {
isHas = auth(item)
})
if (!isHas && el.parentNode) {
el.parentNode.removeChild(el)
}
}
} else {
throw new Error(`need permission! Like v-auth="['admin','user']"`)
}
}
export default {
mounted(el, binding) {
checkAuth(el, binding)
},
updated(el, binding) {
checkAuth(el, binding)
}
}

View File

@@ -0,0 +1,27 @@
import useClipboard from "vue-clipboard3"
import { Message } from "@arco-design/web-vue"
const copy = (el, binding) => {
const { value } = binding
el.addEventListener("click", async () => {
if (value && value !== "") {
try {
await useClipboard().toClipboard(value)
Message.success("已成功复制到剪切板")
} catch (e) {
Message.error("复制失败")
}
} else {
throw new Error(`need for copy content! Like v-copy="Hello World"`)
}
})
}
export default {
mounted(el, binding) {
copy(el, binding)
},
updated(el, binding) {
copy(el, binding)
}
}

View File

@@ -0,0 +1,11 @@
import auth from "./auth/index"
import role from "./role/index"
import copy from "./copy/index"
export default {
install(Vue) {
Vue.directive("auth", auth)
Vue.directive("role", role)
Vue.directive("copy", copy)
}
}

View File

@@ -0,0 +1,29 @@
import role from "./role"
const checkRole = (el, binding) => {
const { value } = binding
if (Array.isArray(value)) {
if (value.length > 0) {
let isHas = false
value.map((item) => {
isHas = role(item)
})
if (!isHas && el.parentNode) {
el.parentNode.removeChild(el)
}
}
} else {
throw new Error(`need role! Like v-role="['seo', 'cfo']"`)
}
}
export default {
mounted(el, binding) {
checkRole(el, binding)
},
updated(el, binding) {
checkRole(el, binding)
}
}

View File

@@ -0,0 +1,11 @@
import { useUserStore } from "@/store"
const role = (name) => {
const userStore = useUserStore()
return (
(userStore.roles && userStore.roles.includes(name)) ||
(userStore.roles && userStore.roles.includes("superAdmin"))
)
}
export default role