feat(workspace): 增强工作区侧边栏,新增快速访问功能并优化路径选择逻辑
This commit is contained in:
parent
874767d4bd
commit
9ff925e4df
@ -4,7 +4,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="workspace-nav-item"
|
||||
:class="{ active: activeKey === 'personal' }"
|
||||
:class="{ active: activeKey === 'personal' && currentPath !== savedArtifactsPath }"
|
||||
@click="$emit('select-personal')"
|
||||
>
|
||||
<FolderKanban :size="16" />
|
||||
@ -12,6 +12,19 @@
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section class="sidebar-section">
|
||||
<div class="section-title">快速访问</div>
|
||||
<button
|
||||
type="button"
|
||||
class="workspace-nav-item secondary"
|
||||
:class="{ active: activeKey === 'personal' && currentPath === savedArtifactsPath }"
|
||||
@click="$emit('select-path', savedArtifactsPath)"
|
||||
>
|
||||
<Archive :size="15" />
|
||||
<span>Saved Artifacts</span>
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<section class="sidebar-section">
|
||||
<div class="section-title">知识库</div>
|
||||
<button
|
||||
@ -41,15 +54,18 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { FolderKanban, LibraryBig, UsersRound } from 'lucide-vue-next'
|
||||
import { Archive, FolderKanban, LibraryBig, UsersRound } from 'lucide-vue-next'
|
||||
|
||||
const savedArtifactsPath = '/saved_artifacts'
|
||||
|
||||
defineProps({
|
||||
activeKey: { type: String, default: 'personal' },
|
||||
currentPath: { type: String, default: '/' },
|
||||
databases: { type: Array, default: () => [] },
|
||||
loadingDatabases: { type: Boolean, default: false }
|
||||
})
|
||||
|
||||
defineEmits(['select-personal', 'select-database'])
|
||||
defineEmits(['select-personal', 'select-database', 'select-path'])
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
@ -25,10 +25,12 @@
|
||||
</button>
|
||||
<WorkspaceSidebar
|
||||
:active-key="activeSourceKey"
|
||||
:current-path="currentPath"
|
||||
:databases="databases"
|
||||
:loading-databases="loadingDatabases"
|
||||
@select-personal="selectPersonalWorkspace"
|
||||
@select-database="selectDatabase"
|
||||
@select-path="selectWorkspacePath"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
@ -268,12 +270,21 @@ const loadDatabases = async () => {
|
||||
const selectPersonalWorkspace = async () => {
|
||||
activeSourceKey.value = 'personal'
|
||||
selectedDatabase.value = null
|
||||
closePreview()
|
||||
clearWorkspaceSelection()
|
||||
if (!entries.value.length) {
|
||||
await loadWorkspaceEntries(currentPath.value)
|
||||
if (currentPath.value !== '/' || !entries.value.length) {
|
||||
await loadWorkspaceEntries('/')
|
||||
}
|
||||
}
|
||||
|
||||
const selectWorkspacePath = async (path) => {
|
||||
activeSourceKey.value = 'personal'
|
||||
selectedDatabase.value = null
|
||||
closePreview()
|
||||
clearWorkspaceSelection()
|
||||
await loadWorkspaceEntries(path)
|
||||
}
|
||||
|
||||
const selectDatabase = (database) => {
|
||||
closePreview()
|
||||
clearWorkspaceSelection()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user