Merge branch 'dev' into codex/desktop-ui-stabilization

# Conflicts:
#	frontend/src/views/admin/Projects.test.ts
#	frontend/src/views/admin/Projects.vue
This commit is contained in:
Cheng Zhou
2026-07-09 15:41:13 +08:00
16 changed files with 1459 additions and 194 deletions
@@ -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", () => {
+4 -11
View File
@@ -446,18 +446,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");
}
studyStore.clearCurrentStudy();
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
+13 -11
View File
@@ -16,7 +16,8 @@ describe("project management access", () => {
const layout = readLayout();
const router = readRouter();
expect(layout).toContain('v-if="auth.user"');
expect(layout).toContain('v-if="showAdminNavigation"');
expect(layout).toContain("const showAdminNavigation = computed(() => Boolean(auth.user)");
expect(layout).toContain('index="/admin/projects"');
expect(router).toContain('name: "AdminProjects"');
expect(router).toContain("meta: { title: TEXT.menu.projectManagement }");
@@ -69,21 +70,22 @@ 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" width="320" class-name="project-actions-column"');
expect(source).not.toContain('projectColumnWidth');
expect(source).not.toContain('fixed="right"');
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).toContain("min-width: 252px;");
expect(source).toContain("min-width: 1060px;");
});
it("reserves enough width for the densest project action set", () => {
const source = readProjects();
expect(source).toContain('width="320" class-name="project-actions-column"');
expect(source).toContain(".project-table :deep(.project-actions-column .cell)");
expect(source).toContain("overflow: visible;");
expect(source).toContain('width="300" fixed="right"');
expect(source).toContain("min-width: 252px;");
expect(source).toContain("min-width: 1060px;");
});
it("keeps the project summary header compact", () => {
+14 -11
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" width="320" class-name="project-actions-column">
<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,16 +576,17 @@ onMounted(() => {
/* 表格 */
.project-table-section {
padding: 0;
overflow: hidden;
}
.project-table {
min-width: 1060px;
}
.project-table :deep(.el-table__inner-wrapper::before) {
display: none;
}
.project-table :deep(.project-actions-column .cell) {
overflow: visible;
}
@media (max-width: 768px) {
.stats-row {
grid-template-columns: repeat(2, 1fr);
+36
View File
@@ -350,6 +350,18 @@ onBeforeUnmount(() => {
</script>
<style scoped>
.page,
.main-content-flat,
.user-table-section {
min-width: 0;
box-sizing: border-box;
}
.main-content-flat {
width: 100%;
max-width: 100%;
}
.stats-row {
display: grid;
grid-template-columns: repeat(3, 1fr);
@@ -427,19 +439,24 @@ onBeforeUnmount(() => {
width: 100%;
gap: 10px;
align-items: center;
min-width: 0;
flex-wrap: wrap;
}
.filter-item-form {
margin-bottom: 0 !important;
margin-right: 0 !important;
min-width: 0;
}
.filter-input-comp {
width: 220px;
max-width: 100%;
}
.filter-spacer {
flex: 1;
min-width: 0;
}
/* 用户单元格 */
@@ -546,12 +563,18 @@ onBeforeUnmount(() => {
/* 表格区域 */
.user-table-section {
padding: 0;
max-width: 100%;
overflow-x: hidden;
}
.user-table :deep(.el-table__inner-wrapper::before) {
display: none;
}
.user-table :deep(.el-scrollbar__bar.is-horizontal) {
display: none;
}
.user-table :deep(th.el-table__cell) {
padding-top: 10px;
padding-bottom: 10px;
@@ -567,11 +590,24 @@ onBeforeUnmount(() => {
display: flex;
justify-content: flex-end;
padding: 8px 16px;
max-width: 100%;
overflow: hidden;
}
.pagination-wrap :deep(.el-pagination) {
min-width: 0;
flex-wrap: wrap;
justify-content: flex-end;
row-gap: 6px;
}
@media (max-width: 768px) {
.stats-row {
grid-template-columns: repeat(2, 1fr);
}
.filter-spacer {
display: none;
}
}
</style>