feat: migrate state from v1 to v2

This commit is contained in:
Yidadaa
2023-04-27 02:00:22 +08:00
parent 401c1364be
commit 30040a0366
8 changed files with 85 additions and 27 deletions

View File

@@ -2,6 +2,7 @@ import { create } from "zustand";
import { persist } from "zustand/middleware";
import Fuse from "fuse.js";
import { getLang } from "../locales";
import { StoreKey } from "../constant";
export interface Prompt {
id?: number;
@@ -23,8 +24,6 @@ export interface PromptStore {
updateUserPrompts: (id: number, updater: (prompt: Prompt) => void) => void;
}
export const PROMPT_KEY = "prompt-store";
export const SearchService = {
ready: false,
builtinEngine: new Fuse<Prompt>([], { keys: ["title"] }),
@@ -123,7 +122,7 @@ export const usePromptStore = create<PromptStore>()(
},
}),
{
name: PROMPT_KEY,
name: StoreKey.Prompt,
version: 1,
onRehydrateStorage(state) {
const PROMPT_URL = "./prompts.json";