2026-05-29 18:16:34 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<template v-if="visibility === 'interactive'">
|
|
|
|
|
|
<slot />
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<div v-else-if="visibility === 'readonly'" class="pg-readonly" :title="`${widgetId} 当前为只读`">
|
|
|
|
|
|
<slot />
|
|
|
|
|
|
<div class="pg-mask" />
|
|
|
|
|
|
</div>
|
2026-05-29 23:51:57 +08:00
|
|
|
|
<el-empty v-else class="pg-hidden">
|
|
|
|
|
|
<template #description>
|
|
|
|
|
|
<p class="pg-hidden-title">当前账号无权查看此功能</p>
|
2026-08-26 17:50:02 +08:00
|
|
|
|
<p class="pg-hidden-hint">控件:{{ widgetId }}。请在「权限与角色」中为该账号开放对应页面后重新登录。</p>
|
2026-05-29 23:51:57 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-empty>
|
2026-05-29 18:16:34 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { computed } from 'vue'
|
2026-08-26 17:50:02 +08:00
|
|
|
|
import { useRoute } from 'vue-router'
|
2026-05-29 18:16:34 +08:00
|
|
|
|
import { useAuthStore } from '@/stores/auth'
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{ widgetId: string }>()
|
|
|
|
|
|
const auth = useAuthStore()
|
2026-08-26 17:50:02 +08:00
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
|
|
|
|
/** 页面已授权则具备该页管理能力,不再被 ConfigCenter 等控件 hidden 整页挡住。 */
|
|
|
|
|
|
const visibility = computed(() => {
|
|
|
|
|
|
const name = typeof route.name === 'string' ? route.name : ''
|
|
|
|
|
|
if (name && auth.hasPage(name)) return 'interactive' as const
|
|
|
|
|
|
return auth.widgetOf(props.widgetId)
|
|
|
|
|
|
})
|
2026-05-29 18:16:34 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.pg-readonly { position: relative; }
|
|
|
|
|
|
.pg-mask {
|
|
|
|
|
|
position: absolute; inset: 0; background: rgba(255, 255, 255, 0.3);
|
|
|
|
|
|
pointer-events: all; cursor: not-allowed;
|
|
|
|
|
|
}
|
2026-05-29 23:51:57 +08:00
|
|
|
|
.pg-hidden { padding: 48px 16px; }
|
|
|
|
|
|
.pg-hidden-title { margin: 0 0 6px; font-size: 14px; color: var(--mg-text-light, #fff); }
|
|
|
|
|
|
.pg-hidden-hint { margin: 0; font-size: 12px; color: var(--mg-text-muted, rgba(255,255,255,.65)); }
|
2026-05-29 18:16:34 +08:00
|
|
|
|
</style>
|