fix(timer): interval-store

This commit is contained in:
zhangheng
2026-04-08 17:13:15 +08:00
parent 8c18cc2b78
commit 8a2bc25c8d

View File

@@ -1,4 +1,5 @@
import { create } from "zustand" import { create } from "zustand"
import { persist } from "zustand/middleware"
interface TimerStore { interface TimerStore {
timer: NodeJS.Timeout | null timer: NodeJS.Timeout | null
@@ -37,7 +38,9 @@ interface IntervalStore {
setAutoSaveGap: (autoSaveGap: number) => void setAutoSaveGap: (autoSaveGap: number) => void
} }
export const useIntervalStore = create<IntervalStore>((set, get) => ({ export const useIntervalStore = create<IntervalStore>()(
persist<IntervalStore>(
(set, get) => ({
timer: null, timer: null,
isAutoSave: false, isAutoSave: false,
autoSaveGap: 5, autoSaveGap: 5,
@@ -64,7 +67,12 @@ export const useIntervalStore = create<IntervalStore>((set, get) => ({
setAutoSaveGap: (value: number) => { setAutoSaveGap: (value: number) => {
set((state) => ({ ...state, autoSaveGap: value })) set((state) => ({ ...state, autoSaveGap: value }))
}, },
})) }),
{
name: "interval-store",
}
)
)
export interface LabelTimeState { export interface LabelTimeState {
label: number label: number