config dir async import

This commit is contained in:
Vomitblood 2024-08-05 21:03:36 +08:00
parent 50e8016b14
commit 8a8b5fcbc2
3 changed files with 32 additions and 7 deletions

View file

@ -1,6 +1,7 @@
import { Close, UnfoldLess, UnfoldMore } from "@mui/icons-material"; import { Close, UnfoldLess, UnfoldMore } from "@mui/icons-material";
import { Box, IconButton, Modal, Tooltip, Typography } from "@mui/material"; import { Box, IconButton, Modal, Tooltip, Typography } from "@mui/material";
import { FC, ReactNode } from "react"; import { FC, ReactNode } from "react";
import { useSettings } from "../../contexts/SettingsContext";
interface FloatingDialog { interface FloatingDialog {
sx?: any; sx?: any;

View file

@ -1,8 +1,11 @@
import { Box, Button, IconButton, Typography } from "@mui/material"; import { Box, Button, IconButton, Typography } from "@mui/material";
import { WindowButtons } from "./WindowButtons"; import { WindowButtons } from "./WindowButtons";
import { BugReport } from "@mui/icons-material"; import { BugReport } from "@mui/icons-material";
import { useRouter } from "next/router";
export const HeaderBar = () => { export const HeaderBar = () => {
const router = useRouter();
return ( return (
<Box <Box
className="titlebar" className="titlebar"
@ -38,7 +41,11 @@ export const HeaderBar = () => {
flexDirection: "row", flexDirection: "row",
}} }}
> >
<IconButton href="/testing"> <IconButton
onClick={() => {
router.push("/testing");
}}
>
<BugReport /> <BugReport />
</IconButton> </IconButton>
<WindowButtons /> <WindowButtons />

View file

@ -1,24 +1,41 @@
"use client";
import { BugReport } from "@mui/icons-material"; import { BugReport } from "@mui/icons-material";
import { Box, Button, IconButton } from "@mui/material"; import { Box, Button, IconButton, Typography } from "@mui/material";
import { configDir } from "@tauri-apps/api/path"; import { useRouter } from "next/router";
import { useEffect, useState } from "react";
export default function Testing() { export default function Testing() {
const testing = async () => { const router = useRouter();
console.log(await configDir());
const [configDir, setConfigDir] = useState<string>("");
const initializeConfigDir = async () => {
const { appConfigDir } = await import("@tauri-apps/api/path");
setConfigDir(await appConfigDir());
}; };
useEffect(() => {
initializeConfigDir();
});
return ( return (
<Box> <Box>
<IconButton href="/"> <IconButton
onClick={() => {
router.push("/");
}}
>
<BugReport /> <BugReport />
</IconButton> </IconButton>
<Button <Button
onClick={() => { onClick={() => {
testing(); console.log(configDir);
}} }}
> >
Button Button
</Button> </Button>
<Typography>{configDir}</Typography>
</Box> </Box>
); );
} }