From 740d2118f1117a55b5539113f6d6f9f14e04ac95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 22 Feb 2026 13:34:03 +0800 Subject: [PATCH] Comment out plugin import UI and handlers Temporarily disable the local plugin import flow: remove the unused useRef import, comment out the FiUpload import, fileInputRef declaration, and the related handlers (handleImportClick and handleFileChange). Keeps the rest of the plugin page (loading, modal and plugin list logic) intact so the import feature can be re-enabled later. --- .../src/pages/dashboard/plugin.tsx | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/packages/napcat-webui-frontend/src/pages/dashboard/plugin.tsx b/packages/napcat-webui-frontend/src/pages/dashboard/plugin.tsx index 8fc597de..2c581ef5 100644 --- a/packages/napcat-webui-frontend/src/pages/dashboard/plugin.tsx +++ b/packages/napcat-webui-frontend/src/pages/dashboard/plugin.tsx @@ -1,8 +1,8 @@ import { Button } from '@heroui/button'; -import { useEffect, useState, useRef } from 'react'; +import { useEffect, useState } from 'react'; import toast from 'react-hot-toast'; import { IoMdRefresh } from 'react-icons/io'; -import { FiUpload } from 'react-icons/fi'; +// import { FiUpload } from 'react-icons/fi'; import { useDisclosure } from '@heroui/modal'; import PageLoading from '@/components/page_loading'; @@ -19,7 +19,7 @@ export default function PluginPage () { const { isOpen, onOpen, onOpenChange } = useDisclosure(); const [currentPluginId, setCurrentPluginId] = useState(''); - const fileInputRef = useRef(null); + // const fileInputRef = useRef(null); const loadPlugins = async () => { setLoading(true); @@ -106,60 +106,60 @@ export default function PluginPage () { onOpen(); }; - const handleImportClick = () => { - if (pluginManagerNotFound) { - dialog.confirm({ - title: '插件管理器未加载', - content: ( -
-

- 插件管理器尚未加载,无法导入插件。 -

-

- 是否立即注册插件管理器? -

-
- ), - confirmText: '注册插件管理器', - cancelText: '取消', - onConfirm: async () => { - try { - await PluginManager.registerPluginManager(); - toast.success('插件管理器注册成功'); - setPluginManagerNotFound(false); - // 注册成功后打开文件选择器 - fileInputRef.current?.click(); - } catch (e: any) { - toast.error('注册失败: ' + e.message); - } - }, - }); - return; - } - fileInputRef.current?.click(); - }; + // const handleImportClick = () => { + // if (pluginManagerNotFound) { + // dialog.confirm({ + // title: '插件管理器未加载', + // content: ( + //
+ //

+ // 插件管理器尚未加载,无法导入插件。 + //

+ //

+ // 是否立即注册插件管理器? + //

+ //
+ // ), + // confirmText: '注册插件管理器', + // cancelText: '取消', + // onConfirm: async () => { + // try { + // await PluginManager.registerPluginManager(); + // toast.success('插件管理器注册成功'); + // setPluginManagerNotFound(false); + // // 注册成功后打开文件选择器 + // fileInputRef.current?.click(); + // } catch (e: any) { + // toast.error('注册失败: ' + e.message); + // } + // }, + // }); + // return; + // } + // fileInputRef.current?.click(); + // }; - const handleFileChange = async (e: React.ChangeEvent) => { - const file = e.target.files?.[0]; - if (!file) return; + // const handleFileChange = async (e: React.ChangeEvent) => { + // const file = e.target.files?.[0]; + // if (!file) return; - // 重置 input,允许重复选择同一文件 - e.target.value = ''; + // // 重置 input,允许重复选择同一文件 + // e.target.value = ''; - if (!file.name.endsWith('.zip')) { - toast.error('请选择 .zip 格式的插件包'); - return; - } + // if (!file.name.endsWith('.zip')) { + // toast.error('请选择 .zip 格式的插件包'); + // return; + // } - const loadingToast = toast.loading('正在导入插件...'); - try { - const result = await PluginManager.importLocalPlugin(file); - toast.success(result.message, { id: loadingToast }); - loadPlugins(); - } catch (err: any) { - toast.error(err.message || '导入失败', { id: loadingToast }); - } - }; + // const loadingToast = toast.loading('正在导入插件...'); + // try { + // const result = await PluginManager.importLocalPlugin(file); + // toast.success(result.message, { id: loadingToast }); + // loadPlugins(); + // } catch (err: any) { + // toast.error(err.message || '导入失败', { id: loadingToast }); + // } + // }; return ( <>