feat(role): 根据role判断用户的权限
This commit is contained in:
1 parent
80d78130f8
commit
a24bd94d43
93 files changed
+4472
-387
No files matched your search
@@ -27,6 +27,7 @@ import {
|
||||
} from 'lucide-vue-next';
|
||||
import LocaleToggleButton from '@/shared/components/LocaleToggleButton.vue';
|
||||
import { ExternalSystemLinks } from '@/features/sso';
|
||||
import { isPlatformAdminUser } from '@/shared/utils/auth';
|
||||
import AgentCategoryList from '@/shared/components/AgentCategoryList.vue';
|
||||
import { isHrFocusedAgent, type AgentRegistryFields } from '@/shared/utils/agent-registry.utils';
|
||||
import type { AgentWithCategory } from '@/shared/utils/agent-category.utils';
|
||||
@@ -100,6 +101,8 @@ const onGoAdmin = () => {
|
||||
emit('go-admin');
|
||||
};
|
||||
|
||||
const canOpenAdmin = computed(() => isPlatformAdminUser(props.currentUser as { is_platform_admin?: boolean; role?: string } | null));
|
||||
|
||||
const agentAvatarLabel = computed(() => (isHrFocusedAgent(props.currentAgent) ? 'HR' : 'AI'));
|
||||
|
||||
const userInitial = (fallback: string) => {
|
||||
@@ -352,7 +355,7 @@ const orderExtractionAttentionClass = (item: DisplayHistoryItem) => {
|
||||
<Briefcase class="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
v-if="currentUser?.role === 'admin'"
|
||||
v-if="canOpenAdmin"
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center transition-colors hover:text-secondary"
|
||||
:title="$t('admin.title')"
|
||||
|
||||
@@ -19,7 +19,7 @@ import { computed, defineAsyncComponent, provide, ref, watch } from 'vue';
|
||||
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { Maximize2, Minimize2, Loader2 } from 'lucide-vue-next';
|
||||
import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
|
||||
import ChatShell from '@/shared/layouts/ChatShell.vue';
|
||||
|
||||
@@ -164,7 +164,13 @@ const embeddedIframeSrc = computed(() => {
|
||||
|
||||
});
|
||||
|
||||
const canManageMaintenance = computed(() => ['admin', 'maintenance_manager'].includes(String(page.currentUser?.role || '')));
|
||||
const authStore = useAuthStore();
|
||||
|
||||
/**
|
||||
* 设备维保台账/维修写入口。
|
||||
* 核心逻辑:读登录态 maintenance.ledger_write,不再认 role 字符串。
|
||||
*/
|
||||
const canManageMaintenance = computed(() => authStore.hasFeaturePermission('maintenance.ledger_write'));
|
||||
|
||||
const hideWelcomePanel = computed(() => false);
|
||||
|
||||
|
||||
@@ -58,7 +58,11 @@ const records = computed(() => payload.value?.records || []);
|
||||
const queryMode = computed(() => payload.value?.queryMode === 'records' ? 'records' : 'device');
|
||||
const hasResult = computed(() => Boolean(device.value || records.value.length));
|
||||
const ledgerMatched = computed(() => payload.value?.summary?.ledgerMatched !== false);
|
||||
const canManageMaintenance = computed(() => ['admin', 'maintenance_manager'].includes(String(authStore.user?.role || '')));
|
||||
/**
|
||||
* 结果卡上的新增/编辑维修入口。
|
||||
* 核心逻辑:读登录态 maintenance.ledger_write,不再认 role 字符串。
|
||||
*/
|
||||
const canManageMaintenance = computed(() => authStore.hasFeaturePermission('maintenance.ledger_write'));
|
||||
const selectedRecord = ref<MaintenanceRecord | null>(null);
|
||||
|
||||
const deviceStatusLabel = (status?: string | null) => {
|
||||
|
||||
@@ -510,7 +510,6 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
const canForceCreateShippingDuplicate = computed(() => {
|
||||
const user = useAuthStore().user;
|
||||
if (!user) return false;
|
||||
if (String(user.role || '') === 'admin') return true;
|
||||
return Boolean(user.feature_permissions?.shipping_notice_force_create);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user