Skip to content

Commit 623dbe8

Browse files
committed
feat: add new window functionality and improve UI in Introduce component
Enhanced the Introduce component by adding a button to open a new window, utilizing the Tauri invoke method for functionality. Integrated translation support for the button label and improved the layout by organizing the settings link and new window button within a flex container for better UI presentation.
1 parent a3f34b4 commit 623dbe8

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/components/common/Introduce.tsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@ import {
66
} from "@/components/ui/accordion";
77
import { Button } from "../ui/button";
88
import { open } from "@tauri-apps/plugin-shell";
9-
import { Github, Twitter } from "lucide-react";
9+
import { ExternalLink, Github, Twitter } from "lucide-react";
1010
import { SimpleGitWorktreeSettings } from "../settings/GitWorktreeSettings";
1111
import { Link } from "react-router-dom";
1212
import { Switch } from "../ui/switch";
1313
import { useSettingsStore } from "@/stores/settings/SettingsStore";
14+
import { useTranslation } from "react-i18next";
15+
import { invoke } from "@/lib/tauri-proxy";
1416

1517
export function Introduce() {
1618
const { enableTaskCompleteBeep, setEnableTaskCompleteBeep } = useSettingsStore();
19+
const { t } = useTranslation();
20+
21+
const handleNewWindow = async () => {
22+
try {
23+
await invoke("create_new_window");
24+
} catch (error) {
25+
console.error("Failed to create new window:", error);
26+
}
27+
};
1728

1829
return (
1930
<Accordion
@@ -25,12 +36,20 @@ export function Introduce() {
2536
<AccordionItem value="item-1">
2637
<AccordionTrigger>Settings</AccordionTrigger>
2738
<AccordionContent className="flex flex-col gap-4 text-balance">
28-
<Link
29-
to="/settings"
30-
className="flex hover:text-primary items-center justify-end"
31-
>
32-
More Settings
33-
</Link>
39+
<div className="flex justify-between">
40+
<Button
41+
onClick={handleNewWindow}
42+
title={t("header.openNewWindow")}
43+
>
44+
<ExternalLink /> {t("header.openNewWindow")}
45+
</Button>
46+
<Link
47+
to="/settings"
48+
className="flex hover:text-primary items-center justify-end"
49+
>
50+
More Settings
51+
</Link>
52+
</div>
3453
<SimpleGitWorktreeSettings />
3554
<div className="flex items-start justify-between gap-4 rounded-md border p-4">
3655
<div>

0 commit comments

Comments
 (0)