dev-store #1
28
.github/dependabot.yml
vendored
28
.github/dependabot.yml
vendored
@@ -1,28 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
# Enable version updates for Node.js dependencies
|
|
||||||
- package-ecosystem: "npm"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
allow:
|
|
||||||
- dependency-type: "all"
|
|
||||||
groups:
|
|
||||||
all:
|
|
||||||
patterns:
|
|
||||||
- "*"
|
|
||||||
ignore:
|
|
||||||
- dependency-name: "eslint"
|
|
||||||
versions: ">= 9"
|
|
||||||
|
|
||||||
# Enable version updates for rust
|
|
||||||
- package-ecosystem: "cargo"
|
|
||||||
directory: "/src-tauri"
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
allow:
|
|
||||||
- dependency-type: "all"
|
|
||||||
groups:
|
|
||||||
all:
|
|
||||||
patterns:
|
|
||||||
- "*"
|
|
||||||
34
.github/workflows/dependabot-automerge.yml
vendored
34
.github/workflows/dependabot-automerge.yml
vendored
@@ -1,34 +0,0 @@
|
|||||||
# Automatically squashes and merges Dependabot dependency upgrades if tests pass
|
|
||||||
|
|
||||||
name: Dependabot Auto-merge
|
|
||||||
|
|
||||||
on: pull_request_target
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
pull-requests: write
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
dependabot:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
if: ${{ github.actor == 'dependabot[bot]' }}
|
|
||||||
steps:
|
|
||||||
- name: Fetch Dependabot metadata
|
|
||||||
id: dependabot-metadata
|
|
||||||
uses: dependabot/fetch-metadata@v1.3.3
|
|
||||||
with:
|
|
||||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
|
|
||||||
- name: Approve Dependabot PR
|
|
||||||
run: gh pr review --approve "$PR_URL"
|
|
||||||
env:
|
|
||||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Auto-merge (squash) Dependabot PR
|
|
||||||
if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
|
|
||||||
run: gh pr merge --auto --squash "$PR_URL"
|
|
||||||
env:
|
|
||||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
46
.github/workflows/lint-js.yml
vendored
46
.github/workflows/lint-js.yml
vendored
@@ -1,46 +0,0 @@
|
|||||||
# Installs Node.js dependencies and pnpm, and checks formatting + linting
|
|
||||||
|
|
||||||
name: Lint Node.js
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- "src-tauri/**"
|
|
||||||
- "README.md"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
fail-fast: true
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Disable git core.autocrlf on Windows
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
run: git config --global core.autocrlf false
|
|
||||||
|
|
||||||
- name: Checkout repository code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up pnpm package manager
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
|
|
||||||
- name: Set up Node.js v22
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
cache: "pnpm"
|
|
||||||
|
|
||||||
- name: Install dependencies from lockfile
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
|
|
||||||
- name: Run lint step
|
|
||||||
run: pnpm lint
|
|
||||||
55
.github/workflows/lint-rs.yml
vendored
55
.github/workflows/lint-rs.yml
vendored
@@ -1,55 +0,0 @@
|
|||||||
# Installs Rust and checks formatting + linting
|
|
||||||
|
|
||||||
name: Lint Rust
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- "src/**"
|
|
||||||
- "package.json"
|
|
||||||
- "package-lock.json"
|
|
||||||
- "yarn.lock"
|
|
||||||
- "pnpm-lock.yaml"
|
|
||||||
- "README.md"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
fail-fast: true
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Disable git core.autocrlf on Windows
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
run: git config --global core.autocrlf false
|
|
||||||
|
|
||||||
- name: Checkout repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
components: rustfmt, clippy
|
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt install libdbus-1-dev libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
|
|
||||||
|
|
||||||
- name: Create empty 'out' directory
|
|
||||||
run: mkdir out
|
|
||||||
|
|
||||||
- name: Run rustfmt check
|
|
||||||
run: cargo fmt --all -- --check
|
|
||||||
working-directory: src-tauri
|
|
||||||
|
|
||||||
- name: Run clippy check and deny warnings
|
|
||||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
|
||||||
working-directory: src-tauri
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeBuildCommand": "pnpm next-build",
|
"beforeBuildCommand": "bun next-build",
|
||||||
"beforeDevCommand": "pnpm next-start",
|
"beforeDevCommand": "bun next-start",
|
||||||
"frontendDist": "../out",
|
"frontendDist": "../out",
|
||||||
"devUrl": "http://localhost:3000"
|
"devUrl": "http://localhost:3000"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { appStore } from "@/store/app"
|
import { appStore } from "@/store/app"
|
||||||
import { useEffect } from "react"
|
|
||||||
import { useSnapshot } from "valtio"
|
import { useSnapshot } from "valtio"
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
appStore.start()
|
void appStore.start()
|
||||||
const app = useSnapshot(appStore.state)
|
const app = useSnapshot(appStore.state)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
CardTool,
|
CardTool,
|
||||||
} from "@/components/window/Card"
|
} from "@/components/window/Card"
|
||||||
import { ToolButton } from "@/components/window/ToolButton"
|
import { ToolButton } from "@/components/window/ToolButton"
|
||||||
|
import { cn } from "@heroui/react"
|
||||||
import {
|
import {
|
||||||
AssemblyLine,
|
AssemblyLine,
|
||||||
HardDisk,
|
HardDisk,
|
||||||
@@ -14,7 +15,6 @@ import {
|
|||||||
UploadOne,
|
UploadOne,
|
||||||
Videocamera,
|
Videocamera,
|
||||||
} from "@icon-park/react"
|
} from "@icon-park/react"
|
||||||
import { cn } from "@heroui/react"
|
|
||||||
import { usePathname, useRouter } from "next/navigation"
|
import { usePathname, useRouter } from "next/navigation"
|
||||||
// import { platform } from "@tauri-apps/plugin-os"
|
// import { platform } from "@tauri-apps/plugin-os"
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { currentUser, steamStore } from "@/store/steam"
|
import { currentUser, steamStore } from "@/store/steam"
|
||||||
import { useEffect } from "react"
|
|
||||||
import { useSnapshot } from "valtio"
|
import { useSnapshot } from "valtio"
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
steamStore.start()
|
void steamStore.start()
|
||||||
const steam = useSnapshot(steamStore.state)
|
const steam = useSnapshot(steamStore.state)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import React from "react"
|
|
||||||
import { useRouter } from "next/navigation"
|
|
||||||
import { open } from "@tauri-apps/plugin-dialog"
|
import { open } from "@tauri-apps/plugin-dialog"
|
||||||
|
import { useRouter } from "next/navigation"
|
||||||
|
import React from "react"
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -21,7 +21,9 @@ const Home = () => {
|
|||||||
className="flex flex-col items-center justify-center w-full h-screen gap-6"
|
className="flex flex-col items-center justify-center w-full h-screen gap-6"
|
||||||
data-tauri-drag-region
|
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>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => router.push("/home")}
|
onClick={() => router.push("/home")}
|
||||||
@@ -29,7 +31,11 @@ const Home = () => {
|
|||||||
>
|
>
|
||||||
进入
|
进入
|
||||||
</button>
|
</button>
|
||||||
<button type="button" onClick={openFile} className="px-4 py-1 text-white bg-blue-500 rounded">
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={openFile}
|
||||||
|
className="px-4 py-1 text-white bg-blue-500 rounded"
|
||||||
|
>
|
||||||
选择文件
|
选择文件
|
||||||
</button>
|
</button>
|
||||||
<p className="text-center bg-zinc-50">{file}</p>
|
<p className="text-center bg-zinc-50">{file}</p>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { steamStore, setDir, setCsDir, currentUser } from "@/store/steam"
|
import { currentUser, setCsDir, setDir, steamStore } from "@/store/steam"
|
||||||
import { useEffect } from "react"
|
|
||||||
import { useSnapshot } from "valtio"
|
import { useSnapshot } from "valtio"
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
steamStore.start()
|
void steamStore.start()
|
||||||
const steam = useSnapshot(steamStore.state)
|
const steam = useSnapshot(steamStore.state)
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { ThemeProvider as NextThemesProvider } from "next-themes"
|
|||||||
export default function Providers({ children }: { children: React.ReactNode }) {
|
export default function Providers({ children }: { children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<HeroUIProvider className="h-full bg-transparent">
|
<HeroUIProvider className="h-full bg-transparent">
|
||||||
<NextThemesProvider attribute="class" defaultTheme="light" >
|
<NextThemesProvider attribute="class" defaultTheme="light">
|
||||||
<ToastProvider toastOffset={10} placement="top-center" />
|
<ToastProvider toastOffset={10} placement="top-center" />
|
||||||
{children}
|
{children}
|
||||||
</NextThemesProvider>
|
</NextThemesProvider>
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { toolStore, setLaunchOption, setLaunchIndex } from "@/store/tool"
|
import { setLaunchIndex, setLaunchOption, toolStore } from "@/store/tool"
|
||||||
import { Plus, SettingConfig, Switch } from "@icon-park/react"
|
import { Plus, SettingConfig, Switch } from "@icon-park/react"
|
||||||
|
import { useSnapshot } from "valtio"
|
||||||
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
|
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
|
||||||
import { ToolButton } from "../window/ToolButton"
|
import { ToolButton } from "../window/ToolButton"
|
||||||
import { useSnapshot } from "valtio"
|
|
||||||
import { use, useEffect, useState } from "react"
|
|
||||||
|
|
||||||
const LaunchOption = () => {
|
const LaunchOption = () => {
|
||||||
toolStore.start()
|
void toolStore.start()
|
||||||
const { launchOptions, launchIndex } = useSnapshot(toolStore.state)
|
const { launchOptions, launchIndex } = useSnapshot(toolStore.state)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -33,7 +32,9 @@ const LaunchOption = () => {
|
|||||||
<textarea
|
<textarea
|
||||||
placeholder="请输入启动选项"
|
placeholder="请输入启动选项"
|
||||||
value={launchOptions[launchIndex] || ""}
|
value={launchOptions[launchIndex] || ""}
|
||||||
onChange={(e) => launchIndex !== -1 && setLaunchOption(e.target.value, launchIndex)}
|
onChange={(e) =>
|
||||||
|
launchIndex !== -1 && setLaunchOption(e.target.value, launchIndex)
|
||||||
|
}
|
||||||
className="w-full font-mono text-base bg-transparent outline-none resize-none min-h-20"
|
className="w-full font-mono text-base bg-transparent outline-none resize-none min-h-20"
|
||||||
/>
|
/>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "@/components/window/Card"
|
import {
|
||||||
|
Card,
|
||||||
|
CardBody,
|
||||||
|
CardHeader,
|
||||||
|
CardIcon,
|
||||||
|
CardTool,
|
||||||
|
} from "@/components/window/Card"
|
||||||
import { appStore } from "@/store/app"
|
import { appStore } from "@/store/app"
|
||||||
import { Refresh, VolumeNotice } from "@icon-park/react"
|
import { Refresh, VolumeNotice } from "@icon-park/react"
|
||||||
import { ToolButton } from "../window/ToolButton"
|
|
||||||
import { useSnapshot } from "valtio"
|
import { useSnapshot } from "valtio"
|
||||||
import { useEffect } from "react"
|
import { ToolButton } from "../window/ToolButton"
|
||||||
|
|
||||||
const Notice = () => {
|
const Notice = () => {
|
||||||
appStore.start()
|
void appStore.start()
|
||||||
const app = useSnapshot(appStore.state)
|
const app = useSnapshot(appStore.state)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -22,7 +27,9 @@ const Notice = () => {
|
|||||||
</ToolButton>
|
</ToolButton>
|
||||||
</CardTool>
|
</CardTool>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardBody>{app.notice || "不会真的有人要更新CSGO工具箱吧,不会吧不会吧 xswl"}</CardBody>
|
<CardBody>
|
||||||
|
{app.notice || "不会真的有人要更新CSGO工具箱吧,不会吧不会吧 xswl"}
|
||||||
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,18 @@
|
|||||||
import { resetAppStore } from "@/store/app"
|
import { resetAppStore } from "@/store/app"
|
||||||
import { resetToolStore } from "@/store/tool"
|
import { resetToolStore } from "@/store/tool"
|
||||||
import { addToast } from "@heroui/react"
|
import { addToast } from "@heroui/react"
|
||||||
import { Close, Minus, Moon, Refresh, RefreshOne, RocketOne, Square, Sun, SunOne } from "@icon-park/react"
|
import {
|
||||||
import { useTheme } from "next-themes"
|
Close,
|
||||||
|
Minus,
|
||||||
|
Moon,
|
||||||
|
Refresh,
|
||||||
|
RocketOne,
|
||||||
|
Square,
|
||||||
|
SunOne,
|
||||||
|
} from "@icon-park/react"
|
||||||
import { getCurrentWindow } from "@tauri-apps/api/window"
|
import { getCurrentWindow } from "@tauri-apps/api/window"
|
||||||
import { /* relaunch, */ exit, relaunch } from "@tauri-apps/plugin-process"
|
import { /* relaunch, */ exit } from "@tauri-apps/plugin-process"
|
||||||
|
import { useTheme } from "next-themes"
|
||||||
// import { platform } from "@tauri-apps/plugin-os"
|
// import { platform } from "@tauri-apps/plugin-os"
|
||||||
import { usePathname, useRouter } from "next/navigation"
|
import { usePathname, useRouter } from "next/navigation"
|
||||||
|
|
||||||
@@ -41,7 +49,10 @@ const Nav = () => {
|
|||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
|
|
||||||
return (
|
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
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="px-2 py-0 transition duration-150 rounded hover:bg-zinc-200/80 active:scale-95"
|
className="px-2 py-0 transition duration-150 rounded hover:bg-zinc-200/80 active:scale-95"
|
||||||
@@ -50,7 +61,7 @@ const Nav = () => {
|
|||||||
resetToolStore()
|
resetToolStore()
|
||||||
addToast({
|
addToast({
|
||||||
title: "重置成功",
|
title: "重置成功",
|
||||||
color: 'success'
|
color: "success",
|
||||||
// description: "已重置所有设置",
|
// description: "已重置所有设置",
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
@@ -61,7 +72,9 @@ const Nav = () => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="px-2 py-0 transition duration-150 rounded hover:bg-zinc-200/80 active:scale-95"
|
className="px-2 py-0 transition duration-150 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} />
|
<RocketOne size={16} />
|
||||||
</button>
|
</button>
|
||||||
@@ -69,7 +82,9 @@ const Nav = () => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="px-2 py-0 transition duration-150 rounded hover:bg-zinc-200/80 active:scale-95"
|
className="px-2 py-0 transition duration-150 rounded hover:bg-zinc-200/80 active:scale-95"
|
||||||
onClick={() => (theme === "light" ? setTheme("dark") : setTheme("light"))}
|
onClick={() =>
|
||||||
|
theme === "light" ? setTheme("dark") : setTheme("light")
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{theme === "light" ? <SunOne size={16} /> : <Moon size={16} />}
|
{theme === "light" ? <SunOne size={16} /> : <Moon size={16} />}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { Home, MonitorOne, Movie, Setting, Terminal, Toolkit } from "@icon-park/react"
|
|
||||||
import { Button, cn } from "@heroui/react"
|
import { Button, cn } from "@heroui/react"
|
||||||
|
import {
|
||||||
|
Home,
|
||||||
|
MonitorOne,
|
||||||
|
Movie,
|
||||||
|
Setting,
|
||||||
|
Terminal,
|
||||||
|
Toolkit,
|
||||||
|
} from "@icon-park/react"
|
||||||
import { usePathname, useRouter } from "next/navigation"
|
import { usePathname, useRouter } from "next/navigation"
|
||||||
import { useEffect, type ReactNode } from "react"
|
import type { ReactNode } from "react"
|
||||||
|
|
||||||
// import { platform } from "@tauri-apps/plugin-os"
|
// import { platform } from "@tauri-apps/plugin-os"
|
||||||
import { appStore, setVersion } from "@/store/app"
|
import { appStore, setVersion } from "@/store/app"
|
||||||
@@ -30,7 +37,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}
|
||||||
>
|
>
|
||||||
@@ -38,7 +45,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>
|
||||||
@@ -54,7 +61,7 @@ const Avatar = () => {
|
|||||||
onKeyUp={() => router.push("/users")}
|
onKeyUp={() => 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",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<img src="favicon.ico" alt="avatar" draggable={false} />
|
<img src="favicon.ico" alt="avatar" draggable={false} />
|
||||||
@@ -63,13 +70,13 @@ const Avatar = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SideBar = () => {
|
const SideBar = () => {
|
||||||
appStore.start()
|
void appStore.start()
|
||||||
const { version } = useSnapshot(appStore.state)
|
const { version } = useSnapshot(appStore.state)
|
||||||
|
|
||||||
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
|
||||||
@@ -102,7 +109,10 @@ const SideBar = () => {
|
|||||||
</SideButton>
|
</SideButton>
|
||||||
</section>
|
</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>版本号</p>
|
||||||
<Button
|
<Button
|
||||||
variant="light"
|
variant="light"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { store } from 'tauri-plugin-valtio';
|
import { store } from "tauri-plugin-valtio"
|
||||||
import { DEFAULT_STORE_CONFIG } from '.';
|
import { DEFAULT_STORE_CONFIG } from "."
|
||||||
|
|
||||||
// Usage:
|
// Usage:
|
||||||
// import {appStore} from "@/store/app"
|
// import {appStore} from "@/store/app"
|
||||||
@@ -13,16 +13,26 @@ const defaultValue = {
|
|||||||
hasUpdate: false,
|
hasUpdate: false,
|
||||||
inited: false,
|
inited: false,
|
||||||
notice: "",
|
notice: "",
|
||||||
useMirror: true
|
useMirror: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const appStore = store('app', { ...defaultValue }, DEFAULT_STORE_CONFIG);
|
export const appStore = store("app", { ...defaultValue }, DEFAULT_STORE_CONFIG)
|
||||||
|
|
||||||
export const setVersion = (version: string) => { appStore.state.version = version }
|
export const setVersion = (version: string) => {
|
||||||
export const setHasUpdate = (hasUpdate: boolean) => { appStore.state.hasUpdate = hasUpdate }
|
appStore.state.version = version
|
||||||
export const setInited = (inited: boolean) => { appStore.state.inited = inited }
|
}
|
||||||
export const setNotice = (notice: string) => { appStore.state.notice = notice }
|
export const setHasUpdate = (hasUpdate: boolean) => {
|
||||||
export const setUseMirror = (useMirror: boolean) => { appStore.state.useMirror = useMirror }
|
appStore.state.hasUpdate = hasUpdate
|
||||||
|
}
|
||||||
|
export const setInited = (inited: boolean) => {
|
||||||
|
appStore.state.inited = inited
|
||||||
|
}
|
||||||
|
export const setNotice = (notice: string) => {
|
||||||
|
appStore.state.notice = notice
|
||||||
|
}
|
||||||
|
export const setUseMirror = (useMirror: boolean) => {
|
||||||
|
appStore.state.useMirror = useMirror
|
||||||
|
}
|
||||||
|
|
||||||
export const resetAppStore = () => {
|
export const resetAppStore = () => {
|
||||||
setVersion(defaultValue.version)
|
setVersion(defaultValue.version)
|
||||||
@@ -30,4 +40,4 @@ export const resetAppStore = () => {
|
|||||||
setInited(defaultValue.inited)
|
setInited(defaultValue.inited)
|
||||||
setNotice(defaultValue.notice)
|
setNotice(defaultValue.notice)
|
||||||
setUseMirror(defaultValue.useMirror)
|
setUseMirror(defaultValue.useMirror)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export const DEFAULT_STORE_CONFIG = {
|
export const DEFAULT_STORE_CONFIG = {
|
||||||
saveOnChange: true,
|
saveOnChange: true,
|
||||||
saveOnExit: true,
|
saveOnExit: true,
|
||||||
saveStrategy: 'debounce' as const,
|
saveStrategy: "debounce" as const,
|
||||||
saveInterval: 3000,
|
saveInterval: 3000,
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,28 +1,44 @@
|
|||||||
import type { SteamUser } from "@/types/steam"
|
import type { SteamUser } from "@/types/steam"
|
||||||
import { store } from 'tauri-plugin-valtio';
|
import { store } from "tauri-plugin-valtio"
|
||||||
import { DEFAULT_STORE_CONFIG } from '.';
|
import { DEFAULT_STORE_CONFIG } from "."
|
||||||
|
|
||||||
const defaultValue = {
|
const defaultValue = {
|
||||||
dir: "C:\\Program Files (x86)\\Steam",
|
dir: "C:\\Program Files (x86)\\Steam",
|
||||||
csDir: "",
|
csDir: "",
|
||||||
users: [{
|
users: [
|
||||||
steamID64: "76561198052315353",
|
{
|
||||||
steamID32: "STEAM_0:0:46157676",
|
steamID64: "76561198052315353",
|
||||||
accountName: "wrr",
|
steamID32: "STEAM_0:0:46157676",
|
||||||
personaName: "wrr",
|
accountName: "wrr",
|
||||||
recent: 0,
|
personaName: "wrr",
|
||||||
avatar: ""
|
recent: 0,
|
||||||
}] as SteamUser[],
|
avatar: "",
|
||||||
|
},
|
||||||
|
] as SteamUser[],
|
||||||
isDirValid: false,
|
isDirValid: false,
|
||||||
isCsDirValid: false
|
isCsDirValid: false,
|
||||||
}
|
}
|
||||||
export const steamStore = store('steam', {...defaultValue}, DEFAULT_STORE_CONFIG);
|
export const steamStore = store(
|
||||||
|
"steam",
|
||||||
|
{ ...defaultValue },
|
||||||
|
DEFAULT_STORE_CONFIG,
|
||||||
|
)
|
||||||
|
|
||||||
export const setDir = (dir: string) => { steamStore.state.dir = dir }
|
export const setDir = (dir: string) => {
|
||||||
export const setCsDir = (dir: string) => { steamStore.state.csDir = dir }
|
steamStore.state.dir = dir
|
||||||
export const setUsers = (users: SteamUser[]) => { steamStore.state.users = users }
|
}
|
||||||
export const setIsDirValid = (valid: boolean) => { steamStore.state.isDirValid = valid }
|
export const setCsDir = (dir: string) => {
|
||||||
export const setIsCsDirValid = (valid: boolean) => { steamStore.state.isCsDirValid = valid }
|
steamStore.state.csDir = dir
|
||||||
|
}
|
||||||
|
export const setUsers = (users: SteamUser[]) => {
|
||||||
|
steamStore.state.users = users
|
||||||
|
}
|
||||||
|
export const setIsDirValid = (valid: boolean) => {
|
||||||
|
steamStore.state.isDirValid = valid
|
||||||
|
}
|
||||||
|
export const setIsCsDirValid = (valid: boolean) => {
|
||||||
|
steamStore.state.isCsDirValid = valid
|
||||||
|
}
|
||||||
|
|
||||||
export const currentUser = () => {
|
export const currentUser = () => {
|
||||||
return steamStore.state.users[0] || defaultValue.users[0]
|
return steamStore.state.users[0] || defaultValue.users[0]
|
||||||
@@ -34,4 +50,4 @@ export const resetSteamStore = () => {
|
|||||||
setUsers(defaultValue.users)
|
setUsers(defaultValue.users)
|
||||||
setIsDirValid(defaultValue.isDirValid)
|
setIsDirValid(defaultValue.isDirValid)
|
||||||
setIsCsDirValid(defaultValue.isCsDirValid)
|
setIsCsDirValid(defaultValue.isCsDirValid)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,27 @@
|
|||||||
import { store } from 'tauri-plugin-valtio';
|
import { store } from "tauri-plugin-valtio"
|
||||||
import { DEFAULT_STORE_CONFIG } from '.';
|
import { DEFAULT_STORE_CONFIG } from "."
|
||||||
|
|
||||||
const defaultValue = {
|
const defaultValue = {
|
||||||
launchOptions: [
|
launchOptions: [
|
||||||
"-novid -high -freq 144 -fullscreen",
|
"-novid -high -freq 144 -fullscreen",
|
||||||
"-novid -high -w 1920 -h 1080 -freq 144 -sw -noborder",
|
"-novid -high -w 1920 -h 1080 -freq 144 -sw -noborder",
|
||||||
"-novid -high -freq 144 -fullscreen -allow_third_party_software"
|
"-novid -high -freq 144 -fullscreen -allow_third_party_software",
|
||||||
] as string[],
|
] as string[],
|
||||||
launchIndex: 0,
|
launchIndex: 0,
|
||||||
powerPlan: 0
|
powerPlan: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const toolStore = store('tool', { ...defaultValue }, DEFAULT_STORE_CONFIG);
|
export const toolStore = store(
|
||||||
|
"tool",
|
||||||
|
{ ...defaultValue },
|
||||||
|
DEFAULT_STORE_CONFIG,
|
||||||
|
)
|
||||||
|
|
||||||
export const setLaunchOption = (option: string, index: number) => {
|
export const setLaunchOption = (option: string, index: number) => {
|
||||||
toolStore.state.launchOptions = [
|
toolStore.state.launchOptions = [
|
||||||
...toolStore.state.launchOptions.slice(0, index),
|
...toolStore.state.launchOptions.slice(0, index),
|
||||||
option,
|
option,
|
||||||
...toolStore.state.launchOptions.slice(index + 1)
|
...toolStore.state.launchOptions.slice(index + 1),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
import { Store } from "@tauri-apps/plugin-store"
|
|
||||||
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 = 2000
|
|
||||||
export const THROTTLE_LEADING = true
|
|
||||||
export const THROTTLE_TRAILING = true
|
|
||||||
|
|
||||||
// 自定义Store覆盖get, set等方法,以适应tauri+zustand
|
|
||||||
export async function tauriStore(name: string) {
|
|
||||||
const store = await Store.load(`${name || "store"}.settings.json`, {
|
|
||||||
autoSave: THROTTLE_TIME_STORE,
|
|
||||||
})
|
|
||||||
|
|
||||||
const doSet = throttle(
|
|
||||||
THROTTLE_TIME,
|
|
||||||
async (key: string, value: unknown) => await store.set(key, value),
|
|
||||||
{
|
|
||||||
noTrailing: !THROTTLE_TRAILING,
|
|
||||||
noLeading: !THROTTLE_LEADING,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
const set = (key: string, value: unknown) => {
|
|
||||||
doSet(key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const get = async (key: string) => await store.get(key)
|
|
||||||
|
|
||||||
// 自定义存储对象
|
|
||||||
const storage: StateStorage = {
|
|
||||||
setItem: async (name: string, value: string): Promise<void> => {
|
|
||||||
await store.set(name, value)
|
|
||||||
// console.log(name, 'has been set to', value)
|
|
||||||
},
|
|
||||||
getItem: async (name: string): Promise<string | null> => {
|
|
||||||
// console.log(name, 'has been get')
|
|
||||||
return (await store.get(name)) || null
|
|
||||||
},
|
|
||||||
removeItem: async (name: string): Promise<void> => {
|
|
||||||
// console.log(name, 'has been deleted')
|
|
||||||
await store.delete(name)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return { store, get, set, storage }
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import { Store } from "@tauri-apps/plugin-store"
|
|
||||||
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 = 2000
|
|
||||||
export const THROTTLE_LEADING = true
|
|
||||||
export const THROTTLE_TRAILING = true
|
|
||||||
|
|
||||||
// 自定义Store覆盖get, set等方法,以适应tauri+zustand
|
|
||||||
export async function tauriStore(name: string) {
|
|
||||||
const store = await Store.load(`${name || "store"}.settings.json`, {
|
|
||||||
autoSave: THROTTLE_TIME_STORE,
|
|
||||||
})
|
|
||||||
|
|
||||||
const doSet = throttle(
|
|
||||||
THROTTLE_TIME,
|
|
||||||
async (key: string, value: unknown) => await store.set(key, value),
|
|
||||||
{
|
|
||||||
noTrailing: !THROTTLE_TRAILING,
|
|
||||||
noLeading: !THROTTLE_LEADING,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
const set = (key: string, value: unknown) => {
|
|
||||||
doSet(key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const get = async (key: string) => await store.get(key)
|
|
||||||
|
|
||||||
|
|
||||||
return { store, get, set }
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user