fix: 修复原本 store 中的 refreshDatabase 失败的问题

This commit is contained in:
Wenjie Zhang 2025-06-27 01:48:55 +08:00
parent b4be4c0021
commit be3adf7b9d

View File

@ -1,5 +1,6 @@
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { knowledgeBaseApi } from '@/apis/admin_api'
export const useDatabaseStore = defineStore('database', () => {
const db = ref({})
@ -7,11 +8,10 @@ export const useDatabaseStore = defineStore('database', () => {
db.value = newDatabase
}
function refreshDatabase() {
fetch('/api/data').then(res => res.json()).then(data => {
console.log("database", data)
setDatabase(data.databases)
})
async function refreshDatabase() {
const res = await knowledgeBaseApi.getDatabases()
console.log("database", res)
setDatabase(res.databases)
}
return { db, setDatabase, refreshDatabase }