[feat] use heroui + setup persistore + setup toast

todo: fix launchoption problem
This commit is contained in:
Purp1e
2025-03-12 11:22:32 +08:00
parent 2ef6d2c298
commit 9103150562
27 changed files with 745 additions and 264 deletions

View File

@@ -2,7 +2,7 @@
import Header from "@/components/window/Header"
import Nav from "@/components/window/Nav"
import SideBar from "@/components/window/SideBar"
import clsx from "clsx"
import { cn } from "@heroui/react"
// import { platform } from "@tauri-apps/plugin-os"
export default function BaseLayout({
@@ -11,7 +11,7 @@ export default function BaseLayout({
children: React.ReactNode
}) {
return (
<div className="w-full h-full bg-transparent">
<div className="w-full h-full p-0 m-0 bg-transparent">
{/* bg-[#f1f0f2] */}
<Nav />
@@ -19,7 +19,7 @@ export default function BaseLayout({
<SideBar />
<main
className={clsx(
className={cn(
"flex flex-col h-full pb-5 pr-5 ml-20 overflow-hidden",
// platform() === "windows" ? "ml-20" : "ml-[4.25rem]"
)}

View File

@@ -1,11 +1,12 @@
"use client"
import useAppStore from "@/store/app"
import { appStore } from "@/store/app"
import { useSnapshot } from "valtio"
export default function Page() {
const app = useAppStore()
const app = useSnapshot(appStore.state)
return (
<div className="flex flex-col items-start gap-3 pt-2 pb-1">
<div className="flex flex-col gap-3 items-start pt-2 pb-1">
<p>{app.version}</p>
<p>{app.hasUpdate ? "有" : "无"}</p>
<p>{app.inited ? "是" : "否"}</p>

View File

@@ -14,7 +14,7 @@ import {
UploadOne,
Videocamera,
} from "@icon-park/react"
import clsx from "clsx"
import { cn } from "@heroui/react"
import { usePathname, useRouter } from "next/navigation"
// import { platform } from "@tauri-apps/plugin-os"
@@ -30,21 +30,21 @@ export default function PreferenceLayout({
<CardIcon
type="menu"
onClick={() => router.push("/preference/general")}
className={clsx(pathname === "/preference/general" && "bg-black/5")}
className={cn(pathname === "/preference/general" && "bg-black/5")}
>
<SettingConfig />
</CardIcon>
<CardIcon
type="menu"
onClick={() => router.push("/preference/path")}
className={clsx(pathname === "/preference/path" && "bg-black/5")}
className={cn(pathname === "/preference/path" && "bg-black/5")}
>
<AssemblyLine />
</CardIcon>
<CardIcon
type="menu"
onClick={() => router.push("/preference/replay")}
className={clsx(pathname === "/preference/replay" && "bg-black/5")}
className={cn(pathname === "/preference/replay" && "bg-black/5")}
>
<Videocamera />
</CardIcon>

View File

@@ -1,8 +0,0 @@
import "@/styles/globals.css"
import type { AppProps } from "next/app"
function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
export default MyApp

View File

@@ -1,10 +1,12 @@
export const metadata = {
title: "CS工具箱",
description: "Generated by Next.js",
icons: ["/favicon.ico"],
}
"use client"
// export const metadata = {
// title: "CS工具箱",
// description: "Generated by Next.js",
// icons: ["/favicon.ico"],
// }
import "./globals.css"
import Providers from "./providers"
export default function RootLayout({
children,
@@ -13,7 +15,9 @@ export default function RootLayout({
}) {
return (
<html lang="en">
<body>{children}</body>
<body>
<Providers>{children}</Providers>
</body>
</html>
)
}

12
src/app/providers.tsx Normal file
View File

@@ -0,0 +1,12 @@
"use client"
import { HeroUIProvider } from "@heroui/react"
import { ToastProvider } from "@heroui/toast"
export default function Providers({ children }: { children: React.ReactNode }) {
return (
<HeroUIProvider className="h-full bg-transparent">
<ToastProvider toastOffset={10} placement="top-center" />
{children}
</HeroUIProvider>
)
}