2022-12-22 02:12:37 +00:00
|
|
|
import { Store } from 'tauri-plugin-store-api'
|
2024-09-30 09:11:56 +01:00
|
|
|
import { createStorage } from 'unstorage'
|
2022-12-22 02:12:37 +00:00
|
|
|
|
|
|
|
const store = new Store('.servers.dat')
|
|
|
|
const storage = createStorage()
|
|
|
|
storage.mount('servers', {
|
|
|
|
getKeys() {
|
|
|
|
return store.keys()
|
|
|
|
},
|
|
|
|
async removeItem(key: string) {
|
|
|
|
await store.delete(key)
|
|
|
|
},
|
|
|
|
clear() {
|
|
|
|
return store.clear()
|
|
|
|
},
|
|
|
|
hasItem(key: string) {
|
|
|
|
return store.has(key)
|
|
|
|
},
|
|
|
|
setItem(key: string, value: any) {
|
|
|
|
return store.set(key, value)
|
|
|
|
},
|
|
|
|
getItem(key: string) {
|
|
|
|
return store.get(key)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2023-03-30 20:01:24 +01:00
|
|
|
export function useStorage() {
|
|
|
|
return storage
|
|
|
|
}
|