diff --git a/app/pages/store.vue b/app/pages/store.vue
index ea0defe..d7c8bfc 100644
--- a/app/pages/store.vue
+++ b/app/pages/store.vue
@@ -3,29 +3,23 @@
title="Store"
description="Persistent key-value store. Allows you to handle state to a file which can be saved and loaded on demand including between app restarts."
>
-
+
+
+
+
+
+
+
+ Set value
+
+
+
+
+
+
+
+
+
@@ -35,8 +29,22 @@
icon: "lucide:database"
});
- const input = ref("");
- const result = ref("");
+ const schema = z.object({
+ value: z.string({
+ required_error: "Store key is required"
+ }).nonempty()
+ });
+
+ type Schema = zInfer;
+
+ const inputState = ref>({
+ value: undefined
+ });
+ const outputState = ref({
+ content: ""
+ });
+
+ const toast = useToast();
const autosave = ref(false);
const store = await useTauriStoreLoad("store.bin", {
@@ -45,9 +53,14 @@
const getStoreValue = async () => {
try {
- result.value = await store.get("myData") || "";
+ outputState.value.content = await store.get("myData") || "";
} catch (error) {
- result.value = JSON.stringify(error, null, 4);
+ toast.add({
+ title: "Error",
+ description: String(error),
+ color: "error"
+ });
+ outputState.value.content = JSON.stringify(error, null, 4);
}
};
@@ -55,12 +68,22 @@
const setStoreValue = async () => {
try {
- await store.set("myData", input.value);
+ await store.set("myData", inputState.value!.value);
await getStoreValue();
+ toast.add({
+ title: "Success",
+ description: "Store value retieved",
+ color: "success"
+ });
} catch (error) {
- result.value = JSON.stringify(error, null, 4);
+ toast.add({
+ title: "Error",
+ description: String(error),
+ color: "error"
+ });
+ outputState.value.content = JSON.stringify(error, null, 4);
} finally {
- input.value = "";
+ inputState.value.value = undefined;
}
};