Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/renderer/src/main/public/locales/en/layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -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, ",
Expand Down
4 changes: 4 additions & 0 deletions app/renderer/src/main/public/locales/zh-TW/layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@
"slashCommandDesc": "在 IM 聊天中輸入斜杠命令控制 Alagent:普通訊息直接發給 agent。",
"deleteRobot": "刪除機器人",
"deleteRobotDesc": "移除這個機器人",
"deleteRobotConfirm": "將刪除 {{channel}} 機器人及其掃碼憑證等相關設定,刪除後不可復原,確定要刪除嗎?",
"deleteRobotSuccess": "機器人已刪除",
"deleteRobotFailed": "刪除機器人失敗:{{error}}",
"deleteCancel": "取消",
"scanFeishuTip": "請使用飛書移動端掃描二維碼並確認登入。",
"scanDingtalkTip": "請使用釘釘移動端掃描二維碼並確認登入。",
"waitingScanPrefix": "等待掃碼,",
Expand Down
4 changes: 4 additions & 0 deletions app/renderer/src/main/public/locales/zh/layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@
"slashCommandDesc": "在 IM 聊天中输入斜杠命令控制 Alagent:普通消息直接发给 agent。",
"deleteRobot": "删除机器人",
"deleteRobotDesc": "移除这个机器人",
"deleteRobotConfirm": "将删除 {{channel}} 机器人及其扫码凭证等相关配置,删除后不可恢复,确定要删除吗?",
"deleteRobotSuccess": "机器人已删除",
"deleteRobotFailed": "删除机器人失败:{{error}}",
"deleteCancel": "取消",
"scanFeishuTip": "请使用飞书移动端扫描二维码并确认登录。",
"scanDingtalkTip": "请使用钉钉移动端扫描二维码并确认登录。",
"waitingScanPrefix": "等待扫码,",
Expand Down
39 changes: 26 additions & 13 deletions app/renderer/src/main/src/pages/robotControl/RobotControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -387,7 +388,7 @@ export const RobotControl: React.FC<RobotControlProps> = (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)
Expand All @@ -411,17 +412,29 @@ export const RobotControl: React.FC<RobotControlProps> = (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) => {
Expand Down Expand Up @@ -646,7 +659,7 @@ export const RobotControl: React.FC<RobotControlProps> = (props) => {
) : activeRobot ? (
<RobotDetailPanel
robot={activeRobot}
onDelete={activeRobot.isDraft ? () => onDeleteRobot(activeRobot.id) : undefined}
onDelete={() => onDeleteRobot(activeRobot.id)}
onToggleEnabled={(enabled) => onToggleEnabled(activeRobot.id, enabled)}
onLinkInfoChange={(info, bot) => onLinkInfoChange(activeRobot.id, info, bot)}
onUnbound={onUnbound}
Expand Down
Loading