summaryrefslogtreecommitdiffhomepage
path: root/packages/tauri/src
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-12-17 13:10:57 -0600
committerAdam <[email protected]>2025-12-17 13:11:02 -0600
commit4a3ba58f65d12b4f7c7a97b42a5bb3bc0eb5f88b (patch)
treeabae119fe310b1c73fc0d70d9d0d81985c5def42 /packages/tauri/src
parent2a3a8a1ec2d71ae27730226cfac37830c7a5dfd7 (diff)
downloadopencode-4a3ba58f65d12b4f7c7a97b42a5bb3bc0eb5f88b.tar.gz
opencode-4a3ba58f65d12b4f7c7a97b42a5bb3bc0eb5f88b.zip
chore: localStorage -> tauri store
Diffstat (limited to 'packages/tauri/src')
-rw-r--r--packages/tauri/src/index.tsx18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/tauri/src/index.tsx b/packages/tauri/src/index.tsx
index 01df8166a..c77058eb9 100644
--- a/packages/tauri/src/index.tsx
+++ b/packages/tauri/src/index.tsx
@@ -5,6 +5,7 @@ import { onMount } from "solid-js"
import { open, save } from "@tauri-apps/plugin-dialog"
import { open as shellOpen } from "@tauri-apps/plugin-shell"
import { type as ostype } from "@tauri-apps/plugin-os"
+import { AsyncStorage } from "@solid-primitives/storage"
import { runUpdater, UPDATER_ENABLED } from "./updater"
import { createMenu } from "./menu"
@@ -48,6 +49,23 @@ const platform: Platform = {
openLink(url: string) {
shellOpen(url)
},
+
+ storage: (name = "default.dat") => {
+ const api: AsyncStorage = {
+ _store: null,
+ _getStore: async () => api._store || (api._store = (await import("@tauri-apps/plugin-store")).Store.load(name)),
+ getItem: async (key: string) => (await (await api._getStore()).get(key)) ?? null,
+ setItem: async (key: string, value: string) => await (await api._getStore()).set(key, value),
+ removeItem: async (key: string) => await (await api._getStore()).delete(key),
+ clear: async () => await (await api._getStore()).clear(),
+ key: async (index: number) => (await (await api._getStore()).keys())[index],
+ getLength: async () => (await api._getStore()).length(),
+ get length() {
+ return api.getLength()
+ },
+ }
+ return api
+ },
}
createMenu()