2026-02-10 01:57:11 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<a-dropdown class="project-selector">
|
|
|
|
|
|
<template #overlay>
|
|
|
|
|
|
<a-menu @click="handleMenuClick">
|
|
|
|
|
|
<a-menu-item v-for="item in projectStore.myProjects" :key="item.id">
|
2026-02-26 23:50:15 +08:00
|
|
|
|
<div class="flex items-center justify-between w-full">
|
|
|
|
|
|
<span class="mr-1">{{ item.name }}</span>
|
|
|
|
|
|
<fs-values-format :model-value="item.permission" :dict="projectPermissionDict"></fs-values-format>
|
|
|
|
|
|
</div>
|
2026-02-10 01:57:11 +08:00
|
|
|
|
</a-menu-item>
|
|
|
|
|
|
</a-menu>
|
|
|
|
|
|
</template>
|
2026-02-13 21:28:17 +08:00
|
|
|
|
<div class="rounded pl-3 pr-3 px-2 py-1 flex-center flex pointer items-center bg-accent h-10 button-text" title="当前项目">
|
2026-02-26 23:50:15 +08:00
|
|
|
|
<!-- <fs-icon icon="ion:apps" class="mr-1"></fs-icon> -->
|
|
|
|
|
|
<fs-icon :icon="currentIcon" class="mr-5"></fs-icon>
|
2026-02-13 21:28:17 +08:00
|
|
|
|
当前项目:{{ projectStore.currentProject?.name || "..." }}
|
2026-02-10 01:57:11 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</a-dropdown>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2026-02-26 23:50:15 +08:00
|
|
|
|
import { computed, onMounted } from "vue";
|
2026-02-10 01:57:11 +08:00
|
|
|
|
import { useProjectStore } from "/@/store/project";
|
2026-02-26 23:50:15 +08:00
|
|
|
|
import { useDicts } from "/@/views/certd/dicts";
|
2026-02-10 01:57:11 +08:00
|
|
|
|
defineOptions({
|
|
|
|
|
|
name: "ProjectSelector",
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const projectStore = useProjectStore();
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
await projectStore.reload();
|
2026-02-26 23:50:15 +08:00
|
|
|
|
console.log(projectStore.myProjects);
|
2026-02-10 01:57:11 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function handleMenuClick({ key }: any) {
|
|
|
|
|
|
projectStore.changeCurrentProject(key);
|
2026-02-13 22:24:04 +08:00
|
|
|
|
window.location.reload();
|
2026-02-10 01:57:11 +08:00
|
|
|
|
}
|
2026-02-26 23:50:15 +08:00
|
|
|
|
const { projectPermissionDict } = useDicts();
|
|
|
|
|
|
|
|
|
|
|
|
const currentIcon = computed(() => {
|
|
|
|
|
|
return projectPermissionDict.dataMap[projectStore.currentProject?.permission || ""]?.icon || "";
|
|
|
|
|
|
});
|
2026-02-10 01:57:11 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|
|
|
|
|
|
.project-selector {
|
|
|
|
|
|
&.button-text {
|
2026-02-13 21:28:17 +08:00
|
|
|
|
min-width: 150px;
|
|
|
|
|
|
max-width: 250px;
|
2026-02-10 01:57:11 +08:00
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|