From dc15e537d81a4bb6df5f30e702515c5c49157bba Mon Sep 17 00:00:00 2001 From: madrays Date: Mon, 26 May 2025 10:55:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8F=92=E4=BB=B6=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/cards/PluginCard.vue | 200 ++++++++++++++++++++++++++++ src/locales/zh-CN.ts | 8 ++ 2 files changed, 208 insertions(+) diff --git a/src/components/cards/PluginCard.vue b/src/components/cards/PluginCard.vue index e47ec64f..2030c4b8 100644 --- a/src/components/cards/PluginCard.vue +++ b/src/components/cards/PluginCard.vue @@ -73,6 +73,18 @@ const imageLoadError = ref(false) // 更新日志弹窗 const releaseDialog = ref(false) +// 插件分身对话框 +const pluginCloneDialog = ref(false) + +// 插件分身表单 +const cloneForm = ref({ + suffix: '', + name: '', + description: '', + version: '', + icon: '' +}) + // 监听动作标识,如为true则打开详情 watch( () => props.action, @@ -241,6 +253,54 @@ function configDone() { emit('save') } +// 显示插件分身对话框 +function showPluginClone() { + cloneForm.value = { + suffix: '', + name: `${props.plugin?.plugin_name} 分身`, + description: `${props.plugin?.plugin_desc} (分身版本)`, + version: props.plugin?.plugin_version || '1.0', + icon: props.plugin?.plugin_icon || '' + } + pluginCloneDialog.value = true +} + +// 执行插件分身 +async function executePluginClone() { + if (!cloneForm.value.suffix.trim()) { + $toast.error('请输入分身后缀') + return + } + + try { + progressDialog.value = true + progressText.value = `正在创建 ${props.plugin?.plugin_name} 的分身...` + + const result: { [key: string]: any } = await api.post(`plugin/clone/${props.plugin?.id}`, { + suffix: cloneForm.value.suffix.trim(), + name: cloneForm.value.name.trim(), + description: cloneForm.value.description.trim(), + version: cloneForm.value.version.trim(), + icon: cloneForm.value.icon.trim() + }) + + progressDialog.value = false + + if (result.success) { + $toast.success(`插件分身 ${cloneForm.value.name} 创建成功!`) + pluginCloneDialog.value = false + // 通知父组件刷新 + emit('remove') + } else { + $toast.error(`插件分身创建失败:${result.message}`) + } + } catch (error) { + progressDialog.value = false + $toast.error('插件分身创建失败') + console.error(error) + } +} + // 弹出菜单 const dropdownItems = ref([ { @@ -261,6 +321,16 @@ const dropdownItems = ref([ click: showPluginConfig, }, }, + { + title: '插件分身', + value: 8, + show: true, + props: { + prependIcon: 'mdi-content-copy', + color: 'info', + click: showPluginClone, + }, + }, { title: t('plugin.update'), value: 3, @@ -470,6 +540,136 @@ watch( + + + + + + +
+
🎭 创建插件分身
+
为 {{ props.plugin?.plugin_name }} 创建独立的分身实例
+
+
+ + + + + + +
+ 插件分身功能:创建插件的独立副本,拥有独立的配置和数据,适用于多账号、测试环境等场景 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 注意:分身插件创建后默认为禁用状态,需要手动配置启用。分身后缀一旦确定无法修改。 +
+
+
+
+
+
+ + + + + + 取消 + + + + 创建分身 + + +
+
diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index df5f55eb..354006cf 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -1989,6 +1989,14 @@ export default { folderName: '文件夹名称', cancel: '取消', create: '创建', + clonePluginTitle: '创建插件分身 - {name}', + suffix: '分身后缀', + description: '描述', + clone: '创建分身', + suffixPlaceholder: '例如:Clone1, Test, Backup', + namePlaceholder: '分身插件的显示名称', + descriptionPlaceholder: '分身插件的描述信息', + suffixRequired: '分身后缀不能为空', }, profile: { personalInfo: '个人信息',