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