fix: 修复原本 store 中的 refreshDatabase 失败的问题
This commit is contained in:
parent
b4be4c0021
commit
be3adf7b9d
@ -1,5 +1,6 @@
|
|||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
import { knowledgeBaseApi } from '@/apis/admin_api'
|
||||||
|
|
||||||
export const useDatabaseStore = defineStore('database', () => {
|
export const useDatabaseStore = defineStore('database', () => {
|
||||||
const db = ref({})
|
const db = ref({})
|
||||||
@ -7,11 +8,10 @@ export const useDatabaseStore = defineStore('database', () => {
|
|||||||
db.value = newDatabase
|
db.value = newDatabase
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshDatabase() {
|
async function refreshDatabase() {
|
||||||
fetch('/api/data').then(res => res.json()).then(data => {
|
const res = await knowledgeBaseApi.getDatabases()
|
||||||
console.log("database", data)
|
console.log("database", res)
|
||||||
setDatabase(data.databases)
|
setDatabase(res.databases)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { db, setDatabase, refreshDatabase }
|
return { db, setDatabase, refreshDatabase }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user