2024-07-28 16:16:52 +08:00
|
|
|
import { ref, computed } from 'vue'
|
|
|
|
|
import { defineStore } from 'pinia'
|
2025-07-22 17:29:38 +08:00
|
|
|
import { databaseApi } from '@/apis/knowledge_api'
|
2024-07-28 16:16:52 +08:00
|
|
|
|
|
|
|
|
export const useDatabaseStore = defineStore('database', () => {
|
|
|
|
|
const db = ref({})
|
|
|
|
|
function setDatabase(newDatabase) {
|
|
|
|
|
db.value = newDatabase
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-27 01:48:55 +08:00
|
|
|
async function refreshDatabase() {
|
2025-07-22 17:29:38 +08:00
|
|
|
const res = await databaseApi.getDatabases()
|
2025-06-27 01:48:55 +08:00
|
|
|
console.log("database", res)
|
|
|
|
|
setDatabase(res.databases)
|
2024-10-24 13:09:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { db, setDatabase, refreshDatabase }
|
2024-07-28 16:16:52 +08:00
|
|
|
})
|