feat(avatar): improve multi-avatar management
This commit is contained in:
@@ -79,9 +79,9 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useAvatarStore } from '@/store/avatar'
|
||||
import { pickAvatarId, unwrapListData } from '@/utils/avatar-page-data.js'
|
||||
import { pickScopedAvatarId, unwrapListData } from '@/utils/avatar-page-data.js'
|
||||
import {
|
||||
getKnowledgeDocs,
|
||||
uploadKnowledgeDoc,
|
||||
@@ -93,9 +93,10 @@ import {
|
||||
} from '@/api'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const store = useAvatarStore()
|
||||
|
||||
const avatarId = computed(() => pickAvatarId(store.currentAvatarId, store.avatars))
|
||||
const avatarId = computed(() => pickScopedAvatarId(route.params.avatarId, store.currentAvatarId, store.avatars))
|
||||
const activeTab = ref<'docs' | 'qa'>('docs')
|
||||
|
||||
const docs = ref<any[]>([])
|
||||
@@ -200,9 +201,21 @@ const toggleQa = async (qa: any, e: Event) => {
|
||||
}
|
||||
}
|
||||
|
||||
const goAddQa = () => router.push('/knowledge/qa/create')
|
||||
const goAddQa = () => {
|
||||
if (route.params.avatarId && avatarId.value) {
|
||||
router.push({ name: 'AvatarQaPairCreate', params: { avatarId: avatarId.value } })
|
||||
return
|
||||
}
|
||||
router.push('/knowledge/qa/create')
|
||||
}
|
||||
|
||||
const goEditQa = (qa: any) => router.push(`/knowledge/qa/${qa.id}/edit`)
|
||||
const goEditQa = (qa: any) => {
|
||||
if (route.params.avatarId && avatarId.value) {
|
||||
router.push({ name: 'AvatarQaPairEdit', params: { avatarId: avatarId.value, qaId: qa.id } })
|
||||
return
|
||||
}
|
||||
router.push(`/knowledge/qa/${qa.id}/edit`)
|
||||
}
|
||||
|
||||
const removeQa = async (id: string) => {
|
||||
if (!avatarId.value) return
|
||||
@@ -226,6 +239,7 @@ onMounted(async () => {
|
||||
if (!store.avatars.length) {
|
||||
await store.loadAvatars()
|
||||
}
|
||||
if (avatarId.value) store.currentAvatarId = avatarId.value
|
||||
await Promise.all([loadDocs(), loadQA()])
|
||||
})
|
||||
</script>
|
||||
@@ -234,7 +248,7 @@ onMounted(async () => {
|
||||
.knowledge-page {
|
||||
min-height: 100vh;
|
||||
background: #F8F9FA;
|
||||
padding-bottom: 80px;
|
||||
padding-bottom: calc(28px + env(safe-area-inset-bottom));
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user