feat(网页端): 完善登录后工作台与项目管理体验
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
</el-menu-item>
|
||||
</el-menu-item-group>
|
||||
|
||||
<el-menu-item-group v-if="auth.user" class="menu-group">
|
||||
<el-menu-item-group v-if="showAdminNavigation" class="menu-group">
|
||||
<template #title>
|
||||
<span class="menu-divider">{{ TEXT.menu.admin }}</span>
|
||||
</template>
|
||||
@@ -141,25 +141,8 @@
|
||||
<!-- 移入 Header 的面包屑 -->
|
||||
<div v-if="breadcrumbs.length" class="header-breadcrumb">
|
||||
<template v-for="(item, index) in breadcrumbs" :key="breadcrumbKey(item, index)">
|
||||
<!-- 带下拉的选择器类型 -->
|
||||
<el-dropdown v-if="item.hasDropdown" trigger="click" @command="handleBreadcrumbCommand">
|
||||
<div class="breadcrumb-item-wrapper is-link is-study">
|
||||
<span class="breadcrumb-item-text is-link-text">{{ item.label }}</span>
|
||||
<el-icon class="breadcrumb-dropdown-icon"><ArrowDown /></el-icon>
|
||||
</div>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu class="breadcrumb-dropdown-menu">
|
||||
<template v-if="item.type === 'study'">
|
||||
<el-dropdown-item v-for="s in studies" :key="s.id" :command="{ type: 'study', value: s }" :class="{ active: study.currentStudy?.id === s.id }">
|
||||
{{ s.name }}
|
||||
</el-dropdown-item>
|
||||
</template>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
|
||||
<!-- 同级导航下拉:在同级模块/页面之间横跳 -->
|
||||
<el-dropdown v-else-if="item.navDropdown && item.siblings?.length" trigger="click" :hide-on-click="true" @command="handleBreadcrumbCommand">
|
||||
<el-dropdown v-if="item.navDropdown && item.siblings?.length" trigger="click" :hide-on-click="true" @command="handleBreadcrumbCommand">
|
||||
<div class="breadcrumb-item-wrapper is-nav" :class="{ 'is-current': index === breadcrumbs.length - 1 }">
|
||||
<span class="breadcrumb-item-text" :class="{ 'is-link-text': index < breadcrumbs.length - 1 }">{{ item.label }}</span>
|
||||
<el-icon class="breadcrumb-dropdown-icon breadcrumb-nav-icon"><ArrowDown /></el-icon>
|
||||
@@ -221,6 +204,11 @@
|
||||
</div>
|
||||
|
||||
<div class="header-right">
|
||||
<button v-if="study.currentStudy" class="workbench-return-button" type="button" @click="openWorkbenchEntry">
|
||||
<el-icon><Suitcase /></el-icon>
|
||||
<span>工作台</span>
|
||||
</button>
|
||||
|
||||
<button v-if="isDesktop" class="desktop-command-trigger" type="button" @click="openCommandPalette">
|
||||
<el-icon><Search /></el-icon>
|
||||
<span>搜索命令</span>
|
||||
@@ -332,6 +320,10 @@
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu class="user-dropdown-menu">
|
||||
<el-dropdown-item command="workbench">
|
||||
<el-icon><Suitcase /></el-icon>
|
||||
<span>工作台</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item command="profile">
|
||||
<el-icon><User /></el-icon>
|
||||
<span>{{ TEXT.menu.profile }}</span>
|
||||
@@ -498,6 +490,7 @@ const userDisplayInitial = computed(() => {
|
||||
});
|
||||
|
||||
const isAdminContext = computed(() => route.path.startsWith("/admin"));
|
||||
const showAdminNavigation = computed(() => Boolean(auth.user) && (!study.currentStudy || isAdminContext.value));
|
||||
const canReadRiskIssueAes = computed(() => !isAdminContext.value && canAccessProjectPath("/risk-issues/sae"));
|
||||
const canReadMonitoringIssues = computed(() => !isAdminContext.value && canAccessProjectPath("/risk-issues/monitoring-visits"));
|
||||
const hasAnyRiskReminderAccess = computed(() => canReadRiskIssueAes.value || canReadMonitoringIssues.value);
|
||||
@@ -792,19 +785,6 @@ const desktopCommands = computed<DesktopCommand[]>(() => {
|
||||
},
|
||||
}));
|
||||
|
||||
const projectCommands: DesktopCommand[] = studies.value.map((item) => ({
|
||||
id: `study:${item.id}`,
|
||||
title: `切换项目:${item.name}`,
|
||||
group: "项目",
|
||||
keywords: [item.name, item.project_no, item.protocol_no].filter(Boolean),
|
||||
visible: Boolean(item?.id),
|
||||
run: async () => {
|
||||
study.setCurrentStudy(item);
|
||||
await study.loadCurrentStudyPermissions().catch(() => {});
|
||||
await router.push("/project/overview");
|
||||
},
|
||||
}));
|
||||
|
||||
return [
|
||||
{
|
||||
id: "desktop:refresh",
|
||||
@@ -846,7 +826,6 @@ const desktopCommands = computed<DesktopCommand[]>(() => {
|
||||
run: toggleCurrentFavorite,
|
||||
},
|
||||
...navigationCommands,
|
||||
...projectCommands,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -918,12 +897,10 @@ const breadcrumbs = computed(() => {
|
||||
return items;
|
||||
}
|
||||
} else if (study.currentStudy) {
|
||||
// 1. 项目名(可下拉切换项目)
|
||||
// 项目内不提供横向切换项目;需要切换时先回工作台重新选择。
|
||||
items.push({
|
||||
label: (study.currentStudy.name || "").replace(/^示例项目[::]/, ''),
|
||||
path: "/project/overview",
|
||||
hasDropdown: true,
|
||||
type: 'study'
|
||||
});
|
||||
|
||||
// 3. 模块级面包屑:依据侧边栏导航树,顶级模块为二级,子菜单项为三级
|
||||
@@ -1029,12 +1006,6 @@ const breadcrumbKey = (item: any, index: number) => {
|
||||
const handleBreadcrumbCommand = async (cmd: any) => {
|
||||
if (cmd.type === 'nav') {
|
||||
if (cmd.value && cmd.value !== route.path) router.push(cmd.value);
|
||||
return;
|
||||
}
|
||||
if (cmd.type === 'study') {
|
||||
study.setCurrentStudy(cmd.value);
|
||||
await study.loadCurrentStudyPermissions().catch(() => {});
|
||||
router.push("/project/overview");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1099,6 +1070,11 @@ const logoutImmediately = async () => {
|
||||
router.replace("/login");
|
||||
};
|
||||
|
||||
const openWorkbenchEntry = async () => {
|
||||
study.clearCurrentStudy();
|
||||
await router.push("/workbench");
|
||||
};
|
||||
|
||||
const onLogout = async () => {
|
||||
if (loggingOut.value) return;
|
||||
const confirmed = await ElMessageBox.confirm(
|
||||
@@ -1158,6 +1134,8 @@ onBeforeUnmount(() => {
|
||||
const onCommand = (cmd: string) => {
|
||||
if (cmd === "logout") {
|
||||
onLogout();
|
||||
} else if (cmd === "workbench") {
|
||||
void openWorkbenchEntry();
|
||||
} else if (cmd === "profile") {
|
||||
profileDialogVisible.value = true;
|
||||
} else if (cmd === "desktopPreferences") {
|
||||
@@ -1649,6 +1627,26 @@ useDesktopShortcuts(
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.workbench-return-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #c7d7ec;
|
||||
border-radius: 8px;
|
||||
background: #eff6ff;
|
||||
color: #1d4ed8;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.workbench-return-button:hover {
|
||||
border-color: #93c5fd;
|
||||
background: #dbeafe;
|
||||
}
|
||||
|
||||
.desktop-command-trigger {
|
||||
display: inline-grid;
|
||||
grid-template-columns: auto minmax(0, auto) auto;
|
||||
|
||||
Reference in New Issue
Block a user