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) => {