diff --git a/im-admin-ui/src/views/im/setting/indexSetting.vue b/im-admin-ui/src/views/im/setting/indexSetting.vue index 4b3e53a..719031e 100644 --- a/im-admin-ui/src/views/im/setting/indexSetting.vue +++ b/im-admin-ui/src/views/im/setting/indexSetting.vue @@ -14,7 +14,7 @@ - + @@ -23,33 +23,18 @@ + + + + + + 提交 重置 - - @@ -69,12 +54,9 @@ const activeTab = ref('translation'); const translationSettingData = ref({ type: '', appId: '', - secretKey: '' -}); - -const platformSettingData = ref({ - name: '', - domain: '' + secretKey: '', + appKey: '', + appSecret: '' }); // 翻译配置验证规则 @@ -87,18 +69,14 @@ const translationRules = { secretKey: [ { required: true, message: '请输入密钥', 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: [ - { required: true, message: '请输入平台域名', trigger: 'blur' }, - { pattern: /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/, message: '请输入正确的域名格式', trigger: 'blur' } + appKey: [ + { required: true, message: '请输入App Key', 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); } console.log('成功:', translationSettingData.value); - // 更新平台配置数据 - if (res.PLATFORM_SETTING) { - platformSettingData.value = JSON.parse(res.PLATFORM_SETTING); - } } catch (error) { ElMessage.error('获取配置失败'); } finally { @@ -137,7 +111,9 @@ const submitTranslationForm = async () => { settingName: 'TRANSLATION_SETTING', type: translationSettingData.value.type, appId: translationSettingData.value.appId, - secretKey: translationSettingData.value.secretKey + secretKey: translationSettingData.value.secretKey, + appKey: translationSettingData.value.appKey, + appSecret: translationSettingData.value.appSecret }; await updateSetting(params); 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 formRef = proxy.$refs.translationFormRef as (typeof import('element-plus'))['ElForm']; formRef.resetFields(); }; -/** 重置平台配置表单 */ -const resetPlatformForm = () => { - const formRef = proxy.$refs.platformFormRef as (typeof import('element-plus'))['ElForm']; - formRef.resetFields(); -}; - onMounted(() => { getList(); }); diff --git a/im-admin-ui/src/views/system/user/profile/index.vue b/im-admin-ui/src/views/system/user/profile/index.vue index 97d70ae..968e4fd 100644 --- a/im-admin-ui/src/views/system/user/profile/index.vue +++ b/im-admin-ui/src/views/system/user/profile/index.vue @@ -25,10 +25,10 @@ 用户邮箱
{{ state.user.email }}
-
  • +
  • 所属角色
    {{ state.roleGroup }}
    diff --git a/im-admin/ruoyi-im/src/main/java/org/dromara/im/domain/setting/domain/TranslationSetting.java b/im-admin/ruoyi-im/src/main/java/org/dromara/im/domain/setting/domain/TranslationSetting.java index ecbbb3b..64a33ec 100644 --- a/im-admin/ruoyi-im/src/main/java/org/dromara/im/domain/setting/domain/TranslationSetting.java +++ b/im-admin/ruoyi-im/src/main/java/org/dromara/im/domain/setting/domain/TranslationSetting.java @@ -9,12 +9,16 @@ import lombok.Setter; public class TranslationSetting { /** - * 翻译类型 0-默认管理员配置 1-百度翻译 2-谷歌翻译 + * 翻译类型 0-默认管理员配置 1-百度翻译 2-有道翻译 3-谷歌翻译 */ private String type = "0"; - private String appId = ""; + private String appId = "";//百度翻译使用 - private String secretKey = ""; + private String secretKey = "";//百度翻译使用 + + private String appKey = "";//有道翻译使用 + + private String appSecret = "";//有道翻译使用 } diff --git a/im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImSettingServiceImpl.java b/im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImSettingServiceImpl.java index 499d124..5046724 100644 --- a/im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImSettingServiceImpl.java +++ b/im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImSettingServiceImpl.java @@ -279,8 +279,13 @@ public class ImSettingServiceImpl implements IImSettingService { origin.setType("1"); origin.setAppId(value.getStr("appId")); origin.setSecretKey(value.getStr("secretKey")); - }else{//其余情况 异常 - return false; + } else if (type.equals("2")) {//使用有道翻译 + if(ObjectUtil.isEmpty(value.getStr("appKey")) || ObjectUtil.isEmpty(value.getStr("appSecret"))) { + return false; + } + origin.setType("2"); + origin.setAppId(value.getStr("appKey")); + origin.setAppSecret(value.getStr("appSecret")); }