From 2e69c815206e6d37ce25b136c1cd868f050696f6 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 8 Jan 2026 13:42:43 +0800 Subject: [PATCH] perf: Platform card page --- frontend/src/i18n/en.json | 3 +- frontend/src/i18n/ko-KR.json | 3 +- frontend/src/i18n/zh-CN.json | 3 +- frontend/src/views/login/xpack/QrTab.vue | 10 +- .../{wecom/WecomEdit.vue => PlatformForm.vue} | 189 ++++++------ .../{wecom/WecomInfo.vue => PlatformInfo.vue} | 125 ++++---- .../system/platform/common/SettingTemplate.ts | 138 +++++++++ .../system/platform/dingtalk/DingtalkEdit.vue | 280 ------------------ .../system/platform/dingtalk/DingtalkInfo.vue | 246 --------------- frontend/src/views/system/platform/index.vue | 44 ++- .../views/system/platform/lark/LarkEdit.vue | 262 ---------------- .../views/system/platform/lark/LarkInfo.vue | 240 --------------- .../platform/larksuite/LarksuiteEdit.vue | 262 ---------------- .../platform/larksuite/LarksuiteInfo.vue | 241 --------------- 14 files changed, 333 insertions(+), 1713 deletions(-) rename frontend/src/views/system/platform/{wecom/WecomEdit.vue => PlatformForm.vue} (60%) rename frontend/src/views/system/platform/{wecom/WecomInfo.vue => PlatformInfo.vue} (69%) delete mode 100644 frontend/src/views/system/platform/dingtalk/DingtalkEdit.vue delete mode 100644 frontend/src/views/system/platform/dingtalk/DingtalkInfo.vue delete mode 100644 frontend/src/views/system/platform/lark/LarkEdit.vue delete mode 100644 frontend/src/views/system/platform/lark/LarkInfo.vue delete mode 100644 frontend/src/views/system/platform/larksuite/LarksuiteEdit.vue delete mode 100644 frontend/src/views/system/platform/larksuite/LarksuiteInfo.vue diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 1abf829a..7c15bae5 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -447,7 +447,8 @@ "enable": "Enabled", "disable": "Disabled", "local_creation": "Local", - "feishu": "Feishu", + "lark": "Lark", + "larksuite": "Larksuite", "dingtalk": "DingTalk", "wechat_for_business": "WeChat for business", "1240_results": "{msg} results", diff --git a/frontend/src/i18n/ko-KR.json b/frontend/src/i18n/ko-KR.json index 81df893a..9d389ead 100644 --- a/frontend/src/i18n/ko-KR.json +++ b/frontend/src/i18n/ko-KR.json @@ -447,7 +447,8 @@ "enable": "활성화", "disable": "비활성화", "local_creation": "로컬 생성", - "feishu": "페이슈", + "lark": "페이슈", + "larksuite": "페이수 (Pei-su)", "dingtalk": "딩톡", "wechat_for_business": "기업용 위챗", "1240_results": "{msg}개 결과 ", diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json index 48f0567b..d3a9b69f 100644 --- a/frontend/src/i18n/zh-CN.json +++ b/frontend/src/i18n/zh-CN.json @@ -447,7 +447,8 @@ "enable": "启用", "disable": "禁用", "local_creation": "本地创建", - "feishu": "飞书", + "lark": "飞书", + "larksuite": "国际飞书", "dingtalk": "钉钉", "wechat_for_business": "企业微信", "1240_results": "{msg} 个结果 ", diff --git a/frontend/src/views/login/xpack/QrTab.vue b/frontend/src/views/login/xpack/QrTab.vue index 261d5343..77e3a9c0 100644 --- a/frontend/src/views/login/xpack/QrTab.vue +++ b/frontend/src/views/login/xpack/QrTab.vue @@ -6,12 +6,8 @@ name="wecom" > - - + +
@@ -51,7 +47,7 @@ - {{ t('system.international_feishu') }} + {{ t('user.larksuite') }}
diff --git a/frontend/src/views/system/platform/wecom/WecomEdit.vue b/frontend/src/views/system/platform/PlatformForm.vue similarity index 60% rename from frontend/src/views/system/platform/wecom/WecomEdit.vue rename to frontend/src/views/system/platform/PlatformForm.vue index b93488ee..74de4849 100644 --- a/frontend/src/views/system/platform/wecom/WecomEdit.vue +++ b/frontend/src/views/system/platform/PlatformForm.vue @@ -4,72 +4,50 @@ import { ElMessage, ElLoading } from 'element-plus-secondary' import { request } from '@/utils/request' import { useI18n } from 'vue-i18n' import type { FormInstance, FormRules } from 'element-plus-secondary' +import { settingMapping } from './common/SettingTemplate' const { t } = useI18n() const dialogVisible = ref(false) const loadingInstance = ref | null>(null) -const wecomForm = ref() -interface WecomkForm { - corpid?: string - agent_id?: string - corpsecret?: string -} +const platformForm = ref() + const state = reactive({ - form: reactive({ - agent_id: '', - corpid: '', - corpsecret: '', - }), + form: reactive({}), + settingList: [] as any[], }) const origin = ref(6) const id = ref() -const rule = reactive({ - agent_id: [ - { - required: true, - message: t('common.require'), - trigger: 'blur', - }, - { - min: 5, - max: 20, - message: t('common.input_limit', [5, 20]), - trigger: 'blur', - }, - ], - corpid: [ - { - required: true, - message: t('common.require'), - trigger: 'blur', - }, - { - min: 5, - max: 20, - message: t('common.input_limit', [5, 20]), - trigger: 'blur', - }, - ], - corpsecret: [ - { - required: true, - message: t('common.require'), - trigger: 'blur', - }, - { - min: 5, - max: 100, - message: t('common.input_limit', [5, 100]), - trigger: 'blur', - }, - ], -}) - +const rule = reactive({}) +const formTitle = ref('') +const busiMapping = { + 6: 'wecom', + 7: 'dingtalk', + 8: 'lark', + 9: 'larksuite', +} as any +const initForm = (row: any) => { + state.settingList.forEach((item: any) => { + const key = item.realKey + rule[key] = [ + { + required: true, + message: t('common.require'), + trigger: 'blur', + }, + { + min: 5, + max: 255, + message: t('common.input_limit', [5, 255]), + trigger: 'blur', + }, + ] + state.form[key] = row[key] + }) +} const edit = (row: any) => { - state.form = { - agent_id: row.agent_id, - corpid: row.corpid, - corpsecret: row.corpsecret, - } + state.settingList = settingMapping[row.type] + initForm(row) + origin.value = row.type + formTitle.value = row.title if (row?.id) { id.value = row.id } @@ -86,7 +64,7 @@ const submitForm = async (formEl: FormInstance | undefined) => { const data = { id: origin.value, type: origin.value, - name: 'wecom', + name: busiMapping[origin.value], config: JSON.stringify(param), } const method = id.value @@ -122,10 +100,15 @@ const resetForm = (formEl: FormInstance | undefined) => { formEl.resetFields() dialogVisible.value = false id.value = null + origin.value = 6 + formTitle.value = '' + state.settingList = [] + const keys = Object.keys(rule) + keys.forEach((key: string) => delete rule[key]) } const reset = () => { - resetForm(wecomForm.value) + resetForm(platformForm.value) } const showLoading = () => { @@ -137,28 +120,34 @@ const closeLoading = () => { loadingInstance.value?.close() } -const validate = () => { - const url = '/system/authentication/status' - const config_data = state.form - const data = { - type: origin.value, - name: 'wecom', - config: JSON.stringify(config_data), - } - showLoading() - request - .patch(url, data) - .then((res) => { - if (res) { - ElMessage.success(t('ds.connection_success')) - } else { - ElMessage.error(t('ds.connection_failed')) - } - }) - .finally(() => { - closeLoading() - emits('saved') - }) +const validate = async (formEl: FormInstance | undefined) => { + if (!formEl) return + await formEl.validate((valid) => { + if (!valid) { + return + } + const url = '/system/authentication/status' + const config_data = state.form + const data = { + type: origin.value, + name: busiMapping[origin.value], + config: JSON.stringify(config_data), + } + showLoading() + request + .patch(url, data) + .then((res) => { + if (res) { + ElMessage.success(t('ds.connection_success')) + } else { + ElMessage.error(t('ds.connection_failed')) + } + }) + .finally(() => { + closeLoading() + emits('saved') + }) + }) } defineExpose({ @@ -169,46 +158,46 @@ defineExpose({ - diff --git a/frontend/src/views/system/platform/lark/LarkInfo.vue b/frontend/src/views/system/platform/lark/LarkInfo.vue deleted file mode 100644 index 76d8974a..00000000 --- a/frontend/src/views/system/platform/lark/LarkInfo.vue +++ /dev/null @@ -1,240 +0,0 @@ - - - - - diff --git a/frontend/src/views/system/platform/larksuite/LarksuiteEdit.vue b/frontend/src/views/system/platform/larksuite/LarksuiteEdit.vue deleted file mode 100644 index 043b92e4..00000000 --- a/frontend/src/views/system/platform/larksuite/LarksuiteEdit.vue +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - diff --git a/frontend/src/views/system/platform/larksuite/LarksuiteInfo.vue b/frontend/src/views/system/platform/larksuite/LarksuiteInfo.vue deleted file mode 100644 index 4e95763a..00000000 --- a/frontend/src/views/system/platform/larksuite/LarksuiteInfo.vue +++ /dev/null @@ -1,241 +0,0 @@ - - - - -