diff --git a/package.json b/package.json
index 4ba2a6a..5ef2bad 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,8 @@
"@tauri-apps/plugin-shell": "2.0.0-rc.1",
"next": "^14.2.13",
"react": "^18.3.1",
- "react-dom": "^18.3.1"
+ "react-dom": "^18.3.1",
+ "zustand": "5.0.0-rc.2"
},
"devDependencies": {
"@biomejs/biome": "^1.9.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 82e0a4a..7b8b4e9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -50,6 +50,9 @@ importers:
react-dom:
specifier: ^18.3.1
version: 18.3.1(react@18.3.1)
+ zustand:
+ specifier: 5.0.0-rc.2
+ version: 5.0.0-rc.2(@types/react@18.3.8)(react@18.3.1)
devDependencies:
'@biomejs/biome':
specifier: ^1.9.2
@@ -2476,6 +2479,24 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
+ zustand@5.0.0-rc.2:
+ resolution: {integrity: sha512-o2Nwuvnk8vQBX7CcHL8WfFkZNJdxB/VKeWw0tNglw8p4cypsZ3tRT7rTRTDNeUPFS0qaMBRSKe+fVwL5xpcE3A==}
+ engines: {node: '>=12.20.0'}
+ peerDependencies:
+ '@types/react': '>=18.0.0'
+ immer: '>=9.0.6'
+ react: '>=18.0.0'
+ use-sync-external-store: '>=1.2.0'
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ immer:
+ optional: true
+ react:
+ optional: true
+ use-sync-external-store:
+ optional: true
+
snapshots:
'@adobe/css-tools@4.4.0': {}
@@ -5083,3 +5104,8 @@ snapshots:
yaml@2.5.1: {}
yocto-queue@0.1.0: {}
+
+ zustand@5.0.0-rc.2(@types/react@18.3.8)(react@18.3.1):
+ optionalDependencies:
+ '@types/react': 18.3.8
+ react: 18.3.1
diff --git a/src/app/prepare/page.tsx b/src/app/prepare/page.tsx
index 6ab0fca..71e39aa 100644
--- a/src/app/prepare/page.tsx
+++ b/src/app/prepare/page.tsx
@@ -1,4 +1,8 @@
+"use client"
+import useSteamStore from "@/store/steam"
+
export default function Page() {
+ const { dir, updateDir, csDir, updateCsDir, currentUser } = useSteamStore()
return (
)
}
diff --git a/src/store/app.ts b/src/store/app.ts
new file mode 100644
index 0000000..de2c4f0
--- /dev/null
+++ b/src/store/app.ts
@@ -0,0 +1,24 @@
+import { create } from 'zustand'
+
+interface AppState {
+ version: number
+ hasUpdate: boolean
+ hasInit: boolean
+ notice: string
+ useMirror: boolean
+ init: () => void
+}
+
+const useAppStore = create()((/* set */) => ({
+ version: 0,
+ hasUpdate: false,
+ hasInit: false,
+ notice: "",
+ useMirror: true,
+ init: () => {
+ console.log('init')
+ },
+ // increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
+}))
+
+export default useAppStore
\ No newline at end of file
diff --git a/src/store/steam.ts b/src/store/steam.ts
new file mode 100644
index 0000000..1fcddb2
--- /dev/null
+++ b/src/store/steam.ts
@@ -0,0 +1,45 @@
+import { SteamUser } from '@/types/steam'
+import { create } from 'zustand'
+
+const mock_user: SteamUser = {
+ steamID64: "76561198052315353",
+ steamID32: "STEAM_0:0:46157676",
+ accountName: "wrr",
+ personaName: "wrr",
+ recent: 0,
+ avatar: "",
+ // "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/0d/0d1d4b9e1a9e8b2b3d4d0a7e1b3d6b1e3f8f4f7.jpg",
+}
+
+interface SteamState {
+ dir: string,
+ csDir: string,
+ users: SteamUser[],
+ currentUser: () => SteamUser,
+ isDirValid: boolean,
+ isCsDirValid: boolean,
+ init: () => void,
+ updateDir: (dir: string) => void,
+ updateCsDir: (dir: string) => void,
+}
+
+const useSteamStore = create()((set, get) => ({
+ // 路径
+ dir: "C:\\Program Files (x86)\\Steam",
+ csDir: "",
+ users: [mock_user] as SteamUser[],
+ currentUser: () => {
+ return get().users[0] || mock_user
+ },
+ // 路径是否可用
+ isDirValid: false,
+ isCsDirValid: false,
+ init: () => {
+ console.log('init')
+ },
+ updateDir: (dir: string) => set(() => ({ dir: dir })),
+ updateCsDir: (dir: string) => set(() => ({ csDir: dir })),
+ // increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
+}))
+
+export default useSteamStore
\ No newline at end of file
diff --git a/src/store/tool.ts b/src/store/tool.ts
new file mode 100644
index 0000000..f052ee6
--- /dev/null
+++ b/src/store/tool.ts
@@ -0,0 +1,20 @@
+import { create } from 'zustand'
+
+export interface ToolState {
+ launchOptions: string[]
+ launchIndex: number
+ powerPlan: number
+ init: () => void
+}
+
+const useToolStore = create()((/* set */) => ({
+ launchOptions: ["-novid -nojoy -high -freq 120 -tickrate 128", "", ""],
+ launchIndex: 0,
+ powerPlan: 0,
+ init: () => {
+ console.log('init')
+ },
+ // increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
+}))
+
+export default useToolStore
\ No newline at end of file
diff --git a/src/types/cfg.ts b/src/types/cfg.ts
new file mode 100644
index 0000000..f981210
--- /dev/null
+++ b/src/types/cfg.ts
@@ -0,0 +1,21 @@
+import { AdvancedListItem } from "@/types/common"
+
+export interface File {
+ dir: string
+ filename: string
+ format: "cfg" | "vcfg" | "txt" | "zip"
+ createTime: number
+ updateTime: number
+ size: number
+}
+
+export interface Owner {
+ ownerSteamId64: string
+ ownerSteamName: string
+ ownerToolboxId: string
+ ownerToolboxName: string
+}
+
+export interface CfgBackup extends File, Owner {}
+
+export interface Cfg extends File, AdvancedListItem {}
diff --git a/src/types/cfgx.ts b/src/types/cfgx.ts
new file mode 100644
index 0000000..588e8a5
--- /dev/null
+++ b/src/types/cfgx.ts
@@ -0,0 +1,30 @@
+import { Owner } from "@/types/cfg"
+
+export interface XBase {
+ name: string
+ value: string
+ default: string
+ info: string
+}
+
+export interface Key extends XBase {}
+export interface Alias extends XBase {}
+export interface Value extends XBase {
+ option: { name: string; value: string }[]
+}
+
+// 转换方法 [[key=${name}]] | [[alias=${name}]] | [[value=${name}]] -> value
+export interface XItem {
+ version: string
+ creater: string
+ key: Key[]
+ alias: Alias[]
+ value: Value[]
+ comment: string
+ content: string
+}
+
+export interface CfgX extends Owner {
+ note: string
+ items: XItem[]
+}
diff --git a/src/types/common.ts b/src/types/common.ts
new file mode 100644
index 0000000..3d38682
--- /dev/null
+++ b/src/types/common.ts
@@ -0,0 +1,5 @@
+export interface AdvancedListItem {
+ mark?: boolean
+ hidden?: boolean
+ priority?: number
+}
diff --git a/src/types/steam.ts b/src/types/steam.ts
new file mode 100644
index 0000000..9c01620
--- /dev/null
+++ b/src/types/steam.ts
@@ -0,0 +1,10 @@
+import { AdvancedListItem } from "@/types/common"
+
+export interface SteamUser extends AdvancedListItem {
+ steamID64: string
+ steamID32: string
+ accountName: string
+ personaName: string
+ recent: number
+ avatar: string
+}