From 46c6dbfa61df2cb30a0dc79f1c8bc1e3c6997fdd Mon Sep 17 00:00:00 2001 From: Purp1e <438518244@qq.com> Date: Fri, 27 Sep 2024 10:38:40 +0800 Subject: [PATCH] update: persist store fullfiil + launchOptions validation --- package.json | 2 + pnpm-lock.yaml | 17 ++++++ src/components/cstb/LaunchOption.tsx | 16 +++--- src/store/app.ts | 38 +++++++------ src/store/steam.ts | 59 ++++++++++++-------- src/store/tool.ts | 41 ++++++++++---- src/utils/persist.ts | 82 +++++++++++++++------------- 7 files changed, 158 insertions(+), 97 deletions(-) diff --git a/package.json b/package.json index 1247f5c..622c469 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,12 @@ "@tauri-apps/plugin-process": "2.0.0-rc.1", "@tauri-apps/plugin-shell": "2.0.0-rc.1", "@tauri-apps/plugin-store": "^2.0.0-rc", + "@types/throttle-debounce": "^5.0.2", "jotai": "^2.10.0", "next": "^14.2.13", "react": "^18.3.1", "react-dom": "^18.3.1", + "throttle-debounce": "^5.0.2", "zustand": "5.0.0-rc.2" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3a20b9b..4414dc0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,6 +47,9 @@ importers: '@tauri-apps/plugin-store': specifier: ^2.0.0-rc version: 2.0.0-rc.1 + '@types/throttle-debounce': + specifier: ^5.0.2 + version: 5.0.2 jotai: specifier: ^2.10.0 version: 2.10.0(@types/react@18.3.8)(react@18.3.1) @@ -59,6 +62,9 @@ importers: react-dom: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) + throttle-debounce: + specifier: ^5.0.2 + version: 5.0.2 zustand: specifier: 5.0.0-rc.2 version: 5.0.0-rc.2(@types/react@18.3.8)(react@18.3.1)(use-sync-external-store@1.2.2(react@18.3.1)) @@ -584,6 +590,9 @@ packages: '@types/stack-utils@2.0.3': resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} + '@types/throttle-debounce@5.0.2': + resolution: {integrity: sha512-pDzSNulqooSKvSNcksnV72nk8p7gRqN8As71Sp28nov1IgmPKWbOEIwAWvBME5pPTtaXJAvG3O4oc76HlQ4kqQ==} + '@types/yargs-parser@21.0.3': resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} @@ -2421,6 +2430,10 @@ packages: thenify@3.3.1: resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==} + throttle-debounce@5.0.2: + resolution: {integrity: sha512-B71/4oyj61iNH0KeCamLuE2rmKuTO5byTOSVwECM5FA7TiAiAW+UqTKZ9ERueC4qvgSttUhdmq1mXC3kJqGX7A==} + engines: {node: '>=12.22'} + to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -2937,6 +2950,8 @@ snapshots: '@types/stack-utils@2.0.3': {} + '@types/throttle-debounce@5.0.2': {} + '@types/yargs-parser@21.0.3': {} '@types/yargs@17.0.33': @@ -5041,6 +5056,8 @@ snapshots: dependencies: any-promise: 1.3.0 + throttle-debounce@5.0.2: {} + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 diff --git a/src/components/cstb/LaunchOption.tsx b/src/components/cstb/LaunchOption.tsx index 04c9934..c118f91 100644 --- a/src/components/cstb/LaunchOption.tsx +++ b/src/components/cstb/LaunchOption.tsx @@ -1,12 +1,10 @@ import { Plus, SettingConfig, Switch } from "@icon-park/react"; import { Card, CardHeader, CardIcon, CardTool, CardBody } from "../window/Card"; -import { useState } from "react"; import { ToolButton } from "../window/ToolButton"; +import useToolStore from "@/store/tool"; const LaunchOption = () => { - const [LaunchOption, setLaunchOption] = useState( - "-high -refresh 120 -novid -nojoy -tickrate 128 +cl_cmdrate 128 +cl_updaterate 128 +exec auto.cfg +test" - ); + const { launchOptions, setLaunchOption, launchIndex, setLaunchIndex } = useToolStore() return ( @@ -15,9 +13,9 @@ const LaunchOption = () => { 启动选项 - 1 - 2 - 3 + setLaunchIndex(0)}>1 + setLaunchIndex(1)}>2 + setLaunchIndex(2)}>3 添加 @@ -31,8 +29,8 @@ const LaunchOption = () => {