feat(网页端): 完善登录后工作台与项目管理体验
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
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
@@ -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", () => {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user