diff --git a/src/components/cards/WorkflowTaskCard.vue b/src/components/cards/WorkflowTaskCard.vue index c4d54ac5..e2c69469 100644 --- a/src/components/cards/WorkflowTaskCard.vue +++ b/src/components/cards/WorkflowTaskCard.vue @@ -5,6 +5,9 @@ import { useConfirm } from 'vuetify-use-dialog' import WorkflowAddEditDialog from '@/components/dialog/WorkflowAddEditDialog.vue' import WorkflowActionsDialog from '@/components/dialog/WorkflowActionsDialog.vue' import api from '@/api' +import { useI18n } from 'vue-i18n' + +const { t } = useI18n() // 定义输入参数 const props = defineProps({ @@ -52,8 +55,8 @@ function editDone() { // 删除任务 async function handleDelete(item: Workflow) { const isConfirmed = await createConfirm({ - title: '确认', - content: `是否确认删除任务 ${item.name} ?`, + title: t('common.confirm'), + content: t('workflow.task.confirmDelete', { name: item.name }), }) if (!isConfirmed) return @@ -61,10 +64,10 @@ async function handleDelete(item: Workflow) { try { const result: { [key: string]: string } = await api.delete(`workflow/${item.id}`) if (result.success) { - $toast.success('删除任务成功!') + $toast.success(t('workflow.task.deleteSuccess')) emit('refresh') } else { - $toast.error(`删除任务失败:${result.message}`) + $toast.error(t('workflow.task.deleteFailed', { message: result.message })) } } catch (error) { console.error(error) @@ -77,10 +80,10 @@ async function handleEnable(item: Workflow) { try { const result: { [key: string]: string } = await api.post(`workflow/${item.id}/start`) if (result.success) { - $toast.success('启用任务成功!') + $toast.success(t('workflow.task.enableSuccess')) emit('refresh') } else { - $toast.error(`启用任务失败:${result.message}`) + $toast.error(t('workflow.task.enableFailed', { message: result.message })) } } catch (error) { console.error(error) @@ -94,10 +97,10 @@ async function handlePause(item: Workflow) { try { const result: { [key: string]: string } = await api.post(`workflow/${item.id}/pause`) if (result.success) { - $toast.success('停用任务成功!') + $toast.success(t('workflow.task.pauseSuccess')) emit('refresh') } else { - $toast.error(`停用任务失败:${result.message}`) + $toast.error(t('workflow.task.pauseFailed', { message: result.message })) } } catch (error) { console.error(error) @@ -116,10 +119,10 @@ async function handleRun(item: Workflow, from_begin: boolean) { from_begin, }) if (result.success) { - $toast.success('任务执行完成!') + $toast.success(t('workflow.task.runSuccess')) emit('refresh') } else { - $toast.error(`任务执行失败:${result.message}`) + $toast.error(t('workflow.task.runFailed', { message: result.message })) emit('refresh') } } catch (error) { @@ -131,8 +134,8 @@ async function handleRun(item: Workflow, from_begin: boolean) { // 重置任务 async function handleReset(item: Workflow) { const isConfirmed = await createConfirm({ - title: '确认', - content: `是否确认重置任务 ${item.name} ?`, + title: t('common.confirm'), + content: t('workflow.task.confirmReset', { name: item.name }), }) if (!isConfirmed) return @@ -140,10 +143,10 @@ async function handleReset(item: Workflow) { try { const result: { [key: string]: string } = await api.post(`workflow/${item.id}/reset`) if (result.success) { - $toast.success('重置任务成功!') + $toast.success(t('workflow.task.resetSuccess')) emit('refresh') } else { - $toast.error(`重置任务失败:${result.message}`) + $toast.error(t('workflow.task.resetFailed', { message: result.message })) } } catch (error) { console.error(error) @@ -152,11 +155,11 @@ async function handleReset(item: Workflow) { // 计算状态颜色 const resolveStatusVariant = (status: string | undefined) => { - if (status === 'S') return { color: 'success', text: '成功' } - else if (status === 'R') return { color: 'primary', text: '运行中' } - else if (status === 'F') return { color: 'error', text: '失败' } - else if (status === 'P') return { color: 'secondary', text: '暂停' } - else return { color: 'info', text: '等待' } + if (status === 'S') return { color: 'success', text: t('workflow.task.status.success') } + else if (status === 'R') return { color: 'primary', text: t('workflow.task.status.running') } + else if (status === 'F') return { color: 'error', text: t('workflow.task.status.failed') } + else if (status === 'P') return { color: 'secondary', text: t('workflow.task.status.paused') } + else return { color: 'info', text: t('workflow.task.status.waiting') } } // 计算当前动作占比 @@ -205,37 +208,37 @@ const resolveProgress = (item: Workflow) => { - 编辑任务 + {{ t('workflow.task.edit') }} - 继续执行 + {{ t('workflow.task.continue') }} - 重新执行 + {{ t('workflow.task.restart') }} - 立即执行 + {{ t('workflow.task.run') }} - 重置任务 + {{ t('workflow.task.reset') }} - 删除任务 + {{ t('workflow.task.delete') }} @@ -247,11 +250,11 @@ const resolveProgress = (item: Workflow) => {
-
定时
+
{{ t('workflow.task.info.timer') }}
{{ workflow?.timer }}
-
状态
+
{{ t('workflow.task.info.status') }}
{{ resolveStatusVariant(workflow?.state).text }}
@@ -259,7 +262,7 @@ const resolveProgress = (item: Workflow) => {
-
动作数
+
{{ t('workflow.task.info.actionCount') }}
{{ workflow?.actions?.length }} @@ -267,13 +270,13 @@ const resolveProgress = (item: Workflow) => {
-
已执行次数
+
{{ t('workflow.task.info.runCount') }}
{{ workflow?.run_count }}
-
进度
+
{{ t('workflow.task.info.progress') }}
@@ -284,7 +287,7 @@ const resolveProgress = (item: Workflow) => {
-
错误信息
+
{{ t('workflow.task.info.error') }}
{{ workflow?.result }}
diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index b4a45c4a..d6d2f5d3 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -258,6 +258,41 @@ export default { dragToCanvas: 'Drag to Canvas', tapComponentHint: 'Tap component to add to canvas', dragComponentHint: 'Drag component to canvas', + task: { + edit: 'Edit Task', + continue: 'Continue', + restart: 'Restart', + run: 'Run Now', + reset: 'Reset Task', + delete: 'Delete Task', + confirmDelete: 'Are you sure to delete task {name} ?', + confirmReset: 'Are you sure to reset task {name} ?', + deleteSuccess: 'Task deleted successfully!', + deleteFailed: 'Failed to delete task: {message}', + enableSuccess: 'Task enabled successfully!', + enableFailed: 'Failed to enable task: {message}', + pauseSuccess: 'Task paused successfully!', + pauseFailed: 'Failed to pause task: {message}', + runSuccess: 'Task execution completed!', + runFailed: 'Task execution failed: {message}', + resetSuccess: 'Task reset successfully!', + resetFailed: 'Failed to reset task: {message}', + status: { + success: 'Success', + running: 'Running', + failed: 'Failed', + paused: 'Paused', + waiting: 'Waiting', + }, + info: { + timer: 'Timer', + status: 'Status', + actionCount: 'Action Count', + runCount: 'Run Count', + progress: 'Progress', + error: 'Error Message', + }, + }, }, dashboard: { storage: 'Storage', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 8fe15223..0d05a41e 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -282,7 +282,7 @@ export default { running: '运行中', failed: '失败', paused: '暂停', - waiting: '等待' + waiting: '等待', }, info: { timer: '定时', @@ -290,6 +290,9 @@ export default { actionCount: '动作数', runCount: '已执行次数', progress: '进度', + error: '错误信息', + }, + }, }, dashboard: { storage: '存储空间', diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts index 0d358eaa..64fa9763 100644 --- a/src/locales/zh-TW.ts +++ b/src/locales/zh-TW.ts @@ -255,9 +255,44 @@ export default { workflow: { components: '動作組件', clickToAdd: '點擊添加', - dragToCanvas: '拖動到畫布', + dragToCanvas: '拖曳至畫布', tapComponentHint: '點擊組件添加到畫布', - dragComponentHint: '拖動組件到畫布', + dragComponentHint: '拖曳組件到畫布', + task: { + edit: '編輯任務', + continue: '繼續', + restart: '重新開始', + run: '立即執行', + reset: '重置任務', + delete: '刪除任務', + confirmDelete: '確定要刪除任務 {name} 嗎?', + confirmReset: '確定要重置任務 {name} 嗎?', + deleteSuccess: '任務刪除成功!', + deleteFailed: '刪除任務失敗:{message}', + enableSuccess: '任務啟用成功!', + enableFailed: '啟用任務失敗:{message}', + pauseSuccess: '任務暫停成功!', + pauseFailed: '暫停任務失敗:{message}', + runSuccess: '任務執行完成!', + runFailed: '任務執行失敗:{message}', + resetSuccess: '任務重置成功!', + resetFailed: '重置任務失敗:{message}', + status: { + success: '成功', + running: '執行中', + failed: '失敗', + paused: '已暫停', + waiting: '等待中', + }, + info: { + timer: '定時器', + status: '狀態', + actionCount: '動作數量', + runCount: '執行次數', + progress: '進度', + error: '錯誤訊息', + }, + }, }, dashboard: { storage: '存儲空間',