UnisKB/ui/src/components/workspace-dropdown/index.vue

66 lines
1.8 KiB
Vue
Raw Normal View History

2025-06-13 09:38:37 +00:00
<template>
2025-06-20 09:02:42 +00:00
<el-dropdown placement="bottom-start" class="workspace-dropdown">
<el-button text style="font-size: 14px" class="workspace-dropdown__button">
2025-06-26 08:36:08 +00:00
<AppIcon iconName="app-workspace" style="font-size: 18px"></AppIcon>
2025-06-20 09:02:42 +00:00
<span class="ellipsis" style="max-width: 155px">
2025-06-13 09:38:37 +00:00
{{ currentWorkspace?.name }}
</span>
<el-icon class="el-icon--right">
<CaretBottom />
</el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu v-loading="loading">
2025-06-17 10:38:00 +00:00
<el-dropdown-item
2025-06-20 10:10:32 +00:00
v-for="item in data"
2025-06-17 10:38:00 +00:00
:key="item.id"
:class="item.id === currentWorkspace?.id ? 'active' : ''"
@click="changeWorkspace(item)"
>
2025-06-26 08:36:08 +00:00
<AppIcon class="mr-8" iconName="app-workspace" style="font-size: 16px"></AppIcon>
2025-06-20 09:02:42 +00:00
<span class="ellipsis" style="max-width: 230px">
2025-06-13 09:38:37 +00:00
{{ item.name }}
</span>
2025-06-17 10:38:00 +00:00
<el-icon
v-show="item.id === currentWorkspace?.id"
class="ml-8"
style="font-size: 16px; margin-right: 0"
>
2025-06-13 09:38:37 +00:00
<Check />
</el-icon>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
<script setup lang="ts">
2025-06-19 13:43:57 +00:00
import { computed, ref } from 'vue'
2025-06-13 09:38:37 +00:00
import type { WorkspaceItem } from '@/api/type/workspace'
2025-06-19 13:43:57 +00:00
2025-06-20 10:10:32 +00:00
const props = defineProps({
data: {
type: Array,
default: () => [],
},
currentWorkspace: {
type: Object,
default: () => {},
},
2025-06-13 09:38:37 +00:00
})
2025-06-20 10:10:32 +00:00
const loading = ref(false)
const emit = defineEmits(['changeWorkspace'])
2025-06-13 09:38:37 +00:00
function changeWorkspace(item: WorkspaceItem) {
2025-06-20 10:10:32 +00:00
emit('changeWorkspace', item)
2025-06-13 09:38:37 +00:00
}
</script>
<style lang="scss" scoped>
2025-06-20 09:02:42 +00:00
.workspace-dropdown {
&__button {
font-size: 14px;
padding: 0 12px !important;
max-height: 32px;
}
2025-06-13 09:38:37 +00:00
}
2025-06-13 10:31:22 +00:00
</style>