2024-07-28 16:16:52 +08:00
|
|
|
import { ref, computed } from 'vue'
|
|
|
|
|
import { defineStore } from 'pinia'
|
|
|
|
|
|
|
|
|
|
export const useDatabaseStore = defineStore('database', () => {
|
|
|
|
|
const db = ref({})
|
|
|
|
|
function setDatabase(newDatabase) {
|
|
|
|
|
db.value = newDatabase
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-24 13:09:59 +08:00
|
|
|
function refreshDatabase() {
|
|
|
|
|
fetch('/api/data').then(res => res.json()).then(data => {
|
|
|
|
|
console.log("database", data)
|
|
|
|
|
setDatabase(data.databases)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { db, setDatabase, refreshDatabase }
|
2024-07-28 16:16:52 +08:00
|
|
|
})
|