feat:init

This commit is contained in:
zhongyidian committed 2025-12-29 19:19:10 +08:00
1 parent 53d0eeac6b
commit ae0c050010
494 files changed
+17701 -2318

No files matched your search

-39
View File
@@ -1,39 +0,0 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";
interface FirstVisitState {
hasSeenIntro: boolean;
timestamp: number | null; // 存储时间戳
setHasSeenIntro: () => void;
isExpired: () => boolean; // 检查是否过期
reset: () => void; // 重置状态
}
// 存储有效期(毫秒),默认5分钟
const STORAGE_EXPIRY_TIME = 5 * 60 * 1000;
export const useFirstVisitStore = create<FirstVisitState>()(
persist(
(set, get) => ({
hasSeenIntro: false,
timestamp: null,
setHasSeenIntro: () => {
set({ hasSeenIntro: true, timestamp: Date.now() });
},
isExpired: () => {
const state = get();
if (!state.timestamp) {
return false;
}
const now = Date.now();
return now - state.timestamp > STORAGE_EXPIRY_TIME;
},
reset: () => {
set({ hasSeenIntro: false, timestamp: null });
},
}),
{
name: "first-visit-storage", // 存储到localStorage的key
}
)
);
-1
View File
@@ -1 +0,0 @@
export * from "./firstVisitStore";