Browse Source

🦄 refactor: 多语言配置纯文本校验

zhangrenyuan/feature-20251125114759-多语言
zhangrenyuan 1 day ago
parent
commit
6d803b0b7b
  1. 14
      src/views/language/languageTranslate.vue

14
src/views/language/languageTranslate.vue

@ -336,11 +336,21 @@ const handleAdd = () => {
//
const handleSave = async () => {
if (!editForm.value.chineseSimplified) {
ElMessage.error('请输入原文内容')
//
if (!editForm.value.chineseSimplified || editForm.value.chineseSimplified.trim() === '') {
ElMessage.error('原文为必填项')
return
}
//
const fields = ['english', 'thai', 'chineseTraditional', 'malay', 'vietnamese']
for (const field of fields) {
if (editForm.value[field] && /<[^>]*>/.test(editForm.value[field])) {
ElMessage.error('译文仅支持纯文本,不支持HTML标签')
return
}
}
try {
const url = editForm.value.id ? '/language/updateTranslation' : '/language/addTranslation'
const res = await API({

Loading…
Cancel
Save