[feat] dynamic version name

This commit is contained in:
Purp1e
2025-03-21 15:20:03 +08:00
parent 1f07d876d3
commit 90a05017ce
2 changed files with 14 additions and 26 deletions

View File

@@ -50,7 +50,7 @@ export function Prepare() {
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, "触发", debounceValid, steam.state.steamDir, steam.state.cs2Dir)
if (checkCount < 1) { if (checkCount < 2) {
if (debounceValid) { if (debounceValid) {
console.log("跳转") console.log("跳转")
setTimeout(() => { setTimeout(() => {

View File

@@ -1,15 +1,9 @@
"use client" "use client"
import { Button, cn } from "@heroui/react" import { cn } from "@heroui/react"
import { import { Home, MonitorOne, Movie, Setting, Terminal, Toolkit } from "@icon-park/react"
Home,
MonitorOne,
Movie,
Setting,
Terminal,
Toolkit,
} from "@icon-park/react"
import { usePathname, useRouter } from "next/navigation" import { usePathname, useRouter } from "next/navigation"
import type { ReactNode } from "react" import type { ReactNode } from "react"
import { getVersion } from "@tauri-apps/api/app"
// import { platform } from "@tauri-apps/plugin-os" // import { platform } from "@tauri-apps/plugin-os"
import { useAppStore } from "@/store/app" import { useAppStore } from "@/store/app"
@@ -36,7 +30,7 @@ const SideButton = ({
className={cn( className={cn(
className, className,
"p-2.5 hover:bg-black/5 rounded-lg transition relative", "p-2.5 hover:bg-black/5 rounded-lg transition relative",
path.startsWith(route) && "bg-black/5", path.startsWith(route) && "bg-black/5"
)} )}
{...rest} {...rest}
> >
@@ -44,7 +38,7 @@ const SideButton = ({
<div <div
className={cn( className={cn(
path.startsWith(route) && "opacity-100", path.startsWith(route) && "opacity-100",
"transition-opacity duration-300 opacity-0 h-3.5 w-0.5 absolute left-0.5 bg-purple-500 rounded-full top-1/2 -translate-y-1/2", "transition-opacity duration-300 opacity-0 h-3.5 w-0.5 absolute left-0.5 bg-purple-500 rounded-full top-1/2 -translate-y-1/2"
)} )}
/> />
</button> </button>
@@ -60,7 +54,7 @@ const Avatar = () => {
onClick={() => router.push("/users")} onClick={() => router.push("/users")}
className={cn( className={cn(
"w-12 h-12 bg-gray-700 rounded-full shadow-2xl cursor-pointer transition active:scale-95 shadow-purple-800", "w-12 h-12 bg-gray-700 rounded-full shadow-2xl cursor-pointer transition active:scale-95 shadow-purple-800",
path.startsWith("/users") && "shadow-sm", path.startsWith("/users") && "shadow-sm"
)} )}
type="button" type="button"
> >
@@ -72,10 +66,14 @@ const Avatar = () => {
const SideBar = () => { const SideBar = () => {
const app = useAppStore() const app = useAppStore()
getVersion().then((Value) => {
app.setVersion(Value)
})
return ( return (
<div <div
className={cn( className={cn(
"absolute left-0 flex flex-col h-full select-none w-20 pt-7 pb-5", "absolute left-0 flex flex-col h-full select-none w-20 pt-7 pb-5"
// platform() === "windows" ? "w-20" : "w-[4.25rem]" // platform() === "windows" ? "w-20" : "w-[4.25rem]"
)} )}
data-tauri-drag-region data-tauri-drag-region
@@ -108,19 +106,9 @@ const SideBar = () => {
</SideButton> </SideButton>
</section> </section>
<div <div className="mx-auto text-sm text-center text-zinc-500" data-tauri-drag-region>
className="mx-auto text-sm text-center text-zinc-500"
data-tauri-drag-region
>
<p></p> <p></p>
<Button <p className="py-1 text-sm text-zinc-600">{app.state.version}</p>
variant="light"
size="sm"
className="mt-0.5 text-zinc-600"
onPress={() => app.setVersion("x.y.z")}
>
{app.state.version}
</Button>
</div> </div>
</div> </div>
) )