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
+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>