Commit dd3d61a6 authored by nick zheng's avatar nick zheng

chore(知识库管理): 对接接口&&多语言

parent abf6965e
...@@ -8,6 +8,8 @@ import CreateKnowledgeModal, { ...@@ -8,6 +8,8 @@ import CreateKnowledgeModal, {
} from './personal-knowledge/components/create-knowledge-modal.vue' } from './personal-knowledge/components/create-knowledge-modal.vue'
import CreateDatabaseModal from './personal-database/components/create-database-modal.vue' import CreateDatabaseModal from './personal-database/components/create-database-modal.vue'
import { fetchCreateKnowledge } from '@/apis/knowledge' import { fetchCreateKnowledge } from '@/apis/knowledge'
import { fetchCreateDataBase } from '@/apis/database'
import { DatabaseItemInterface } from './personal-database/type'
const { t } = useI18n() const { t } = useI18n()
...@@ -27,7 +29,7 @@ const personalSpaceModuleList = [ ...@@ -27,7 +29,7 @@ const personalSpaceModuleList = [
}, },
{ {
routeName: 'PersonalSpaceDatabase', routeName: 'PersonalSpaceDatabase',
label: '数据库', label: 'common_module.database',
}, },
] ]
...@@ -44,7 +46,7 @@ const addPersonalSpaceOptions = readonly([ ...@@ -44,7 +46,7 @@ const addPersonalSpaceOptions = readonly([
icon: () => h(NotebookOne, { theme: 'outline', size: 16, fill: '#333' }), icon: () => h(NotebookOne, { theme: 'outline', size: 16, fill: '#333' }),
}, },
{ {
label: () => h('span', {}, '数据库'), label: () => h('span', {}, t('common_module.database')),
key: 'addDatabase', key: 'addDatabase',
icon: () => h(DatabaseSetting, { theme: 'outline', size: 16, fill: '#333' }), icon: () => h(DatabaseSetting, { theme: 'outline', size: 16, fill: '#333' }),
}, },
...@@ -54,6 +56,7 @@ const showCreateKnowledgeModal = ref(false) ...@@ -54,6 +56,7 @@ const showCreateKnowledgeModal = ref(false)
const createKnowledgeBtnLoading = ref(false) const createKnowledgeBtnLoading = ref(false)
const showCreateDatabaseModal = ref(false) const showCreateDatabaseModal = ref(false)
const createDatabaseBtnLoading = ref(false)
watch( watch(
() => currentRoute.fullPath, () => currentRoute.fullPath,
...@@ -102,6 +105,19 @@ async function handleCreateKnowledgeNextStep(createKnowledgeData: KnowledgeFormD ...@@ -102,6 +105,19 @@ async function handleCreateKnowledgeNextStep(createKnowledgeData: KnowledgeFormD
showCreateKnowledgeModal.value = false showCreateKnowledgeModal.value = false
} }
} }
async function handleCreateDatabase(databaseData: Omit<DatabaseItemInterface, 'id' | 'modifiedTime'>) {
createDatabaseBtnLoading.value = true
const res = await fetchCreateDataBase(databaseData).finally(() => {
createDatabaseBtnLoading.value = false
})
if (res.code === 0) {
showCreateDatabaseModal.value = false
router.push({ name: 'PersonalSpaceDatabase' })
}
}
</script> </script>
<template> <template>
...@@ -154,7 +170,11 @@ async function handleCreateKnowledgeNextStep(createKnowledgeData: KnowledgeFormD ...@@ -154,7 +170,11 @@ async function handleCreateKnowledgeNextStep(createKnowledgeData: KnowledgeFormD
@confirm="handleCreateKnowledgeNextStep" @confirm="handleCreateKnowledgeNextStep"
/> />
<CreateDatabaseModal v-model:show-modal="showCreateDatabaseModal" /> <CreateDatabaseModal
v-model:show-modal="showCreateDatabaseModal"
:btn-loading="createDatabaseBtnLoading"
@confirm="handleCreateDatabase"
/>
</div> </div>
</template> </template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment