mirror of https://github.com/halo-dev/halo-admin
fix: ui permissions (#633)
parent
d385ae84dd
commit
7bc46a5e90
|
@ -173,10 +173,9 @@ async function loadCurrentUser() {
|
|||
app.directive(
|
||||
"permission",
|
||||
(el: HTMLElement, binding: DirectiveBinding<string[]>) => {
|
||||
// const uiPermissions = Array.from<string>(
|
||||
// currentPermissions.uiPermissions
|
||||
// );
|
||||
const uiPermissions = Array.from<string>(["system:attachments:view"]);
|
||||
const uiPermissions = Array.from<string>(
|
||||
currentPermissions.uiPermissions
|
||||
);
|
||||
const { value } = binding;
|
||||
const { any, enable } = binding.modifiers;
|
||||
|
||||
|
|
|
@ -609,7 +609,7 @@ onMounted(() => {
|
|||
<VEntity :is-selected="isChecked(attachment)">
|
||||
<template
|
||||
v-if="
|
||||
!currentUserHasPermission(['system:attachments:manage'])
|
||||
currentUserHasPermission(['system:attachments:manage'])
|
||||
"
|
||||
#checkbox
|
||||
>
|
||||
|
@ -695,7 +695,7 @@ onMounted(() => {
|
|||
</template>
|
||||
<template
|
||||
v-if="
|
||||
!currentUserHasPermission(['system:attachments:manage'])
|
||||
currentUserHasPermission(['system:attachments:manage'])
|
||||
"
|
||||
#dropdownItems
|
||||
>
|
||||
|
|
|
@ -251,7 +251,7 @@ const subjectRefResult = computed(() => {
|
|||
<div class="absolute inset-x-0 bottom-0 h-[1px] bg-black/50"></div>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:comments:manage'])"
|
||||
v-if="currentUserHasPermission(['system:comments:manage'])"
|
||||
#checkbox
|
||||
>
|
||||
<slot name="checkbox" />
|
||||
|
@ -343,7 +343,7 @@ const subjectRefResult = computed(() => {
|
|||
</VEntityField>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:comments:manage'])"
|
||||
v-if="currentUserHasPermission(['system:comments:manage'])"
|
||||
#dropdownItems
|
||||
>
|
||||
<VButton
|
||||
|
|
|
@ -536,7 +536,7 @@ function handleSortItemChange(sortItem?: SortItem) {
|
|||
<li v-for="(singlePage, index) in singlePages.items" :key="index">
|
||||
<VEntity :is-selected="checkAll">
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:singlepages:manage'])"
|
||||
v-if="currentUserHasPermission(['system:singlepages:manage'])"
|
||||
#checkbox
|
||||
>
|
||||
<input
|
||||
|
@ -636,7 +636,7 @@ function handleSortItemChange(sortItem?: SortItem) {
|
|||
</VEntityField>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:singlepages:manage'])"
|
||||
v-if="currentUserHasPermission(['system:singlepages:manage'])"
|
||||
#dropdownItems
|
||||
>
|
||||
<VButton
|
||||
|
|
|
@ -800,7 +800,7 @@ function handleContributorChange(user?: User) {
|
|||
<li v-for="(post, index) in posts.items" :key="index">
|
||||
<VEntity :is-selected="checkSelection(post.post)">
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:posts:manage'])"
|
||||
v-if="currentUserHasPermission(['system:posts:manage'])"
|
||||
#checkbox
|
||||
>
|
||||
<input
|
||||
|
@ -922,7 +922,7 @@ function handleContributorChange(user?: User) {
|
|||
</VEntityField>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:posts:manage'])"
|
||||
v-if="currentUserHasPermission(['system:posts:manage'])"
|
||||
#dropdownItems
|
||||
>
|
||||
<VButton
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
import { VTag } from "@halo-dev/components";
|
||||
import type { Tag } from "@halo-dev/api-client";
|
||||
import { computed } from "vue";
|
||||
// @ts-ignore
|
||||
import Color from "colorjs.io";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
const props = withDefaults(
|
||||
|
@ -21,9 +19,8 @@ const labelColor = computed(() => {
|
|||
if (!color) {
|
||||
return "inherit";
|
||||
}
|
||||
const onWhite = Math.abs(Color.contrast(color, "white", "APCA"));
|
||||
const onBlack = Math.abs(Color.contrast(color, "black", "APCA"));
|
||||
return onWhite > onBlack ? "white" : "#333";
|
||||
// TODO computed label color
|
||||
return "#333";
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
|
|
|
@ -103,7 +103,7 @@ function getMenuItemRefDisplayName(menuItem: MenuTreeItem) {
|
|||
</VEntityField>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:menus:manage'])"
|
||||
v-if="currentUserHasPermission(['system:menus:manage'])"
|
||||
#dropdownItems
|
||||
>
|
||||
<VButton
|
||||
|
|
|
@ -165,7 +165,7 @@ defineExpose({
|
|||
</VEntityField>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:menus:manage'])"
|
||||
v-if="currentUserHasPermission(['system:menus:manage'])"
|
||||
#dropdownItems
|
||||
>
|
||||
<VButton
|
||||
|
@ -188,7 +188,7 @@ defineExpose({
|
|||
</VEntity>
|
||||
</li>
|
||||
</ul>
|
||||
<template v-if="!currentUserHasPermission(['system:menus:manage'])" #footer>
|
||||
<template v-if="currentUserHasPermission(['system:menus:manage'])" #footer>
|
||||
<VButton block type="secondary" @click="handleOpenEditingModal()">
|
||||
新增
|
||||
</VButton>
|
||||
|
|
|
@ -246,7 +246,7 @@ defineExpose({
|
|||
</VEntityField>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:themes:manage'])"
|
||||
v-if="currentUserHasPermission(['system:themes:manage'])"
|
||||
#dropdownItems
|
||||
>
|
||||
<VButton
|
||||
|
|
|
@ -101,7 +101,7 @@ const { isStarted, changeStatus, uninstall } = usePluginLifeCycle(plugin);
|
|||
</VEntityField>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:plugins:manage'])"
|
||||
v-if="currentUserHasPermission(['system:plugins:manage'])"
|
||||
#dropdownItems
|
||||
>
|
||||
<VButton v-close-popper block type="danger" @click="uninstall">
|
||||
|
|
|
@ -276,7 +276,7 @@ const handleDelete = async (role: Role) => {
|
|||
</VEntityField>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:roles:manage'])"
|
||||
v-if="currentUserHasPermission(['system:roles:manage'])"
|
||||
#dropdownItems
|
||||
>
|
||||
<VButton
|
||||
|
|
|
@ -388,7 +388,7 @@ onMounted(() => {
|
|||
<li v-for="(user, index) in searchResults" :key="index">
|
||||
<VEntity :is-selected="checkSelection(user)">
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:users:manage'])"
|
||||
v-if="currentUserHasPermission(['system:users:manage'])"
|
||||
#checkbox
|
||||
>
|
||||
<input
|
||||
|
@ -446,7 +446,7 @@ onMounted(() => {
|
|||
</VEntityField>
|
||||
</template>
|
||||
<template
|
||||
v-if="!currentUserHasPermission(['system:users:manage'])"
|
||||
v-if="currentUserHasPermission(['system:users:manage'])"
|
||||
#dropdownItems
|
||||
>
|
||||
<VButton
|
||||
|
|
Loading…
Reference in New Issue