[dep] update to eslint 9
This commit is contained in:
@@ -7,13 +7,22 @@
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": ["./tsconfig.json"]
|
||||
"project": [
|
||||
"./tsconfig.json"
|
||||
]
|
||||
},
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"eqeqeq": "error",
|
||||
"no-else-return": "error",
|
||||
"no-implicit-coercion": ["error", { "disallowTemplateShorthand": true }],
|
||||
"no-implicit-coercion": [
|
||||
"error",
|
||||
{
|
||||
"disallowTemplateShorthand": true
|
||||
}
|
||||
],
|
||||
"no-unneeded-ternary": "error",
|
||||
"no-useless-call": "error",
|
||||
"no-useless-computed-key": "error",
|
||||
@@ -23,7 +32,10 @@
|
||||
"prefer-rest-params": "error",
|
||||
"prefer-spread": "error",
|
||||
"prefer-template": "error",
|
||||
"radix": ["error", "always"],
|
||||
"radix": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"react-hooks/exhaustive-deps": "error",
|
||||
"@typescript-eslint/no-misused-promises": [
|
||||
"error",
|
||||
@@ -31,9 +43,10 @@
|
||||
"checksVoidReturn": false
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-confusing-void-expression":"off",
|
||||
"@typescript-eslint/no-confusing-void-expression": "off",
|
||||
"@typescript-eslint/no-unsafe-return": "off",
|
||||
"@typescript-eslint/no-unsafe-call": "off",
|
||||
"@typescript-eslint/prefer-nullish-coalescing": "off"
|
||||
"@typescript-eslint/prefer-nullish-coalescing": "off",
|
||||
"@typescript-eslint/no-unsafe-member-access": "warn"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
},
|
||||
@@ -18,7 +18,7 @@
|
||||
"formatter": {
|
||||
"semicolons": "asNeeded",
|
||||
"lineEnding": "lf",
|
||||
"trailingComma": "all"
|
||||
"trailingCommas": "all"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
"email": "zx8244@qq.com"
|
||||
},
|
||||
"scripts": {
|
||||
"next-start": "cross-env BROWSER=none next dev",
|
||||
"next-start": "cross-env BROWSER=none next dev --turbo",
|
||||
"next-build": "next build",
|
||||
"tauri": "tauri",
|
||||
"build": "tauri build",
|
||||
"dev": "tauri dev",
|
||||
"lint": "next lint && biome check src/",
|
||||
"fix": "next lint --fix && biome check src/ --fix",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -54,8 +55,8 @@
|
||||
"clsx": "^2.1.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"cssnano": "^7.0.6",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-config-next": "^14.2.17",
|
||||
"eslint": "9.14.0",
|
||||
"eslint-config-next": "15.0.3",
|
||||
"husky": "^9.1.6",
|
||||
"lint-staged": "^15.2.10",
|
||||
"postcss": "^8.4.48",
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function Page() {
|
||||
return <div>Console</div>;
|
||||
return <div>Console</div>
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function Page() {
|
||||
return <div>Gear</div>;
|
||||
return <div>Gear</div>
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use client";
|
||||
"use client"
|
||||
|
||||
import CommonDir from "@/components/cstb/CommonDir";
|
||||
import FastLaunch from "@/components/cstb/FastLaunch";
|
||||
import ForceQuit from "@/components/cstb/ForceQuit";
|
||||
import LaunchOption from "@/components/cstb/LaunchOption";
|
||||
import Notice from "@/components/cstb/Notice";
|
||||
import PowerPlan from "@/components/cstb/PowerPlan";
|
||||
import SmartTransfer from "@/components/cstb/SmartTranser";
|
||||
import CommonDir from "@/components/cstb/CommonDir"
|
||||
import FastLaunch from "@/components/cstb/FastLaunch"
|
||||
import ForceQuit from "@/components/cstb/ForceQuit"
|
||||
import LaunchOption from "@/components/cstb/LaunchOption"
|
||||
import Notice from "@/components/cstb/Notice"
|
||||
import PowerPlan from "@/components/cstb/PowerPlan"
|
||||
import SmartTransfer from "@/components/cstb/SmartTranser"
|
||||
|
||||
const Home = () => {
|
||||
return (
|
||||
@@ -25,7 +25,7 @@ const Home = () => {
|
||||
<FastLaunch />
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default Home;
|
||||
export default Home
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use client"
|
||||
import Header from "@/components/window/Header";
|
||||
import Nav from "@/components/window/Nav";
|
||||
import SideBar from "@/components/window/SideBar";
|
||||
import clsx from "clsx";
|
||||
import Header from "@/components/window/Header"
|
||||
import Nav from "@/components/window/Nav"
|
||||
import SideBar from "@/components/window/SideBar"
|
||||
import clsx from "clsx"
|
||||
// import { platform } from "@tauri-apps/plugin-os"
|
||||
|
||||
export default function BaseLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div className="w-full h-full bg-transparent">
|
||||
@@ -20,7 +20,7 @@ export default function BaseLayout({
|
||||
|
||||
<main
|
||||
className={clsx(
|
||||
"flex flex-col h-full pb-5 pr-5 ml-20 overflow-hidden"
|
||||
"flex flex-col h-full pb-5 pr-5 ml-20 overflow-hidden",
|
||||
// platform() === "windows" ? "ml-20" : "ml-[4.25rem]"
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function Page() {
|
||||
return <div>Movie</div>;
|
||||
return <div>Movie</div>
|
||||
}
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
"use client"
|
||||
import { Card, CardHeader, CardIcon, CardTool, CardBody } from "@/components/window/Card"
|
||||
import {
|
||||
Card,
|
||||
CardBody,
|
||||
CardHeader,
|
||||
CardIcon,
|
||||
CardTool,
|
||||
} from "@/components/window/Card"
|
||||
import { ToolButton } from "@/components/window/ToolButton"
|
||||
import { SettingConfig, UploadOne, HardDisk, AssemblyLine, Videocamera } from "@icon-park/react"
|
||||
import {
|
||||
AssemblyLine,
|
||||
HardDisk,
|
||||
SettingConfig,
|
||||
UploadOne,
|
||||
Videocamera,
|
||||
} from "@icon-park/react"
|
||||
import clsx from "clsx"
|
||||
import { usePathname, useRouter } from "next/navigation"
|
||||
// import { platform } from "@tauri-apps/plugin-os"
|
||||
|
||||
export default function PreferenceLayout({ children }: { children: React.ReactNode }) {
|
||||
export default function PreferenceLayout({
|
||||
children,
|
||||
}: { children: React.ReactNode }) {
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function Page() {
|
||||
return <div>Tool</div>;
|
||||
return <div>Tool</div>
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ body {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu,
|
||||
Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
|
||||
Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
|
||||
/* background: transparent; */
|
||||
background: rgba(242, 241, 243, 0.65);
|
||||
border-radius: 10px;
|
||||
|
||||
@@ -2,9 +2,9 @@ export const metadata = {
|
||||
title: "CS工具箱",
|
||||
description: "Generated by Next.js",
|
||||
icons: ["/favicon.ico"],
|
||||
};
|
||||
}
|
||||
|
||||
import "./globals.css";
|
||||
import "./globals.css"
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
"use client";
|
||||
"use client"
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useRouter } from "next/navigation"
|
||||
|
||||
const Home = () => {
|
||||
const router = useRouter();
|
||||
const router = useRouter()
|
||||
return (
|
||||
<main
|
||||
className="flex flex-col items-center justify-center w-full h-screen gap-6"
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<h1 className="text-4xl font-bold tracking-wide text-zinc-800">CS 工具箱</h1>
|
||||
<button onClick={() => router.push("/home")} className="px-4 py-1 rounded bg-zinc-200">
|
||||
<h1 className="text-4xl font-bold tracking-wide text-zinc-800">
|
||||
CS 工具箱
|
||||
</h1>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => router.push("/home")}
|
||||
className="px-4 py-1 rounded bg-zinc-200"
|
||||
>
|
||||
进入
|
||||
</button>
|
||||
</main>
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
export default Home;
|
||||
export default Home
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import Nav from "@/components/window/Nav"
|
||||
|
||||
export default function BaseLayout({ children }: { children: React.ReactNode }) {
|
||||
export default function BaseLayout({
|
||||
children,
|
||||
}: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="w-full h-full">
|
||||
<Nav />
|
||||
|
||||
@@ -8,7 +8,9 @@ export default function Page() {
|
||||
className="flex flex-col items-center justify-center w-full h-screen gap-6"
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<h1 className="text-4xl font-bold tracking-wide text-zinc-800">CS工具箱</h1>
|
||||
<h1 className="text-4xl font-bold tracking-wide text-zinc-800">
|
||||
CS工具箱
|
||||
</h1>
|
||||
<p>准备环节</p>
|
||||
|
||||
<div className="flex flex-col w-full gap-6 p-5 border rounded-lg bg-white/40">
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
"use client"
|
||||
import { CardButton } from "@/components/test/CardButton";
|
||||
import { useGlobalShortcut } from "@/hooks/tauri/shortcuts";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { useCallback, useState } from "react";
|
||||
import { CardButton } from "@/components/test/CardButton"
|
||||
import { useGlobalShortcut } from "@/hooks/tauri/shortcuts"
|
||||
import { invoke } from "@tauri-apps/api/core"
|
||||
import { useCallback, useState } from "react"
|
||||
|
||||
export default function Page() {
|
||||
const [buttonDesc, setButtonDesc] = useState<string>(
|
||||
"Waiting to be clicked. This calls 'on_button_clicked' from Rust."
|
||||
);
|
||||
"Waiting to be clicked. This calls 'on_button_clicked' from Rust.",
|
||||
)
|
||||
const onButtonClick = () => {
|
||||
invoke<string>("on_button_clicked")
|
||||
.then((value) => {
|
||||
setButtonDesc(value);
|
||||
setButtonDesc(value)
|
||||
})
|
||||
.catch(() => {
|
||||
setButtonDesc("Failed to invoke Rust command 'on_button_clicked'");
|
||||
});
|
||||
};
|
||||
setButtonDesc("Failed to invoke Rust command 'on_button_clicked'")
|
||||
})
|
||||
}
|
||||
|
||||
const shortcutHandler = useCallback(() => {
|
||||
console.log("Ctrl+P was pressed!");
|
||||
}, []);
|
||||
useGlobalShortcut("CommandOrControl+P", shortcutHandler);
|
||||
console.log("Ctrl+P was pressed!")
|
||||
}, [])
|
||||
useGlobalShortcut("CommandOrControl+P", shortcutHandler)
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
@@ -54,5 +54,5 @@ export default function Page() {
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import { FolderFocusOne } from "@icon-park/react";
|
||||
import { Card, CardHeader, CardIcon, CardBody } from "../window/Card";
|
||||
import { FolderFocusOne } from "@icon-park/react"
|
||||
import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
|
||||
|
||||
interface RoundedButtonProps {
|
||||
children?: React.ReactNode;
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
const RoundedButton = ({ children }: RoundedButtonProps) => {
|
||||
return (
|
||||
<button className="flex items-center justify-center px-3 py-1 transition rounded-full min-w-fit active:scale-95 hover:bg-black/10 text-zinc-700 bg-black/5">
|
||||
<button
|
||||
type="button"
|
||||
className="flex items-center justify-center px-3 py-1 transition rounded-full min-w-fit active:scale-95 hover:bg-black/10 text-zinc-700 bg-black/5"
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
const CommonDir = () => {
|
||||
return (
|
||||
@@ -33,7 +36,7 @@ const CommonDir = () => {
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default CommonDir;
|
||||
export default CommonDir
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { TakeOff } from "@icon-park/react";
|
||||
import { Card, CardHeader, CardIcon, CardBody } from "../window/Card";
|
||||
import { TakeOff } from "@icon-park/react"
|
||||
import { invoke } from "@tauri-apps/api/core"
|
||||
import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
|
||||
|
||||
const FastLaunch = () => {
|
||||
return (
|
||||
@@ -13,6 +13,7 @@ const FastLaunch = () => {
|
||||
<CardBody>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
invoke("launch_game", {
|
||||
// steamPath: steam.dir + "/steam.exe",
|
||||
@@ -25,6 +26,7 @@ const FastLaunch = () => {
|
||||
启动国服
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
invoke("launch_game", {
|
||||
// steamPath: steam.dir + "/steam.exe",
|
||||
@@ -40,6 +42,6 @@ const FastLaunch = () => {
|
||||
</CardBody>
|
||||
</Card>
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
export default FastLaunch;
|
||||
export default FastLaunch
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Power } from "@icon-park/react";
|
||||
import { Card, CardHeader, CardIcon, CardBody } from "../window/Card";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { Power } from "@icon-park/react"
|
||||
import { invoke } from "@tauri-apps/api/core"
|
||||
import { Card, CardBody, CardHeader, CardIcon } from "../window/Card"
|
||||
|
||||
const ForceQuit = () => {
|
||||
return (
|
||||
@@ -12,12 +12,24 @@ const ForceQuit = () => {
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<div className="flex gap-2">
|
||||
<button onClick={() => invoke("kill_steam")} className="px-5 font-medium py-1.5 transition bg-blue-200 rounded-full">关闭Steam</button>
|
||||
<button onClick={() => invoke("kill_game")} className="px-5 font-medium py-1.5 transition bg-orange-200 rounded-full">关闭CS2</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => invoke("kill_steam")}
|
||||
className="px-5 font-medium py-1.5 transition bg-blue-200 rounded-full"
|
||||
>
|
||||
关闭Steam
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => invoke("kill_game")}
|
||||
className="px-5 font-medium py-1.5 transition bg-orange-200 rounded-full"
|
||||
>
|
||||
关闭CS2
|
||||
</button>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default ForceQuit;
|
||||
export default ForceQuit
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Plus, SettingConfig, Switch } from "@icon-park/react";
|
||||
import { Card, CardHeader, CardIcon, CardTool, CardBody } from "../window/Card";
|
||||
import { ToolButton } from "../window/ToolButton";
|
||||
import useToolStore from "@/store/tool";
|
||||
import useToolStore from "@/store/tool"
|
||||
import { Plus, SettingConfig, Switch } from "@icon-park/react"
|
||||
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
|
||||
import { ToolButton } from "../window/ToolButton"
|
||||
|
||||
const LaunchOption = () => {
|
||||
const { launchOptions, setLaunchOption, launchIndex, setLaunchIndex } = useToolStore()
|
||||
const { launchOptions, setLaunchOption, launchIndex, setLaunchIndex } =
|
||||
useToolStore()
|
||||
|
||||
return (
|
||||
<Card>
|
||||
@@ -35,7 +36,7 @@ const LaunchOption = () => {
|
||||
/>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default LaunchOption;
|
||||
export default LaunchOption
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { Refresh, VolumeNotice } from "@icon-park/react";
|
||||
import {
|
||||
Card,
|
||||
CardBody,
|
||||
CardHeader,
|
||||
CardIcon,
|
||||
CardTool,
|
||||
CardBody,
|
||||
Card,
|
||||
} from "@/components/window/Card";
|
||||
import { ToolButton } from "../window/ToolButton";
|
||||
import useAppStore from "@/store/app";
|
||||
} from "@/components/window/Card"
|
||||
import useAppStore from "@/store/app"
|
||||
import { Refresh, VolumeNotice } from "@icon-park/react"
|
||||
import { ToolButton } from "../window/ToolButton"
|
||||
|
||||
const Notice = () => {
|
||||
const app = useAppStore();
|
||||
const app = useAppStore()
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
@@ -24,9 +24,11 @@ const Notice = () => {
|
||||
</ToolButton>
|
||||
</CardTool>
|
||||
</CardHeader>
|
||||
<CardBody>{app.notice || "不会真的有人要更新CSGO工具箱吧,不会吧不会吧 xswl"}</CardBody>
|
||||
<CardBody>
|
||||
{app.notice || "不会真的有人要更新CSGO工具箱吧,不会吧不会吧 xswl"}
|
||||
</CardBody>
|
||||
</Card>
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
export default Notice;
|
||||
export default Notice
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BatteryCharge, Refresh } from "@icon-park/react";
|
||||
import { Card, CardHeader, CardIcon, CardTool, CardBody } from "../window/Card";
|
||||
import { ToolButton } from "../window/ToolButton";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { BatteryCharge, Refresh } from "@icon-park/react"
|
||||
import { invoke } from "@tauri-apps/api/core"
|
||||
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
|
||||
import { ToolButton } from "../window/ToolButton"
|
||||
|
||||
const PowerPlan = () => {
|
||||
return (
|
||||
@@ -19,13 +19,31 @@ const PowerPlan = () => {
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<div className="flex p-0.5 bg-black/5 gap-2 rounded-full">
|
||||
<button onClick={() => invoke("set_power_plan", {index: 1})} className="flex-1 px-2 py-1 transition rounded-full bg-black/5">高性能</button>
|
||||
<button onClick={() => invoke("set_power_plan", {index: 2})} className="flex-1 px-2 py-1 transition rounded-full">平衡</button>
|
||||
<button onClick={() => invoke("set_power_plan", {index: 3})} className="flex-1 px-2 py-1 transition rounded-full">节能</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => invoke("set_power_plan", { index: 1 })}
|
||||
className="flex-1 px-2 py-1 transition rounded-full bg-black/5"
|
||||
>
|
||||
高性能
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => invoke("set_power_plan", { index: 2 })}
|
||||
className="flex-1 px-2 py-1 transition rounded-full"
|
||||
>
|
||||
平衡
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => invoke("set_power_plan", { index: 3 })}
|
||||
className="flex-1 px-2 py-1 transition rounded-full"
|
||||
>
|
||||
节能
|
||||
</button>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default PowerPlan;
|
||||
export default PowerPlan
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FolderConversion, FolderPlus } from "@icon-park/react";
|
||||
import { Card, CardHeader, CardIcon, CardTool, CardBody } from "../window/Card";
|
||||
import { ToolButton } from "../window/ToolButton";
|
||||
import { FolderConversion, FolderPlus } from "@icon-park/react"
|
||||
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
|
||||
import { ToolButton } from "../window/ToolButton"
|
||||
|
||||
const SmartTransfer = () => {
|
||||
return (
|
||||
@@ -22,7 +22,7 @@ const SmartTransfer = () => {
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default SmartTransfer;
|
||||
export default SmartTransfer
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ReactNode } from "react"
|
||||
import clsx from "clsx"
|
||||
import type { ReactNode } from "react"
|
||||
|
||||
interface CardProps {
|
||||
children?: ReactNode
|
||||
@@ -20,23 +20,41 @@ const Card = ({ children }: CardProps) => {
|
||||
}
|
||||
|
||||
const CardHeader = ({ children }: CardProps) => {
|
||||
return <div className="flex items-center gap-1.5 tracking-wide">{children}</div>
|
||||
return (
|
||||
<div className="flex items-center gap-1.5 tracking-wide">{children}</div>
|
||||
)
|
||||
}
|
||||
|
||||
const CardIcon = ({ children, type, className, ...rest }: CardProps) => {
|
||||
return (
|
||||
<div className={clsx("flex gap-1.5 items-center font-semibold", type === "menu" && "transition cursor-pointer hover:bg-black/5 px-2 py-1 rounded-md active:scale-95", className)} {...rest}>
|
||||
<div
|
||||
className={clsx(
|
||||
"flex gap-1.5 items-center font-semibold",
|
||||
type === "menu" &&
|
||||
"transition cursor-pointer hover:bg-black/5 px-2 py-1 rounded-md active:scale-95",
|
||||
className,
|
||||
)}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const CardTool = ({ children }: CardProps) => {
|
||||
return <div className="flex items-center justify-end flex-grow gap-2">{children}</div>
|
||||
return (
|
||||
<div className="flex items-center justify-end flex-grow gap-2">
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const CardBody = ({ children }: CardProps) => {
|
||||
return <div className="w-full h-full text-sm tracking-wide text-zinc-800">{children}</div>
|
||||
return (
|
||||
<div className="w-full h-full text-sm tracking-wide text-zinc-800">
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export { Card, CardHeader, CardIcon, CardTool, CardBody }
|
||||
|
||||
@@ -8,7 +8,7 @@ const Header = () => {
|
||||
本周使用CS工具箱 114 小时
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default Header;
|
||||
export default Header
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client"
|
||||
import { RocketOne, Minus, Close, Square } from "@icon-park/react"
|
||||
import { /* relaunch, */ exit } from "@tauri-apps/plugin-process"
|
||||
import { Close, Minus, RocketOne, Square } from "@icon-park/react"
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window"
|
||||
import { /* relaunch, */ exit } from "@tauri-apps/plugin-process"
|
||||
// import { platform } from "@tauri-apps/plugin-os"
|
||||
import { useRouter, usePathname } from "next/navigation"
|
||||
import { usePathname, useRouter } from "next/navigation"
|
||||
|
||||
const Nav = () => {
|
||||
const close = async () => {
|
||||
@@ -35,35 +35,44 @@ const Nav = () => {
|
||||
const pathname = usePathname()
|
||||
|
||||
return (
|
||||
<nav className="absolute top-0 right-0 flex flex-row h-16 gap-0.5 p-4" data-tauri-drag-region>
|
||||
<nav
|
||||
className="absolute top-0 right-0 flex flex-row h-16 gap-0.5 p-4"
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={() => pathname !== "/prepare" ? router.push("/prepare") : router.back()}
|
||||
onClick={() =>
|
||||
pathname !== "/prepare" ? router.push("/prepare") : router.back()
|
||||
}
|
||||
>
|
||||
<RocketOne size={16} />
|
||||
</button>
|
||||
|
||||
{/* { platform() === "windows" && ( */}
|
||||
<>
|
||||
<button
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={minimize}
|
||||
>
|
||||
<Minus size={16} />
|
||||
</button>
|
||||
<button
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={toggleMaximize}
|
||||
>
|
||||
<Square size={16} />
|
||||
</button>
|
||||
<button
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={close}
|
||||
>
|
||||
<Close size={16} />
|
||||
</button>
|
||||
</>
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={minimize}
|
||||
>
|
||||
<Minus size={16} />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={toggleMaximize}
|
||||
>
|
||||
<Square size={16} />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="px-2 py-0 transition rounded hover:bg-zinc-200/80 active:scale-95"
|
||||
onClick={close}
|
||||
>
|
||||
<Close size={16} />
|
||||
</button>
|
||||
</>
|
||||
{/* )} */}
|
||||
</nav>
|
||||
)
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
"use client"
|
||||
import { ReactNode } from "react"
|
||||
import {
|
||||
Home,
|
||||
MonitorOne,
|
||||
Movie,
|
||||
Setting,
|
||||
Terminal,
|
||||
Toolkit,
|
||||
} from "@icon-park/react"
|
||||
import clsx from "clsx"
|
||||
import { Home, MonitorOne, Movie, Setting, Terminal, Toolkit } from "@icon-park/react"
|
||||
import { useRouter, usePathname } from "next/navigation"
|
||||
import { usePathname, useRouter } from "next/navigation"
|
||||
import type { ReactNode } from "react"
|
||||
|
||||
// import { platform } from "@tauri-apps/plugin-os"
|
||||
import useAppStore from "@/store/app"
|
||||
@@ -24,11 +31,12 @@ const SideButton = ({
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={() => router.push(route || "/")}
|
||||
type="button"
|
||||
onKeyUp={() => router.push(route || "/")}
|
||||
className={clsx(
|
||||
className,
|
||||
"p-2.5 hover:bg-black/5 rounded-lg transition relative",
|
||||
path.startsWith(route) && "bg-black/5"
|
||||
path.startsWith(route) && "bg-black/5",
|
||||
)}
|
||||
{...rest}
|
||||
>
|
||||
@@ -36,7 +44,7 @@ const SideButton = ({
|
||||
<div
|
||||
className={clsx(
|
||||
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>
|
||||
@@ -49,10 +57,10 @@ const Avatar = () => {
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={() => router.push("/users")}
|
||||
onKeyUp={() => router.push("/users")}
|
||||
className={clsx(
|
||||
"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",
|
||||
)}
|
||||
>
|
||||
<img src="favicon.ico" alt="avatar" draggable={false} />
|
||||
@@ -66,7 +74,7 @@ const SideBar = () => {
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
"absolute left-0 flex flex-col h-full select-none w-20 py-7"
|
||||
"absolute left-0 flex flex-col h-full select-none w-20 py-7",
|
||||
// platform() === "windows" ? "w-20" : "w-[4.25rem]"
|
||||
)}
|
||||
data-tauri-drag-region
|
||||
@@ -99,9 +107,12 @@ const SideBar = () => {
|
||||
</SideButton>
|
||||
</section>
|
||||
|
||||
<div className="mx-auto text-sm text-center text-zinc-500" data-tauri-drag-region>
|
||||
<div
|
||||
className="mx-auto text-sm text-center text-zinc-500"
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<p>版本号</p>
|
||||
<p onClick={() => setVersion("x.y.z")}>{version}</p>
|
||||
<p onKeyUp={() => setVersion("x.y.z")}>{version}</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { ReactNode } from "react";
|
||||
import type { ReactNode } from "react"
|
||||
|
||||
interface ToolButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
children?: ReactNode;
|
||||
interface ToolButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
children?: ReactNode
|
||||
}
|
||||
export const ToolButton = ({ children, ...rest }: ToolButtonProps) => {
|
||||
return <button className="flex gap-0.5 active:scale-95 items-center min-w-7 justify-center px-2 py-1.5 bg-black/5 transition hover:bg-black/10 rounded-md text-sm leading-none" {...rest}>{children}</button>;
|
||||
};
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="flex gap-0.5 active:scale-95 items-center min-w-7 justify-center px-2 py-1.5 bg-black/5 transition hover:bg-black/10 rounded-md text-sm leading-none"
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { create } from 'zustand'
|
||||
import { tauriStore } from '@/utils/persist'
|
||||
import { createJSONStorage, persist } from 'zustand/middleware'
|
||||
import { tauriStore } from "@/utils/persist"
|
||||
import { create } from "zustand"
|
||||
import { createJSONStorage, persist } from "zustand/middleware"
|
||||
|
||||
interface AppState {
|
||||
version: string
|
||||
@@ -23,23 +23,25 @@ const { /* store, */ storage } = tauriStore(STORE_NAME)
|
||||
|
||||
const useAppStore = create<AppState & AppAction>()(
|
||||
persist(
|
||||
(set/* , get */) => ({
|
||||
(set /* , get */) => ({
|
||||
version: "0.0.1",
|
||||
hasUpdate: false,
|
||||
inited: false,
|
||||
notice: "Man! What can I say?",
|
||||
useMirror: true,
|
||||
setVersion: (version: string) => set(() => ({ version: version })),
|
||||
setHasUpdate: (hasUpdate: boolean) => set(() => ({ hasUpdate: hasUpdate })),
|
||||
setHasUpdate: (hasUpdate: boolean) =>
|
||||
set(() => ({ hasUpdate: hasUpdate })),
|
||||
setInited: (inited: boolean) => set(() => ({ inited: inited })),
|
||||
setNotice: (notice: string) => set(() => ({ notice: notice })),
|
||||
setUseMirror: (useMirror: boolean) => set(() => ({ useMirror: useMirror }))
|
||||
setUseMirror: (useMirror: boolean) =>
|
||||
set(() => ({ useMirror: useMirror })),
|
||||
}),
|
||||
{
|
||||
name: STORE_NAME, // name of item in the storage (must be unique)
|
||||
storage: createJSONStorage(() => storage), // (optional) by default the 'localStorage' is used
|
||||
},
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
export default useAppStore
|
||||
export default useAppStore
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SteamUser } from '@/types/steam'
|
||||
import { tauriStore } from '@/utils/persist'
|
||||
import { create } from 'zustand'
|
||||
import { persist, createJSONStorage } from 'zustand/middleware'
|
||||
import type { SteamUser } from "@/types/steam"
|
||||
import { tauriStore } from "@/utils/persist"
|
||||
import { create } from "zustand"
|
||||
import { createJSONStorage, persist } from "zustand/middleware"
|
||||
|
||||
const mock_user: SteamUser = {
|
||||
steamID64: "76561198052315353",
|
||||
@@ -14,20 +14,20 @@ const mock_user: SteamUser = {
|
||||
}
|
||||
|
||||
interface SteamState {
|
||||
dir: string,
|
||||
csDir: string,
|
||||
users: SteamUser[],
|
||||
isDirValid: boolean,
|
||||
isCsDirValid: boolean,
|
||||
dir: string
|
||||
csDir: string
|
||||
users: SteamUser[]
|
||||
isDirValid: boolean
|
||||
isCsDirValid: boolean
|
||||
}
|
||||
|
||||
interface SteamAction {
|
||||
setDir: (dir: string) => void,
|
||||
setCsDir: (dir: string) => void,
|
||||
setUsers: (users: SteamUser[]) => void,
|
||||
setIsDirValid: (valid: boolean) => void,
|
||||
setIsCsDirValid: (valid: boolean) => void,
|
||||
currentUser: () => SteamUser,
|
||||
setDir: (dir: string) => void
|
||||
setCsDir: (dir: string) => void
|
||||
setUsers: (users: SteamUser[]) => void
|
||||
setIsDirValid: (valid: boolean) => void
|
||||
setIsCsDirValid: (valid: boolean) => void
|
||||
currentUser: () => SteamUser
|
||||
}
|
||||
|
||||
const STORE_NAME = "steam"
|
||||
@@ -53,8 +53,8 @@ const useSteamStore = create<SteamState & SteamAction>()(
|
||||
{
|
||||
name: STORE_NAME, // name of item in the storage (must be unique)
|
||||
storage: createJSONStorage(() => storage), // (optional) by default the 'localStorage' is used
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
export default useSteamStore
|
||||
export default useSteamStore
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { tauriStore } from '@/utils/persist'
|
||||
import { create } from 'zustand'
|
||||
import { createJSONStorage, persist } from 'zustand/middleware'
|
||||
import { tauriStore } from "@/utils/persist"
|
||||
import { create } from "zustand"
|
||||
import { createJSONStorage, persist } from "zustand/middleware"
|
||||
|
||||
interface ToolState {
|
||||
launchOptions: string[]
|
||||
@@ -20,20 +20,32 @@ const { /* store, */ storage } = tauriStore(STORE_NAME)
|
||||
|
||||
const useToolStore = create<ToolState & ToolAction>()(
|
||||
persist(
|
||||
(set/* , get */) => ({
|
||||
launchOptions: ["-high -refresh 120 -novid -nojoy -tickrate 128 +cl_cmdrate 128 +cl_updaterate 128 +exec auto.cfg +test", "", ""],
|
||||
(set /* , get */) => ({
|
||||
launchOptions: [
|
||||
"-high -refresh 120 -novid -nojoy -tickrate 128 +cl_cmdrate 128 +cl_updaterate 128 +exec auto.cfg +test",
|
||||
"",
|
||||
"",
|
||||
],
|
||||
launchIndex: 0,
|
||||
powerPlan: 0,
|
||||
setLaunchOption: (option: string, index: number) => set((state) => ({ launchOptions: [...state.launchOptions.slice(0, index), option, ...state.launchOptions.slice(index + 1)] })),
|
||||
setLaunchOptions: (options: string[]) => set(() => ({ launchOptions: options })),
|
||||
setLaunchOption: (option: string, index: number) =>
|
||||
set((state) => ({
|
||||
launchOptions: [
|
||||
...state.launchOptions.slice(0, index),
|
||||
option,
|
||||
...state.launchOptions.slice(index + 1),
|
||||
],
|
||||
})),
|
||||
setLaunchOptions: (options: string[]) =>
|
||||
set(() => ({ launchOptions: options })),
|
||||
setLaunchIndex: (index: number) => set(() => ({ launchIndex: index })),
|
||||
setPowerPlan: (index: number) => set(() => ({ powerPlan: index }))
|
||||
setPowerPlan: (index: number) => set(() => ({ powerPlan: index })),
|
||||
}),
|
||||
{
|
||||
name: STORE_NAME, // name of item in the storage (must be unique)
|
||||
storage: createJSONStorage(() => storage), // (optional) by default the 'localStorage' is used
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
export default useToolStore
|
||||
export default useToolStore
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AdvancedListItem } from "@/types/common"
|
||||
import type { AdvancedListItem } from "@/types/common"
|
||||
|
||||
export interface File {
|
||||
dir: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Owner } from "@/types/cfg"
|
||||
import type { Owner } from "@/types/cfg"
|
||||
|
||||
export interface XBase {
|
||||
name: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AdvancedListItem } from "@/types/common"
|
||||
import type { AdvancedListItem } from "@/types/common"
|
||||
|
||||
export interface SteamUser extends AdvancedListItem {
|
||||
steamID64: string
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import { StateStorage } from 'zustand/middleware'
|
||||
import { Store } from "@tauri-apps/plugin-store"
|
||||
import { throttle } from 'throttle-debounce';
|
||||
import { throttle } from "throttle-debounce"
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import type { StateStorage } from "zustand/middleware"
|
||||
// import { useThrottleFn } from '@reactuses/core';
|
||||
|
||||
|
||||
// 节流设置
|
||||
export const THROTTLE_TIME = 300
|
||||
export const THROTTLE_TIME_STORE = 5000
|
||||
export const THROTTLE_LEADING = true
|
||||
export const THROTTLE_TRAILING = true
|
||||
|
||||
|
||||
// 自定义Store覆盖get, set等方法,以适应tauri+zustand
|
||||
export function tauriStore(name: string) {
|
||||
const store = new Store(`${name || "store"}.settings.json`)
|
||||
export async function tauriStore(name: string) {
|
||||
const store = await Store.load(`${name || "store"}.settings.json`)
|
||||
|
||||
// 自动保存
|
||||
const autoSave = throttle(
|
||||
@@ -24,8 +22,8 @@ export function tauriStore(name: string) {
|
||||
},
|
||||
{
|
||||
noTrailing: !THROTTLE_TRAILING,
|
||||
noLeading: !THROTTLE_LEADING
|
||||
}
|
||||
noLeading: !THROTTLE_LEADING,
|
||||
},
|
||||
)
|
||||
|
||||
const doSet = throttle(
|
||||
@@ -35,8 +33,8 @@ export function tauriStore(name: string) {
|
||||
},
|
||||
{
|
||||
noTrailing: !THROTTLE_TRAILING,
|
||||
noLeading: !THROTTLE_LEADING
|
||||
}
|
||||
noLeading: !THROTTLE_LEADING,
|
||||
},
|
||||
)
|
||||
|
||||
const set = (key: string, value: unknown) => {
|
||||
|
||||
Reference in New Issue
Block a user