[fix] errors with default empty steam users + loading process
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
"next-build": "next build",
|
"next-build": "next build",
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"build": "tauri build",
|
"build": "tauri build",
|
||||||
|
"build-fast": "tauri build -b nsis -- --profile dev",
|
||||||
"dev": "tauri dev",
|
"dev": "tauri dev",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"fix": "next lint --fix"
|
"fix": "next lint --fix"
|
||||||
@@ -36,7 +37,6 @@
|
|||||||
"@types/throttle-debounce": "^5.0.2",
|
"@types/throttle-debounce": "^5.0.2",
|
||||||
"ahooks": "^3.8.4",
|
"ahooks": "^3.8.4",
|
||||||
"framer-motion": "^12.5.0",
|
"framer-motion": "^12.5.0",
|
||||||
"jotai": "^2.12.2",
|
|
||||||
"next": "15.2.2",
|
"next": "15.2.2",
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ opt-level = "s" # Optimize for binary size
|
|||||||
strip = true # Remove debug symbols
|
strip = true # Remove debug symbols
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
opt-level = 0 # 关闭优化
|
||||||
|
debug = true # 保留调试信息
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.1.0", features = [] }
|
tauri-build = { version = "2.1.0", features = [] }
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default function Page() {
|
|||||||
<p>游戏路径:{steam.state.cs2Dir}</p>
|
<p>游戏路径:{steam.state.cs2Dir}</p>
|
||||||
<p>Steam路径有效:{steam.state.steamDirValid ? "是" : "否"}</p>
|
<p>Steam路径有效:{steam.state.steamDirValid ? "是" : "否"}</p>
|
||||||
<p>游戏路径有效:{steam.state.cs2DirValid ? "是" : "否"}</p>
|
<p>游戏路径有效:{steam.state.cs2DirValid ? "是" : "否"}</p>
|
||||||
<p>Steam账号:{steam.currentUser().accountName}</p>
|
<p>Steam账号:{steam.currentUser()?.accountName || " "}</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export default function Page() {
|
|||||||
steam.setCsDir(e.target.value)
|
steam.setCsDir(e.target.value)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<p>当前用户64位SteamID:{steam.currentUser().steamID64}</p>
|
<p>当前用户64位SteamID:{steam.currentUser()?.steamID64}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export function Prepare() {
|
|||||||
const app = useAppStore()
|
const app = useAppStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [inited, setInited] = useState(false)
|
||||||
const [, setSteamDir] = useState(steam.state.steamDir)
|
const [, setSteamDir] = useState(steam.state.steamDir)
|
||||||
const [, setCs2Dir] = useState(steam.state.cs2Dir)
|
const [, setCs2Dir] = useState(steam.state.cs2Dir)
|
||||||
|
|
||||||
@@ -41,31 +42,32 @@ export function Prepare() {
|
|||||||
await steam.store.start()
|
await steam.store.start()
|
||||||
await app.store.start()
|
await app.store.start()
|
||||||
if (!app.state.inited) await autoGetPaths()
|
if (!app.state.inited) await autoGetPaths()
|
||||||
|
setInited(true)
|
||||||
}
|
}
|
||||||
void init()
|
void init()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// valid变动后调整State
|
// valid变动后调整State
|
||||||
const debounceValid = useDebounce(steam.state.steamDirValid && steam.state.cs2DirValid, {
|
|
||||||
wait: 500,
|
|
||||||
leading: true,
|
|
||||||
trailing: true,
|
|
||||||
maxWait: 2500,
|
|
||||||
})
|
|
||||||
const [checkCount, setCheckCount] = useState(0)
|
const [checkCount, setCheckCount] = useState(0)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCheckCount((prev) => (prev >= 10 ? 10 : prev + 1))
|
setCheckCount((prev) => (prev >= 10 ? 10 : prev + 1))
|
||||||
// console.log(checkCount, "触发", debounceValid, steam.state.steamDir, steam.state.cs2Dir)
|
// console.log(checkCount, "触发", steam.state.steamDir, steam.state.cs2Dir, app.state.inited)
|
||||||
if (checkCount < 2 && debounceValid && app.state.inited) {
|
if (checkCount <= 2) {
|
||||||
|
if (steam.state.steamDir && steam.state.cs2Dir && app.state.inited) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
router.push("/home")
|
router.push("/home")
|
||||||
}, 800)
|
}, 300)
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
}, [debounceValid])
|
} else {
|
||||||
|
setTimeout(() => {
|
||||||
|
setLoading(false)
|
||||||
|
}, 1200)
|
||||||
|
}
|
||||||
|
}, [inited])
|
||||||
|
|
||||||
const handleSelectSteamDir = async () => {
|
const handleSelectSteamDir = async () => {
|
||||||
const selected = await open({
|
const selected = await open({
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ const Header = () => {
|
|||||||
return (
|
return (
|
||||||
<div className="pt-6 select-none pb-9" data-tauri-drag-region>
|
<div className="pt-6 select-none pb-9" data-tauri-drag-region>
|
||||||
<h1 className="text-xl font-medium tracking-wide w-fit">
|
<h1 className="text-xl font-medium tracking-wide w-fit">
|
||||||
{steam.currentUser().personaName || 'CS工具箱'}
|
{steam.currentUser()?.personaName || 'CS工具箱'}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-sm font-light tracking-wide text-zinc-400 w-fit">
|
<p className="text-sm font-light tracking-wide text-zinc-400 w-fit">
|
||||||
{steam.currentUser().accountName || '本周使用CS工具箱 114 小时'}
|
{steam.currentUser()?.accountName || '本周使用CS工具箱 114 小时'}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,16 +12,7 @@ const defaultValue = {
|
|||||||
cs2DirValid: false,
|
cs2DirValid: false,
|
||||||
steamDirChecking: false,
|
steamDirChecking: false,
|
||||||
cs2DirChecking: false,
|
cs2DirChecking: false,
|
||||||
users: [
|
users: [] as SteamUser[],
|
||||||
{
|
|
||||||
steamID64: "76561198052315353",
|
|
||||||
steamID32: "46157676",
|
|
||||||
accountName: "wrr_account",
|
|
||||||
personaName: "wrr",
|
|
||||||
recent: 0,
|
|
||||||
avatar: "",
|
|
||||||
},
|
|
||||||
] as SteamUser[],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const steamStore = store(
|
export const steamStore = store(
|
||||||
@@ -51,7 +42,7 @@ export const useSteamStore = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cs2BaseDir = () => {
|
const cs2BaseDir = () => {
|
||||||
return path.normalize(`${steamStore.state.cs2Dir.replaceAll("\\", "/") }/../../..`)
|
return path.normalize(`${steamStore.state.cs2Dir.replaceAll("\\", "/")}/../../..`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const setDir = (dir: string) => {
|
const setDir = (dir: string) => {
|
||||||
@@ -97,7 +88,7 @@ const checkCs2DirValid = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const currentUser = () => {
|
const currentUser = () => {
|
||||||
return steamStore.state.users[0] || defaultValue.users[0]
|
return steamStore.state.users.at(0) || undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const resetSteamStore = () => {
|
const resetSteamStore = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user