mirror of
https://github.com/halo-dev/halo.git
synced 2025-12-20 16:44:38 +08:00
Refactor permission checks to use shared utils (#7853)
#### What type of PR is this?
/area ui
/kind feature
/milestone 2.22.x
#### What this PR does / why we need it:
This PR introduces a developer-friendly utility for checking UI permissions, which is also exposed for use by plugins.
Usage:
```ts
import { utils } from "@halo-dev/console-shared"
utils.permission.has(['any:permission'])
```
#### Does this PR introduce a user-facing change?
```release-note
在 `@halo-dev/console-shared` 包中提供 UI 权限检查工具
```
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<script lang="ts" setup>
|
||||
import { usePermission } from "@/utils/permission";
|
||||
import {
|
||||
PluginStatusPhaseEnum,
|
||||
consoleApiClient,
|
||||
@@ -21,6 +20,7 @@ import {
|
||||
VPageHeader,
|
||||
VSpace,
|
||||
} from "@halo-dev/components";
|
||||
import { utils } from "@halo-dev/console-shared";
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import { useRouteQuery } from "@vueuse/router";
|
||||
import type { Ref } from "vue";
|
||||
@@ -31,7 +31,6 @@ import PluginListItem from "./components/PluginListItem.vue";
|
||||
import { usePluginBatchOperations } from "./composables/use-plugin";
|
||||
|
||||
const { t } = useI18n();
|
||||
const { currentUserHasPermission } = usePermission();
|
||||
|
||||
const pluginInstallationModalVisible = ref(false);
|
||||
|
||||
@@ -152,7 +151,7 @@ onMounted(() => {
|
||||
<PluginInstallationModal
|
||||
v-if="
|
||||
pluginInstallationModalVisible &&
|
||||
currentUserHasPermission(['system:plugins:manage'])
|
||||
utils.permission.has(['system:plugins:manage'])
|
||||
"
|
||||
@close="pluginInstallationModalVisible = false"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user