diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index b16efe8..a835644 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -829,6 +829,34 @@ const local: any = { geterr:'Failed to get the billing rule', updatesuc:'Update successful', updateerr:'Update failed' + }, + ratelimit:{ + title:'Speed limit management', + change:'Modify speed limit configuration', + add:'New speed limit configuration.', + name:'Limie Name', + plename:'Please enter speed limit name.', + upratelimit:'Up Rate Limit', + useuplimit:'Enable upstream rate limiting.', + uplimit:'Upstream bandwidth', + pleuplimit:'Please enter upstream bandwidth.', + downratelimit:'Down Rate Limit', + usedownlimit:'Enable downstream speed limit', + downlimit:'Downstream bandwidth', + pledownlimit:'Please enter downstream bandwidth.', + reject:'Please enter bandwidth value greater than 0.', + confirmdelete:'Confirm deletion.', + deletecontant:'It is confirmed to delete the speed limit configuration', + deletesuc:'Deletion successful.', + idnull:'The editor ID cannot be empty.', + changesuc:'Modification successful.', + addsuc:'Addition successful.', + changeerror:'Modification failed.', + adderror:'Failed to add.', + unlimit:'Unlimited', + operate:'Operate', + changed:'Revise', + delete:'Delete', } }, form: { diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index eb97ca1..f85d1f3 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -829,6 +829,34 @@ const local:any = { geterr:'获取计费规则失败', updatesuc:'更新成功', updateerr:'更新失败' + }, + ratelimit:{ + title:'限速管理', + change:'修改限速配置', + add:'新增限速配置', + name:'限速名称', + plename:'请输入限速名称', + upratelimit:'上行限速', + useuplimit:'启用上行限速', + uplimit:'上行带宽', + pleuplimit:'请输入上行带宽', + downratelimit:'下行限速', + usedownlimit:'启用下行限速', + downlimit:'下行带宽', + pledownlimit:'请输入下行带宽', + reject:'请输入大于0的带宽值', + confirmdelete:'确认删除', + deletecontant:'确定要删除限速配置', + deletesuc:'删除成功', + idnull:'编辑ID不能为空', + changesuc:'修改成功', + addsuc:'添加成功', + changeerror:'修改失败', + adderror:'添加失败', + unlimit:'无限制', + operate:'操作', + changed:'修改', + delete:'删除', } }, form: { diff --git a/src/views/billing/ratelimit/index.vue b/src/views/billing/ratelimit/index.vue index 64e5e06..91328af 100644 --- a/src/views/billing/ratelimit/index.vue +++ b/src/views/billing/ratelimit/index.vue @@ -2,25 +2,20 @@
@@ -40,7 +35,7 @@ @@ -51,24 +46,24 @@ :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }" > - - + + - - 启用上行限速 + + {{ t('page.ratelimit.useuplimit') }}
@@ -83,20 +78,20 @@
- - 启用下行限速 + + {{ t('page.ratelimit.usedownlimit') }}
@@ -126,7 +121,8 @@ import { message, Modal, Button } from 'ant-design-vue'; import type { Rule } from 'ant-design-vue/es/form'; import { PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { bandwidthUnits, convertBandwidth, formatBandwidth, type BandwidthUnit } from '@/utils/units'; - +import { useI18n } from 'vue-i18n'; +const { t } = useI18n(); interface RateLimitForm extends Omit { upLimit: number; downLimit: number; @@ -157,15 +153,15 @@ const formState = ref({ }); const rules: Record = { - rateLimitName: [{ required: true, message: '请输入限速名称', trigger: 'blur' }], + rateLimitName: [{ required: true, message: t('page.ratelimit.plename'), trigger: 'blur' }], upLimit: [ { required: true, - message: '请输入上行限速带宽', + message: t('page.ratelimit.pleuplimit'), trigger: 'blur', validator: (_rule: Rule, value: number) => { if (!formState.value.upLimitEnable) return Promise.resolve(); - if (!value || value <= 0) return Promise.reject('请输入大于0的带宽值'); + if (!value || value <= 0) return Promise.reject(t('page.ratelimit.reject')); return Promise.resolve(); } } @@ -173,11 +169,11 @@ const rules: Record = { downLimit: [ { required: true, - message: '请输入下行限速带宽', + message: t('page.ratelimit.pledownlimit'), trigger: 'blur', validator: (_rule: Rule, value: number) => { if (!formState.value.downLimitEnable) return Promise.resolve(); - if (!value || value <= 0) return Promise.reject('请输入大于0的带宽值'); + if (!value || value <= 0) return Promise.reject(t('page.ratelimit.reject')); return Promise.resolve(); } } @@ -221,16 +217,16 @@ const handleEdit = (record: Api.Auth.RateLimit) => { const handleDelete = (record: Api.Auth.RateLimit) => { Modal.confirm({ - title: '确认删除', + title: t('page.ratelimit.confirmdelete'), icon: () => , - content: `确定要删除限速配置 "${record.rateLimitName}" 吗?`, + content: `${t('page.ratelimit.deletecontant')} "${record.rateLimitName}"?`, async onOk() { try { await removeRateLimit(record.id); - message.success('删除成功'); + message.success(t('page.ratelimit.deletesuc')); getData(); } catch (error) { - console.error('删除失败:', error); + console.error('error:', error); } } }); @@ -264,7 +260,7 @@ const handleOk = async () => { if (isEdit.value) { if (!editId.value) { - message.error('编辑ID不能为空'); + message.error(t('page.ratelimit.idnull')); return; } await editRateLimit({ @@ -275,15 +271,15 @@ const handleOk = async () => { upLimit: submitData.upLimit, downLimit: submitData.downLimit }); - message.success('修改成功'); + message.success(t('page.ratelimit.changesuc')); } else { await addRateLimit(submitData); - message.success('添加成功'); + message.success(t('page.ratelimit.addsuc')); } handleCancel(); getData(); } catch (error) { - message.error(isEdit.value ? '修改失败' : '添加失败'); + message.error(isEdit.value ? 'change error' : 'add error'); } }; @@ -319,16 +315,16 @@ const { { key: 'rateLimitName', dataIndex: 'rateLimitName', - title: '限速名称', + title: t('page.ratelimit.name'), align: 'center' }, { key: 'upLimit', dataIndex: 'upLimit', - title: '上行限速', + title: t('page.ratelimit.upratelimit'), align: 'center', customRender: ({ text, record }) => { - if (!record.upLimitEnable) return '无限制'; + if (!record.upLimitEnable) return t('page.ratelimit.unlimit'); const { value, unit } = formatBandwidth(text); return `${value} ${unit}`; } @@ -336,16 +332,16 @@ const { { key: 'downLimit', dataIndex: 'downLimit', - title: '下行限速', + title: t('page.ratelimit.downratelimit'), align: 'center', customRender: ({ text, record }) => { - if (!record.downLimitEnable) return '无限制'; + if (!record.downLimitEnable) return t('page.ratelimit.unlimit'); const { value, unit } = formatBandwidth(text); return `${value} ${unit}`; } }, { - title: '操作', + title: t('page.ratelimit.operate'), key: 'operate', align: 'center', width: 200, @@ -353,10 +349,10 @@ const { customRender: ({ record }) => (
)