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