UnisKB/ui/src/layout/components/sidebar/index.vue

183 lines
7.4 KiB
Vue
Raw Normal View History

2026-03-12 08:17:02 +00:00
<template>
<div
class="sidebar"
style="display: flex; flex-direction: column; height: 100%; background-color: #f9fafb; width: 240px;"
>
<div style="padding: 16px;"></div>
<div style="padding: 0 16px;">
<div v-if="!isSystemManagement" style="display: flex; flex-direction: column; gap: 8px;">
2026-03-12 08:17:02 +00:00
<router-link
to="/application"
style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;"
:style="activeMainMenu === '/application' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
AI应用
</router-link>
2026-03-12 08:17:02 +00:00
<router-link
to="/mindmap"
style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;"
:style="activeMainMenu === '/mindmap' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
思维导图
</router-link>
2026-03-12 08:17:02 +00:00
<router-link
to="/knowledge"
style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;"
:style="activeMainMenu === '/knowledge' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
知识库
</router-link>
2026-03-12 08:17:02 +00:00
<router-link
to="/tool"
style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;"
:style="activeMainMenu === '/tool' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
工具管理
</router-link>
2026-03-12 08:17:02 +00:00
<router-link
to="/model"
style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;"
:style="activeMainMenu === '/model' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
模型管理
</router-link>
</div>
<div v-else style="display: flex; flex-direction: column; gap: 8px;">
2026-03-12 08:17:02 +00:00
<router-link
to="/system/user"
style="display: block; padding: 10px 16px; border-radius: 8px; text-decoration: none; color: #333; font-size: 14px;"
:style="activeSystemMenu === '/system/user' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
用户管理
</router-link>
<div>
2026-03-12 08:17:02 +00:00
<div
style="display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-radius: 8px; cursor: pointer;"
:style="activeSystemMenu.startsWith('/system/authorization') ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
@click="toggleResourceAuth"
>
<span>资源授权</span>
2026-03-12 08:17:02 +00:00
<span>{{ resourceAuthExpanded ? '▾' : '▸' }}</span>
</div>
2026-03-12 08:17:02 +00:00
<div
v-if="resourceAuthExpanded"
style="padding-left: 32px; margin-top: 4px; display: flex; flex-direction: column; gap: 4px;"
>
<router-link
to="/system/authorization/application"
style="display: block; padding: 8px 16px; border-radius: 8px; text-decoration: none; color: #666; font-size: 13px;"
:style="activeSystemMenu === '/system/authorization/application' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
AI应用
</router-link>
2026-03-12 08:17:02 +00:00
<router-link
to="/system/authorization/knowledge"
style="display: block; padding: 8px 16px; border-radius: 8px; text-decoration: none; color: #666; font-size: 13px;"
:style="activeSystemMenu === '/system/authorization/knowledge' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
知识库
</router-link>
2026-03-12 08:17:02 +00:00
<router-link
to="/system/authorization/tool"
style="display: block; padding: 8px 16px; border-radius: 8px; text-decoration: none; color: #666; font-size: 13px;"
:style="activeSystemMenu === '/system/authorization/tool' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
工具管理
</router-link>
2026-03-12 08:17:02 +00:00
<router-link
to="/system/authorization/model"
style="display: block; padding: 8px 16px; border-radius: 8px; text-decoration: none; color: #666; font-size: 13px;"
:style="activeSystemMenu === '/system/authorization/model' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
模型管理
</router-link>
</div>
</div>
<div>
2026-03-12 08:17:02 +00:00
<div
style="display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-radius: 8px; cursor: pointer;"
:style="activeSystemMenu.startsWith('/system/email') ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
@click="toggleSystemSettings"
>
<span>系统设置</span>
2026-03-12 08:17:02 +00:00
<span>{{ systemSettingsExpanded ? '▾' : '▸' }}</span>
</div>
2026-03-12 08:17:02 +00:00
<div
v-if="systemSettingsExpanded"
style="padding-left: 32px; margin-top: 4px; display: flex; flex-direction: column; gap: 4px;"
>
<router-link
to="/system/email"
style="display: block; padding: 8px 16px; border-radius: 8px; text-decoration: none; color: #666; font-size: 13px;"
:style="activeSystemMenu === '/system/email' ? { backgroundColor: '#e6f0ff', color: '#1890ff' } : {}"
>
邮件设置
</router-link>
</div>
</div>
</div>
</div>
<div style="margin-top: auto; padding: 16px; border-top: 1px solid #e5e7eb;">
<UserAvatar />
2025-06-19 10:54:02 +00:00
</div>
2025-04-28 07:23:25 +00:00
</div>
</template>
<script setup lang="ts">
2026-03-12 08:17:02 +00:00
import { computed, onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import UserAvatar from '@/layout/layout-header/avatar/index.vue'
2025-04-28 07:23:25 +00:00
const route = useRoute()
const isSystemManagement = computed(() => {
const path = route.path
2026-03-12 08:17:02 +00:00
return path.startsWith('/system') || path.startsWith('/admin/system')
})
const activeMainMenu = computed(() => {
const path = route.path
if (path.startsWith('/application')) return '/application'
if (path.startsWith('/mindmap')) return '/mindmap'
if (path.startsWith('/knowledge')) return '/knowledge'
if (path.startsWith('/tool')) return '/tool'
if (path.startsWith('/model')) return '/model'
return '/application'
2025-04-28 07:23:25 +00:00
})
const activeSystemMenu = computed(() => {
const path = route.path
2026-03-12 08:17:02 +00:00
if (path.startsWith('/system/user') || path.startsWith('/admin/system/user')) return '/system/user'
if (path.startsWith('/system/authorization') || path.startsWith('/admin/system/authorization')) {
return path.replace('/admin', '')
}
if (path.startsWith('/system/email') || path.startsWith('/admin/system/email')) {
return path.replace('/admin', '')
}
return '/system/user'
})
const resourceAuthExpanded = ref(false)
const systemSettingsExpanded = ref(false)
const toggleResourceAuth = () => {
resourceAuthExpanded.value = !resourceAuthExpanded.value
systemSettingsExpanded.value = false
}
const toggleSystemSettings = () => {
systemSettingsExpanded.value = !systemSettingsExpanded.value
resourceAuthExpanded.value = false
}
onMounted(() => {
resourceAuthExpanded.value = false
systemSettingsExpanded.value = false
})
2025-04-28 07:23:25 +00:00
</script>