diff --git a/app/renderer/src/main/public/locales/en/layout.json b/app/renderer/src/main/public/locales/en/layout.json index 8754d90add..ce8cafb71a 100644 --- a/app/renderer/src/main/public/locales/en/layout.json +++ b/app/renderer/src/main/public/locales/en/layout.json @@ -341,6 +341,10 @@ "slashCommandDesc": "Use slash commands in IM chat to control Alagent; regular messages go directly to the agent.", "deleteRobot": "Delete Robot", "deleteRobotDesc": "Remove this robot", + "deleteRobotConfirm": "This will delete the {{channel}} bot and its scan-code credentials and related config. This cannot be undone. Are you sure?", + "deleteRobotSuccess": "Robot deleted", + "deleteRobotFailed": "Failed to delete robot: {{error}}", + "deleteCancel": "Cancel", "scanFeishuTip": "Use the Feishu mobile app to scan the QR code and confirm login.", "scanDingtalkTip": "Use the DingTalk mobile app to scan the QR code and confirm login.", "waitingScanPrefix": "Waiting for scan, ", diff --git a/app/renderer/src/main/public/locales/zh-TW/layout.json b/app/renderer/src/main/public/locales/zh-TW/layout.json index 07886b3fc3..7036cb85f0 100644 --- a/app/renderer/src/main/public/locales/zh-TW/layout.json +++ b/app/renderer/src/main/public/locales/zh-TW/layout.json @@ -341,6 +341,10 @@ "slashCommandDesc": "在 IM 聊天中輸入斜杠命令控制 Alagent:普通訊息直接發給 agent。", "deleteRobot": "刪除機器人", "deleteRobotDesc": "移除這個機器人", + "deleteRobotConfirm": "將刪除 {{channel}} 機器人及其掃碼憑證等相關設定,刪除後不可復原,確定要刪除嗎?", + "deleteRobotSuccess": "機器人已刪除", + "deleteRobotFailed": "刪除機器人失敗:{{error}}", + "deleteCancel": "取消", "scanFeishuTip": "請使用飛書移動端掃描二維碼並確認登入。", "scanDingtalkTip": "請使用釘釘移動端掃描二維碼並確認登入。", "waitingScanPrefix": "等待掃碼,", diff --git a/app/renderer/src/main/public/locales/zh/layout.json b/app/renderer/src/main/public/locales/zh/layout.json index f7da313048..8a7b550731 100644 --- a/app/renderer/src/main/public/locales/zh/layout.json +++ b/app/renderer/src/main/public/locales/zh/layout.json @@ -341,6 +341,10 @@ "slashCommandDesc": "在 IM 聊天中输入斜杠命令控制 Alagent:普通消息直接发给 agent。", "deleteRobot": "删除机器人", "deleteRobotDesc": "移除这个机器人", + "deleteRobotConfirm": "将删除 {{channel}} 机器人及其扫码凭证等相关配置,删除后不可恢复,确定要删除吗?", + "deleteRobotSuccess": "机器人已删除", + "deleteRobotFailed": "删除机器人失败:{{error}}", + "deleteCancel": "取消", "scanFeishuTip": "请使用飞书移动端扫描二维码并确认登录。", "scanDingtalkTip": "请使用钉钉移动端扫描二维码并确认登录。", "waitingScanPrefix": "等待扫码,", diff --git a/app/renderer/src/main/src/pages/robotControl/RobotControl.tsx b/app/renderer/src/main/src/pages/robotControl/RobotControl.tsx index 88c38e6003..50252c6c02 100644 --- a/app/renderer/src/main/src/pages/robotControl/RobotControl.tsx +++ b/app/renderer/src/main/src/pages/robotControl/RobotControl.tsx @@ -6,6 +6,7 @@ import { DingtalkIcon, FeishuIcon } from '@/assets/commonProcessIcons' import { OutlinePlusIcon } from '@/assets/icon/outline' import { YakitButton } from '@/components/yakitUI/YakitButton/YakitButton' import { YakitInput } from '@/components/yakitUI/YakitInput/YakitInput' +import { YakitModalConfirm } from '@/components/yakitUI/YakitModal/YakitModalConfirm' import { useI18nNamespaces } from '@/i18n/useI18nNamespaces' import { yakitNotify } from '@/utils/notification' import { getLocalValue, setLocalValue } from '@/utils/kv' @@ -387,7 +388,7 @@ export const RobotControl: React.FC = (props) => { updateDraftRobot(id, { isNameEditing: true }) }) - const onDeleteRobot = useMemoizedFn(async (id: string) => { + const onDeleteRobot = useMemoizedFn((id: string) => { if (id.startsWith('draft-')) { setDraftRobots((prev) => { const next = prev.filter((item) => item.id !== id) @@ -411,17 +412,29 @@ export const RobotControl: React.FC = (props) => { const target = robots.find((item) => item.id === id) if (!target?.bot) return - try { - await deleteIMBot(target.bot.Platform) - const enabledPlatforms = robots - .filter((item) => item.enabled && item.bot && item.bot.Platform !== target.bot!.Platform) - .map((item) => item.bot!.Platform) - await syncControlRuntime(enabledPlatforms) - await loadBots(false) - yakitNotify('success', '机器人已删除') - } catch (e) { - yakitNotify('error', `删除机器人失败:${e}`) - } + const channelLabel = target.channel ? getChannelLabel(target.channel) : target.bot.Platform + const confirm = YakitModalConfirm({ + width: 420, + type: 'white', + onCancelText: t('RobotControl.deleteCancel'), + onOkText: t('RobotControl.deleteRobot'), + onOk: () => { + deleteIMBot(target.bot!.Platform) + .then(async () => { + const enabledPlatforms = robots + .filter((item) => item.enabled && item.bot && item.bot.Platform !== target.bot!.Platform) + .map((item) => item.bot!.Platform) + await syncControlRuntime(enabledPlatforms) + await loadBots(false) + yakitNotify('success', t('RobotControl.deleteRobotSuccess')) + }) + .catch((e) => { + yakitNotify('error', t('RobotControl.deleteRobotFailed', { error: String(e) })) + }) + confirm.destroy() + }, + content: t('RobotControl.deleteRobotConfirm', { channel: channelLabel }), + }) }) const onToggleEnabled = useMemoizedFn(async (id: string, enabled: boolean) => { @@ -646,7 +659,7 @@ export const RobotControl: React.FC = (props) => { ) : activeRobot ? ( onDeleteRobot(activeRobot.id) : undefined} + onDelete={() => onDeleteRobot(activeRobot.id)} onToggleEnabled={(enabled) => onToggleEnabled(activeRobot.id, enabled)} onLinkInfoChange={(info, bot) => onLinkInfoChange(activeRobot.id, info, bot)} onUnbound={onUnbound}