|
|
@ -14,7 +14,7 @@ |
|
|
<el-select v-model="translationSettingData.type" placeholder="请选择翻译类型"> |
|
|
<el-select v-model="translationSettingData.type" placeholder="请选择翻译类型"> |
|
|
<el-option label="默认配置" value="0"></el-option> |
|
|
<el-option label="默认配置" value="0"></el-option> |
|
|
<el-option label="百度翻译" value="1"></el-option> |
|
|
<el-option label="百度翻译" value="1"></el-option> |
|
|
<!-- <el-option label="Google翻译" value="2"></el-option> --> |
|
|
<el-option label="有道翻译" value="2"></el-option> |
|
|
</el-select> |
|
|
</el-select> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item v-if="translationSettingData.type === '1'" label="APP ID" prop="appId"> |
|
|
<el-form-item v-if="translationSettingData.type === '1'" label="APP ID" prop="appId"> |
|
|
@ -23,33 +23,18 @@ |
|
|
<el-form-item v-if="translationSettingData.type === '1'" label="密钥" prop="secretKey"> |
|
|
<el-form-item v-if="translationSettingData.type === '1'" label="密钥" prop="secretKey"> |
|
|
<el-input v-model="translationSettingData.secretKey" :rows="4" placeholder="请输入密钥"></el-input> |
|
|
<el-input v-model="translationSettingData.secretKey" :rows="4" placeholder="请输入密钥"></el-input> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
|
|
|
<el-form-item v-if="translationSettingData.type === '2'" label="App Key" prop="appKey"> |
|
|
|
|
|
<el-input v-model="translationSettingData.appKey" placeholder="请输入App Key"></el-input> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
<el-form-item v-if="translationSettingData.type === '2'" label="密钥" prop="appSecret"> |
|
|
|
|
|
<el-input v-model="translationSettingData.appSecret" :rows="4" placeholder="请输入密钥"></el-input> |
|
|
|
|
|
</el-form-item> |
|
|
<el-form-item> |
|
|
<el-form-item> |
|
|
<el-button type="primary" @click="submitTranslationForm">提交</el-button> |
|
|
<el-button type="primary" @click="submitTranslationForm">提交</el-button> |
|
|
<el-button @click="resetTranslationForm">重置</el-button> |
|
|
<el-button @click="resetTranslationForm">重置</el-button> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-form> |
|
|
</el-form> |
|
|
</el-tab-pane> |
|
|
</el-tab-pane> |
|
|
|
|
|
|
|
|
<!-- <el-tab-pane label="平台配置" name="platform" lazy> |
|
|
|
|
|
<el-form |
|
|
|
|
|
ref="platformFormRef" |
|
|
|
|
|
:model="platformSettingData" |
|
|
|
|
|
:rules="platformRules" |
|
|
|
|
|
label-width="120px" |
|
|
|
|
|
style="max-width: 600px; margin-top: 20px" |
|
|
|
|
|
> |
|
|
|
|
|
<el-form-item label="平台名称" prop="name"> |
|
|
|
|
|
<el-input v-model="platformSettingData.name" placeholder="请输入平台名称"></el-input> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
<el-form-item label="平台域名" prop="domain"> |
|
|
|
|
|
<el-input v-model="platformSettingData.domain" placeholder="请输入平台域名"></el-input> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
<el-form-item> |
|
|
|
|
|
<el-button type="primary" @click="submitPlatformForm">提交</el-button> |
|
|
|
|
|
<el-button @click="resetPlatformForm">重置</el-button> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
</el-form> |
|
|
|
|
|
</el-tab-pane> --> |
|
|
|
|
|
</el-tabs> |
|
|
</el-tabs> |
|
|
<!-- </el-card> --> |
|
|
<!-- </el-card> --> |
|
|
</div> |
|
|
</div> |
|
|
@ -69,12 +54,9 @@ const activeTab = ref('translation'); |
|
|
const translationSettingData = ref({ |
|
|
const translationSettingData = ref({ |
|
|
type: '', |
|
|
type: '', |
|
|
appId: '', |
|
|
appId: '', |
|
|
secretKey: '' |
|
|
secretKey: '', |
|
|
}); |
|
|
appKey: '', |
|
|
|
|
|
appSecret: '' |
|
|
const platformSettingData = ref({ |
|
|
|
|
|
name: '', |
|
|
|
|
|
domain: '' |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 翻译配置验证规则 |
|
|
// 翻译配置验证规则 |
|
|
@ -87,18 +69,14 @@ const translationRules = { |
|
|
secretKey: [ |
|
|
secretKey: [ |
|
|
{ required: true, message: '请输入密钥', trigger: 'blur' }, |
|
|
{ required: true, message: '请输入密钥', trigger: 'blur' }, |
|
|
{ min: 1, max: 200, message: '长度在 1 到 200 个字符', trigger: 'blur' } |
|
|
{ min: 1, max: 200, message: '长度在 1 到 200 个字符', trigger: 'blur' } |
|
|
] |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 平台配置验证规则 |
|
|
|
|
|
const platformRules = { |
|
|
|
|
|
name: [ |
|
|
|
|
|
{ required: true, message: '请输入平台名称', trigger: 'blur' }, |
|
|
|
|
|
{ min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' } |
|
|
|
|
|
], |
|
|
], |
|
|
domain: [ |
|
|
appKey: [ |
|
|
{ required: true, message: '请输入平台域名', trigger: 'blur' }, |
|
|
{ required: true, message: '请输入App Key', trigger: 'blur' }, |
|
|
{ pattern: /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/, message: '请输入正确的域名格式', trigger: 'blur' } |
|
|
{ min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur' } |
|
|
|
|
|
], |
|
|
|
|
|
appSecret: [ |
|
|
|
|
|
{ required: true, message: '请输入密钥', trigger: 'blur' }, |
|
|
|
|
|
{ min: 1, max: 200, message: '长度在 1 到 200 个', trigger: 'blur' } |
|
|
] |
|
|
] |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
@ -113,10 +91,6 @@ const getList = async () => { |
|
|
translationSettingData.value = JSON.parse(res.TRANSLATION_SETTING); |
|
|
translationSettingData.value = JSON.parse(res.TRANSLATION_SETTING); |
|
|
} |
|
|
} |
|
|
console.log('成功:', translationSettingData.value); |
|
|
console.log('成功:', translationSettingData.value); |
|
|
// 更新平台配置数据 |
|
|
|
|
|
if (res.PLATFORM_SETTING) { |
|
|
|
|
|
platformSettingData.value = JSON.parse(res.PLATFORM_SETTING); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
ElMessage.error('获取配置失败'); |
|
|
ElMessage.error('获取配置失败'); |
|
|
} finally { |
|
|
} finally { |
|
|
@ -137,7 +111,9 @@ const submitTranslationForm = async () => { |
|
|
settingName: 'TRANSLATION_SETTING', |
|
|
settingName: 'TRANSLATION_SETTING', |
|
|
type: translationSettingData.value.type, |
|
|
type: translationSettingData.value.type, |
|
|
appId: translationSettingData.value.appId, |
|
|
appId: translationSettingData.value.appId, |
|
|
secretKey: translationSettingData.value.secretKey |
|
|
secretKey: translationSettingData.value.secretKey, |
|
|
|
|
|
appKey: translationSettingData.value.appKey, |
|
|
|
|
|
appSecret: translationSettingData.value.appSecret |
|
|
}; |
|
|
}; |
|
|
await updateSetting(params); |
|
|
await updateSetting(params); |
|
|
ElMessage.success('翻译配置更新成功'); |
|
|
ElMessage.success('翻译配置更新成功'); |
|
|
@ -149,40 +125,12 @@ const submitTranslationForm = async () => { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** 提交平台配置表单 */ |
|
|
|
|
|
const submitPlatformForm = async () => { |
|
|
|
|
|
const formRef = proxy.$refs.platformFormRef as (typeof import('element-plus'))['ElForm']; |
|
|
|
|
|
const isValid = await formRef.validate().catch(() => false); |
|
|
|
|
|
|
|
|
|
|
|
if (!isValid) return; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
buttonLoading.value = true; |
|
|
|
|
|
const params = { |
|
|
|
|
|
PLATFORM_SETTING: platformSettingData.value |
|
|
|
|
|
}; |
|
|
|
|
|
await updateSetting(params); |
|
|
|
|
|
ElMessage.success('平台配置更新成功'); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('更新平台配置失败:', error); |
|
|
|
|
|
ElMessage.error('更新平台配置失败'); |
|
|
|
|
|
} finally { |
|
|
|
|
|
buttonLoading.value = false; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** 重置翻译配置表单 */ |
|
|
/** 重置翻译配置表单 */ |
|
|
const resetTranslationForm = () => { |
|
|
const resetTranslationForm = () => { |
|
|
const formRef = proxy.$refs.translationFormRef as (typeof import('element-plus'))['ElForm']; |
|
|
const formRef = proxy.$refs.translationFormRef as (typeof import('element-plus'))['ElForm']; |
|
|
formRef.resetFields(); |
|
|
formRef.resetFields(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** 重置平台配置表单 */ |
|
|
|
|
|
const resetPlatformForm = () => { |
|
|
|
|
|
const formRef = proxy.$refs.platformFormRef as (typeof import('element-plus'))['ElForm']; |
|
|
|
|
|
formRef.resetFields(); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
getList(); |
|
|
getList(); |
|
|
}); |
|
|
}); |
|
|
|