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 { Box, IconButton, Modal, Tooltip, Typography } from "@mui/material";
import { FC, ReactNode } from "react";
import { useSettings } from "../../contexts/SettingsContext";
interface FloatingDialog {
sx?: any;

View file

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

View file

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