feat(网页端): 完善登录后工作台与项目管理体验
Client Quality Gates / Shared client and Web (push) Has been cancelled
Client Quality Gates / macOS Desktop (push) Has been cancelled

This commit is contained in:
Cheng Zhou
2026-07-09 14:59:06 +08:00
parent 0aff10fe0d
commit 1dc10f569d
15 changed files with 1418 additions and 185 deletions
+1 -1
View File
@@ -65,7 +65,7 @@
<div class="ctms-boot-mark">CTMS</div>
<div>
<p class="ctms-boot-title">正在启动 CTMS</p>
<p class="ctms-boot-subtitle">正在加载桌面客户端...</p>
<p class="ctms-boot-subtitle">正在加载系统...</p>
</div>
</div>
</div>
@@ -67,6 +67,20 @@ describe("desktop layout shell", () => {
expect(navigation).toContain("export const getActiveLayoutPath");
});
it("keeps web project switching routed through the workbench entry", () => {
const webLayout = readWebLayoutSource();
expect(webLayout).toContain('class="workbench-return-button"');
expect(webLayout).toContain('await router.push("/workbench")');
expect(webLayout).toContain("const showAdminNavigation = computed(() => Boolean(auth.user) && (!study.currentStudy || isAdminContext.value))");
expect(webLayout).not.toContain("hasDropdown: true");
expect(webLayout).not.toContain("type: 'study'");
expect(webLayout).not.toContain('type: "study"');
expect(webLayout).not.toContain("`切换项目:${item.name}`");
expect(webLayout).not.toContain("study.setCurrentStudy(cmd.value)");
expect(webLayout).not.toContain('router.push("/project/overview");');
});
it("keeps desktop context labels and command entry points de-duplicated", () => {
const source = readDesktopLayoutSource();
+5 -71
View File
@@ -7,23 +7,8 @@
</div>
<template #dropdown>
<el-dropdown-menu class="study-dropdown">
<el-dropdown-item v-if="loading" disabled>
<el-icon><Loading /></el-icon>{{ TEXT.common.loading }}
</el-dropdown-item>
<el-dropdown-item v-else-if="!studies.length" disabled>{{ TEXT.common.empty.noData }}</el-dropdown-item>
<el-dropdown-item
v-for="item in studies"
:key="item.id"
:command="{ type: 'switch', study: item }"
:class="{ active: study.currentStudy?.id === item.id }"
>
<div class="study-item">
<div class="name">{{ item.name }}</div>
<div class="code">{{ item.code }}</div>
</div>
</el-dropdown-item>
<el-dropdown-item divided command="clear" class="danger-item">
<el-icon><Close /></el-icon>{{ TEXT.common.actions.exitProject }}
<el-dropdown-item command="workbench">
<el-icon><OfficeBuilding /></el-icon>返回工作台选择项目
</el-dropdown-item>
</el-dropdown-menu>
</template>
@@ -31,48 +16,20 @@
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
import { useStudyStore } from "../store/study";
import { fetchStudies } from "../api/studies";
import type { Study } from "../types/api";
import { OfficeBuilding, ArrowDown, Close, Loading } from "@element-plus/icons-vue";
import { OfficeBuilding, ArrowDown } from "@element-plus/icons-vue";
import { TEXT } from "../locales";
const router = useRouter();
const study = useStudyStore();
const studies = ref<Study[]>([]);
const loading = ref(false);
const loadStudies = async () => {
loading.value = true;
try {
const { data } = await fetchStudies();
studies.value = data.items || [];
} catch (e: any) {
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
} finally {
loading.value = false;
}
};
const onCommand = async (cmd: any) => {
if (cmd === "clear") {
if (cmd === "workbench") {
study.clearCurrentStudy();
router.push("/admin/projects");
return;
}
if (cmd?.type === "switch" && cmd.study) {
study.setCurrentStudy(cmd.study as Study);
await study.loadCurrentStudyPermissions().catch(() => {});
router.push("/project/overview");
await router.push("/workbench");
}
};
onMounted(() => {
loadStudies();
});
</script>
<style scoped>
@@ -119,27 +76,4 @@ onMounted(() => {
min-width: 220px;
}
.study-item {
display: flex;
flex-direction: column;
gap: 2px;
}
.study-item .name {
font-weight: 600;
color: var(--ctms-text-main);
}
.study-item .code {
font-size: 12px;
color: var(--ctms-text-secondary);
}
.active {
background-color: var(--ctms-primary-light);
}
.danger-item {
color: var(--ctms-danger);
}
</style>
+40 -42
View File
@@ -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;
+2 -1
View File
@@ -11,6 +11,7 @@ describe("app bootstrap shell", () => {
expect(source).toContain('<div id="app">');
expect(source).toContain("ctms-boot-splash");
expect(source).toContain("正在启动 CTMS");
expect(source).toContain("正在加载桌面客户端");
expect(source).toContain("正在加载系统");
expect(source).not.toContain("正在加载桌面客户端");
});
});
+24 -12
View File
@@ -78,20 +78,33 @@ describe("admin project route permissions", () => {
expect(source).not.toContain("[SYSTEM_PERMISSION_MONITORING_METRICS]");
});
it("routes desktop login and missing-project flows through the dedicated entry chooser", () => {
it("routes web and desktop login plus missing-project flows through the entry chooser", () => {
const source = readRouter();
expect(source).not.toContain("findPmAdminLandingPath");
expect(source).not.toContain("pmAdminLandingModules");
expect(source).toContain('path: "/desktop/project-entry"');
expect(source).toContain('component: DesktopProjectEntry');
expect(source).toContain('const WEB_WORKBENCH_ENTRY_PATH = "/workbench";');
expect(source).toContain('const DESKTOP_PROJECT_ENTRY_PATH = "/desktop/project-entry";');
expect(source).toContain("const resolveWorkbenchEntryPath = (isDesktopRuntime: boolean)");
expect(source).toContain("const isWorkbenchEntryPath = (path: string)");
expect(source).toContain('import WebWorkbenchEntry from "../views/WebWorkbenchEntry.vue";');
expect(source).toContain("path: WEB_WORKBENCH_ENTRY_PATH");
expect(source).toContain('name: "WorkbenchEntry"');
expect(source).toContain("component: WebWorkbenchEntry");
expect(source).toContain("path: DESKTOP_PROJECT_ENTRY_PATH");
expect(source).toContain("component: DesktopProjectEntry");
expect(source).toContain("DesktopSessionRestore");
expect(source).toContain("DESKTOP_SESSION_RESTORE_PATH");
expect(source).toContain('if (isDesktopRuntime) {\n next({ path: "/desktop/project-entry" });');
expect(source).toContain('isDesktopRuntime ? "/desktop/project-entry" : isAdmin ? "/admin/users" : "/admin/projects"');
expect(source).toContain("if (isDesktopRuntime && to.path === WEB_WORKBENCH_ENTRY_PATH)");
expect(source).toContain("if (!isDesktopRuntime && to.path === DESKTOP_PROJECT_ENTRY_PATH)");
expect(source).toContain("const workbenchEntryPath = resolveWorkbenchEntryPath(isDesktopRuntime)");
expect(source).toContain("next({ path: workbenchEntryPath });");
expect(source).toContain('if (isDesktopRuntime && token && !isAdmin && to.path.startsWith("/admin"))');
expect(source).toContain('if (isDesktopRuntime && token && to.path === "/desktop/project-entry" && studyStore.currentStudy)');
expect(source).toContain('if (token && !studyStore.currentStudy && !isDesktopRuntime)');
expect(source).toContain('next({ path: DESKTOP_PROJECT_ENTRY_PATH });');
expect(source).toContain("if (token && isWorkbenchEntryPath(to.path) && studyStore.currentStudy)");
expect(source).not.toContain("if (token && !studyStore.currentStudy && !isDesktopRuntime)");
expect(source).not.toContain("ensureDefaultActiveStudy();");
expect(source).not.toContain("ensureDefaultStudy();");
});
it("canonicalizes the legacy file version entry before rendering its loading fallback", () => {
@@ -117,7 +130,7 @@ describe("admin project route permissions", () => {
const restoreRedirectIndex = source.indexOf("next({ path: DESKTOP_SESSION_RESTORE_PATH", preserveIndex);
const logoutIndex = source.indexOf("await auth.logout()", restoreRedirectIndex);
const loginRedirectIndex = source.indexOf('next({ path: "/login" })', logoutIndex);
const projectFallbackIndex = source.indexOf("if (token && !studyStore.currentStudy && !isDesktopRuntime)", restoreGuardIndex);
const workbenchEntryIndex = source.indexOf("const workbenchEntryPath = resolveWorkbenchEntryPath(isDesktopRuntime)", restoreGuardIndex);
expect(restoreGuardIndex).toBeGreaterThan(-1);
expect(fetchMeIndex).toBeGreaterThan(restoreGuardIndex);
@@ -125,7 +138,7 @@ describe("admin project route permissions", () => {
expect(restoreRedirectIndex).toBeGreaterThan(preserveIndex);
expect(logoutIndex).toBeGreaterThan(restoreRedirectIndex);
expect(loginRedirectIndex).toBeGreaterThan(logoutIndex);
expect(fetchMeIndex).toBeLessThan(projectFallbackIndex);
expect(workbenchEntryIndex).toBeGreaterThan(fetchMeIndex);
expect(source).toContain("const isDesktopSessionRestoreRoute = to.path === DESKTOP_SESSION_RESTORE_PATH");
expect(source).toContain("!isDesktopSessionRestoreRoute");
expect(source).toContain("disableNetworkRetry: true");
@@ -135,11 +148,10 @@ describe("admin project route permissions", () => {
it("does not register the removed non-admin personal dashboard route", () => {
const source = readRouter();
const removedComponent = ["My", "Work", "bench"].join("");
const removedPath = `/${["work", "bench"].join("")}`;
expect(source).not.toContain(removedComponent);
expect(source).not.toContain(`path: "${removedPath.slice(1)}"`);
expect(source).not.toContain(`"${removedPath}"`);
expect(source).not.toContain(`component: ${removedComponent}`);
expect(source).not.toContain('path: "workbench"');
});
it("does not register legacy finance contract routes", () => {
+32 -27
View File
@@ -13,6 +13,7 @@ import ForgotPassword from "../views/ForgotPassword.vue";
import DesktopServerSettings from "../views/DesktopServerSettings.vue";
import DesktopProjectEntry from "../views/DesktopProjectEntry.vue";
import DesktopSessionRestore from "../views/DesktopSessionRestore.vue";
import WebWorkbenchEntry from "../views/WebWorkbenchEntry.vue";
import StudyHome from "../views/StudyHome.vue";
import FaqDetail from "../views/FaqDetail.vue";
import AuditLogs from "../views/admin/AuditLogs.vue";
@@ -63,6 +64,14 @@ import { DESKTOP_SESSION_RESTORE_PATH, shouldPreserveDesktopSessionOnAuthCheckFa
const SYSTEM_PERMISSION_READ = "system:permissions:read";
const SYSTEM_PERMISSION_PROJECT_CONFIG = "system:permissions:project_config";
const WEB_WORKBENCH_ENTRY_PATH = "/workbench";
const DESKTOP_PROJECT_ENTRY_PATH = "/desktop/project-entry";
const resolveWorkbenchEntryPath = (isDesktopRuntime: boolean) =>
isDesktopRuntime ? DESKTOP_PROJECT_ENTRY_PATH : WEB_WORKBENCH_ENTRY_PATH;
const isWorkbenchEntryPath = (path: string) =>
path === WEB_WORKBENCH_ENTRY_PATH || path === DESKTOP_PROJECT_ENTRY_PATH;
const routes: RouteRecordRaw[] = [
{
@@ -96,7 +105,13 @@ const routes: RouteRecordRaw[] = [
meta: { public: true, title: "恢复登录状态" },
},
{
path: "/desktop/project-entry",
path: WEB_WORKBENCH_ENTRY_PATH,
name: "WorkbenchEntry",
component: WebWorkbenchEntry,
meta: { title: "工作台入口" },
},
{
path: DESKTOP_PROJECT_ENTRY_PATH,
name: "DesktopProjectEntry",
component: DesktopProjectEntry,
meta: { title: "选择工作入口" },
@@ -533,6 +548,14 @@ router.beforeEach(async (to, _from, next) => {
next({ path: desktopRedirect });
return;
}
if (isDesktopRuntime && to.path === WEB_WORKBENCH_ENTRY_PATH) {
next({ path: DESKTOP_PROJECT_ENTRY_PATH });
return;
}
if (!isDesktopRuntime && to.path === DESKTOP_PROJECT_ENTRY_PATH) {
next({ path: WEB_WORKBENCH_ENTRY_PATH });
return;
}
const auth = useAuthStore();
const studyStore = useStudyStore();
@@ -559,23 +582,17 @@ router.beforeEach(async (to, _from, next) => {
next({ path: "/login" });
return;
}
if (token && !studyStore.currentStudy && !isDesktopRuntime) {
if (isAdmin) {
await studyStore.ensureDefaultActiveStudy();
} else {
await studyStore.ensureDefaultStudy();
}
}
const workbenchEntryPath = resolveWorkbenchEntryPath(isDesktopRuntime);
if (token && studyStore.currentStudy && auth.user?.email) {
studyStore.rememberCurrentStudyForUser(auth.user.email);
}
if (isDesktopRuntime && token && to.path === "/desktop/project-entry" && studyStore.currentStudy) {
if (token && isWorkbenchEntryPath(to.path) && studyStore.currentStudy) {
studyStore.clearCurrentStudy();
}
if (isDesktopRuntime && token && !isAdmin && to.path.startsWith("/admin")) {
next({ path: "/desktop/project-entry" });
next({ path: DESKTOP_PROJECT_ENTRY_PATH });
return;
}
@@ -584,28 +601,16 @@ router.beforeEach(async (to, _from, next) => {
}
if (isDesktopRuntime && token && to.path === "/") {
next({ path: studyStore.currentStudy ? "/project/overview" : "/desktop/project-entry" });
next({ path: studyStore.currentStudy ? "/project/overview" : DESKTOP_PROJECT_ENTRY_PATH });
return;
}
if (isAdmin && to.path === "/") {
next({ path: studyStore.currentStudy ? "/project/overview" : "/admin/users" });
if (token && to.path === "/") {
next({ path: studyStore.currentStudy ? "/project/overview" : workbenchEntryPath });
return;
}
if ((to.path === "/login" || to.path === "/register") && token) {
if (!auth.forceLogin) {
if (isDesktopRuntime) {
next({ path: "/desktop/project-entry" });
return;
}
next({
path: isAdmin
? studyStore.currentStudy
? "/project/overview"
: "/admin/users"
: studyStore.currentStudy
? "/project/overview"
: "/admin/projects",
});
next({ path: workbenchEntryPath });
return;
}
}
@@ -668,7 +673,7 @@ router.beforeEach(async (to, _from, next) => {
}
}
if (to.meta.requiresStudy && !studyStore.currentStudy) {
next({ path: isDesktopRuntime ? "/desktop/project-entry" : isAdmin ? "/admin/users" : "/admin/projects" });
next({ path: workbenchEntryPath });
return;
}
if (to.meta.requiresStudy && studyStore.currentStudy) {
@@ -25,5 +25,7 @@ describe("DesktopProjectEntry", () => {
expect(source).toContain("findFirstAccessibleProjectPath");
expect(source).toContain("当前账号暂无该项目可访问模块");
expect(source).toContain("forceLogout(LOGOUT_REASON_MANUAL)");
expect(source).not.toContain("Web Workbench");
expect(source).not.toContain("PROJECT ADMIN");
});
});
+1 -1
View File
@@ -152,7 +152,7 @@
import { computed, onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
import { ArrowRight, Monitor, SwitchButton, Refresh } from "@element-plus/icons-vue";
import { ArrowRight, Monitor, SwitchButton } from "@element-plus/icons-vue";
import { fetchStudies } from "../api/studies";
import { TEXT } from "../locales";
import { forceLogout, LOGOUT_REASON_MANUAL } from "../session/sessionManager";
+8 -6
View File
@@ -66,19 +66,21 @@ describe("Login protocol agreement", () => {
expect(source).not.toMatch(/sessionStorage\.setItem\([^)]*password/i);
});
it("sends desktop logins to the entry chooser without restoring a project in the login view", () => {
it("sends logins to the entry chooser without restoring a project in the login view", () => {
const source = readLoginView();
const loginCallIndex = source.indexOf("auth.login(form.email, form.password, { restoreStudy: !isDesktopLogin })");
const entryPathIndex = source.indexOf('const entryPath = isDesktopLogin ? "/desktop/project-entry" : "/workbench";');
const loginCallIndex = source.indexOf("auth.login(form.email, form.password, { restoreStudy: false })");
const clearIndex = source.indexOf("studyStore.clearCurrentStudy()");
const desktopEntryRouteIndex = source.indexOf('router.push("/desktop/project-entry")');
const projectOverviewRouteIndex = source.indexOf('router.push("/project/overview")');
const entryRouteIndex = source.indexOf("router.push(entryPath)");
expect(source).toContain("const isDesktopLogin = showDesktopServerSettings");
expect(entryPathIndex).toBeGreaterThan(-1);
expect(loginCallIndex).toBeGreaterThan(-1);
expect(entryPathIndex).toBeLessThan(loginCallIndex);
expect(clearIndex).toBeGreaterThan(loginCallIndex);
expect(desktopEntryRouteIndex).toBeGreaterThan(clearIndex);
expect(desktopEntryRouteIndex).toBeLessThan(projectOverviewRouteIndex);
expect(entryRouteIndex).toBeGreaterThan(clearIndex);
expect(source).not.toContain("studyStore.restoreStudyForUser(userKey");
expect(source).not.toContain('router.push("/project/overview")');
});
it("shows persistent logout reason notices on the login card", () => {
+3 -10
View File
@@ -458,18 +458,11 @@ const onSubmit = async () => {
try {
const studyStore = useStudyStore();
const isDesktopLogin = showDesktopServerSettings;
await auth.login(form.email, form.password, { restoreStudy: !isDesktopLogin });
const entryPath = isDesktopLogin ? "/desktop/project-entry" : "/workbench";
await auth.login(form.email, form.password, { restoreStudy: false });
await syncRememberedCredential();
if (isDesktopLogin) {
studyStore.clearCurrentStudy();
router.push("/desktop/project-entry");
return;
}
if (studyStore.currentStudy) {
router.push("/project/overview");
} else {
router.push(auth.user?.is_admin ? "/admin/users" : "/admin/projects");
}
await router.push(entryPath);
} catch (error: any) {
const status = error?.response?.status;
const detail: string = error?.response?.data?.detail || error?.response?.data?.message || "";
@@ -0,0 +1,31 @@
import { describe, expect, it } from "vitest";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
const readEntryView = () => readFileSync(resolve(__dirname, "./WebWorkbenchEntry.vue"), "utf8");
describe("WebWorkbenchEntry", () => {
it("keeps the web login entry flow aligned with desktop without importing desktop runtime APIs", () => {
const source = readEntryView();
expect(source).toContain("Web Workspace");
expect(source).toContain("选择项目或进入管理界面");
expect(source).toContain("工作台操作规则");
expect(source).toContain("登录后进入工作台");
expect(source).toContain("换项目先回工作台");
expect(source).toContain("项目内不直接切换项目");
expect(source).toContain("项目工作区");
expect(source).toContain("fetchStudies()");
expect(source).toContain("studyStore.clearCurrentStudy()");
expect(source).toContain('router.push(isAdmin.value ? "/admin/users" : "/admin/projects")');
expect(source).toContain("studyStore.setCurrentStudy(project)");
expect(source).toContain("studyStore.loadCurrentStudyPermissions()");
expect(source).toContain("findFirstAccessibleProjectPath");
expect(source).toContain("当前账号暂无该项目可访问模块");
expect(source).toContain("forceLogout(LOGOUT_REASON_MANUAL)");
expect(source).not.toContain("isTauriRuntime");
expect(source).not.toContain("@tauri-apps");
expect(source).not.toContain("data-tauri-drag-region");
expect(source).not.toContain("Desktop Workbench");
});
});
File diff suppressed because it is too large Load Diff
+8 -6
View File
@@ -69,13 +69,15 @@ describe("project management access", () => {
const source = readProjects();
expect(source).toContain('class="project-table" style="width: 100%" table-layout="fixed"');
expect(source).toContain(':label="TEXT.common.fields.projectName"');
expect(source).toContain(`:label="TEXT.common.fields.protocolNo || '方案号'" show-overflow-tooltip`);
expect(source).toContain(':label="TEXT.common.fields.status" align="center"');
expect(source).toContain('label="锁定状态" align="center"');
expect(source).toContain(':label="TEXT.common.labels.actions" align="center"');
expect(source).toContain(':label="TEXT.common.fields.projectName" min-width="260"');
expect(source).toContain(`:label="TEXT.common.fields.protocolNo || '方案号'" min-width="220" show-overflow-tooltip`);
expect(source).toContain('v-if="!isAdmin" label="我的角色" align="center" width="120"');
expect(source).toContain(':label="TEXT.common.fields.status" align="center" width="150"');
expect(source).toContain('label="锁定状态" align="center" width="150"');
expect(source).toContain(':label="TEXT.common.labels.actions" align="center" width="300" fixed="right"');
expect(source).not.toContain('projectColumnWidth');
expect(source).not.toContain('fixed="right"');
expect(source).toContain("min-width: 252px;");
expect(source).toContain("min-width: 1060px;");
});
it("keeps the project summary header compact", () => {
+14 -7
View File
@@ -64,7 +64,7 @@
<!-- 项目表格 -->
<div class="unified-section project-table-section">
<el-table :data="projects" v-loading="loading" class="project-table" style="width: 100%" table-layout="fixed">
<el-table-column :label="TEXT.common.fields.projectName">
<el-table-column :label="TEXT.common.fields.projectName" min-width="260">
<template #default="scope">
<div class="project-cell">
<div class="project-icon" :class="'icon--' + (scope.row.status || 'draft').toLowerCase()">
@@ -80,17 +80,17 @@
</div>
</template>
</el-table-column>
<el-table-column :label="TEXT.common.fields.protocolNo || '方案号'" show-overflow-tooltip>
<el-table-column :label="TEXT.common.fields.protocolNo || '方案号'" min-width="220" show-overflow-tooltip>
<template #default="scope">
<span class="text-muted">{{ scope.row.protocol_no || '-' }}</span>
</template>
</el-table-column>
<el-table-column v-if="!isAdmin" label="我的角色" align="center">
<el-table-column v-if="!isAdmin" label="我的角色" align="center" width="120">
<template #default="scope">
<span class="role-badge">{{ roleLabel(scope.row.role_in_study) || '-' }}</span>
</template>
</el-table-column>
<el-table-column :label="TEXT.common.fields.status" align="center">
<el-table-column :label="TEXT.common.fields.status" align="center" width="150">
<template #default="scope">
<span class="status-badge" :class="'badge--' + (scope.row.status || 'draft').toLowerCase()">
<span class="badge-dot"></span>
@@ -98,7 +98,7 @@
</span>
</template>
</el-table-column>
<el-table-column label="锁定状态" align="center">
<el-table-column label="锁定状态" align="center" width="150">
<template #default="scope">
<span v-if="scope.row.is_locked" class="lock-indicator locked">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="13" height="13">
@@ -116,7 +116,7 @@
</span>
</template>
</el-table-column>
<el-table-column :label="TEXT.common.labels.actions" align="center">
<el-table-column :label="TEXT.common.labels.actions" align="center" width="300" fixed="right">
<template #default="scope">
<div class="action-row">
<el-tooltip v-if="canProject(scope.row, 'project_members', 'read')" :content="TEXT.modules.adminProjects.members" placement="top">
@@ -541,8 +541,10 @@ onMounted(() => {
.action-row {
display: inline-flex;
align-items: center;
gap: 4px;
justify-content: center;
gap: 4px;
min-width: 252px;
max-width: 100%;
white-space: nowrap;
}
@@ -574,6 +576,11 @@ onMounted(() => {
/* 表格 */
.project-table-section {
padding: 0;
overflow: hidden;
}
.project-table {
min-width: 1060px;
}
.project-table :deep(.el-table__inner-wrapper::before) {