From 0fedea5cf4aeafa19eb887b5c033c9e70a62d885 Mon Sep 17 00:00:00 2001 From: Pylogmon Date: Sun, 3 Sep 2023 14:35:24 +0800 Subject: [PATCH] feat: Uninstall Plugin --- src-tauri/src/cmd.rs | 4 +- src/i18n/locales/en_US.json | 3 +- src/i18n/locales/zh_CN.json | 3 +- .../Config/pages/Backup/WebDavModal/index.jsx | 2 +- .../Translate/SelectPluginModal/index.jsx | 47 +++++++++++++++++-- .../Config/pages/Service/Translate/index.jsx | 8 +++- 6 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/cmd.rs b/src-tauri/src/cmd.rs index cdde6c112d..b5de90ab80 100644 --- a/src-tauri/src/cmd.rs +++ b/src-tauri/src/cmd.rs @@ -158,12 +158,12 @@ pub fn install_plugin(path_list: Vec, plugin_type: &str) -> Result return Err(Error::Error("Unknown OS".into())), }; for path in path_list { - if !path.ends_with("zip") { + if !path.ends_with("potext") { continue; } let path = std::path::Path::new(&path); let file_name = path.file_name().unwrap().to_str().unwrap(); - let file_name = file_name.replace(".zip", ""); + let file_name = file_name.replace(".potext", ""); if !file_name.starts_with("[plugin]") { return Err(Error::Error( "Invalid Plugin: file name must start with [plugin]".into(), diff --git a/src/i18n/locales/en_US.json b/src/i18n/locales/en_US.json index 83940cc628..43efd6559c 100644 --- a/src/i18n/locales/en_US.json +++ b/src/i18n/locales/en_US.json @@ -119,7 +119,8 @@ "add_external_service": "Add Extension", "add_service": "Add Service", "test_failed": "Test Failed", - "install_plugin": "Install Plugin" + "install_plugin": "Install Plugin", + "uninstall_success": "Plugin Uninstall Successfully" }, "history": { "label": "History", diff --git a/src/i18n/locales/zh_CN.json b/src/i18n/locales/zh_CN.json index c617eff479..20d2e1001b 100644 --- a/src/i18n/locales/zh_CN.json +++ b/src/i18n/locales/zh_CN.json @@ -119,7 +119,8 @@ "add_external_service": "添加外部插件", "add_service": "添加服务", "test_failed": "测试失败", - "install_plugin": "安装外部插件" + "install_plugin": "安装外部插件", + "uninstall_success": "插件卸载成功" }, "history": { "label": "历史记录", diff --git a/src/window/Config/pages/Backup/WebDavModal/index.jsx b/src/window/Config/pages/Backup/WebDavModal/index.jsx index b5bc65023e..67058b8588 100644 --- a/src/window/Config/pages/Backup/WebDavModal/index.jsx +++ b/src/window/Config/pages/Backup/WebDavModal/index.jsx @@ -66,7 +66,7 @@ export default function WebDavModal(props) { scrollBehavior='inside' > - + {(onClose) => ( <> {t('config.backup.list')} diff --git a/src/window/Config/pages/Service/Translate/SelectPluginModal/index.jsx b/src/window/Config/pages/Service/Translate/SelectPluginModal/index.jsx index 4990fc2d5e..ec3f985a4a 100644 --- a/src/window/Config/pages/Service/Translate/SelectPluginModal/index.jsx +++ b/src/window/Config/pages/Service/Translate/SelectPluginModal/index.jsx @@ -1,16 +1,19 @@ import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@nextui-org/react'; +import { removeDir, BaseDirectory } from '@tauri-apps/api/fs'; import toast, { Toaster } from 'react-hot-toast'; +import { MdDeleteOutline } from 'react-icons/md'; import { useTranslation } from 'react-i18next'; import { open } from '@tauri-apps/api/dialog'; import { invoke } from '@tauri-apps/api'; +import React, { useState } from 'react'; import { useAtomValue } from 'jotai'; -import React from 'react'; import { useToastStyle } from '../../../../../../hooks'; import { pluginListAtom } from '..'; export default function SelectPluginModal(props) { - const { isOpen, onOpenChange, setConfigName, onConfigOpen } = props; + const { isOpen, onOpenChange, setConfigName, onConfigOpen, getPluginList } = props; + const [installing, setInstalling] = useState(false); const pluginList = useAtomValue(pluginListAtom); const { t } = useTranslation(); const toastStyle = useToastStyle(); @@ -29,9 +32,13 @@ export default function SelectPluginModal(props) { {Object.keys(pluginList).map((x) => { return ( -
+
+
); })}