Skip to content

Commit

Permalink
✨ 实现一部分安装插件的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
zty012 committed Dec 7, 2024
1 parent fc0bf4e commit 8c5e240
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/pages/settings/plugins.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
import { open as openFile } from "@tauri-apps/plugin-dialog";
import { open } from "@tauri-apps/plugin-shell";
import { BookOpen, Box, PartyPopper, Plug, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import Button from "../../components/ui/Button";
import Switch from "../../components/ui/Switch";
import { useDialog } from "../../utils/dialog";
import { Field } from "./_field";

export default function PluginsPage() {
const { t } = useTranslation("plugins");
const dialog = useDialog();

const install = async () => {
const path = await openFile({
filters: [
{
name: "Plugin",
extensions: ["pg-plugin"],
},
],
});
if (!path) return;
await dialog.show({
title: t("install.warning.title"),
content: t("install.warning.content", {
name: "plugin name",
author: "author author",
permission: ["perm1", "perm2", "perm3"],
}),
type: "warning",
buttons: [
{
text: t("install.button.cancel"),
},
{
text: t("install.button.install"),
},
],
});
};

return (
<>
Expand All @@ -17,7 +49,7 @@ export default function PluginsPage() {
description={t("welcome.description")}
></Field>
<Field icon={<Plug />} title={t("title")}>
<Button>
<Button onClick={install}>
<Box />
{t("install")}
</Button>
Expand Down

0 comments on commit 8c5e240

Please sign in to comment.