Skip to content

Commit 376bf0e

Browse files
committed
feat: scan support i18n
1 parent 769f6ff commit 376bf0e

File tree

6 files changed

+135
-31
lines changed

6 files changed

+135
-31
lines changed

ui/src/locales/lang/en_US/index.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default {
3131
professional: 'Purchase the Professional Edition',
3232
status: 'Status',
3333
createDate: 'Create date',
34-
operation: 'Operation',
34+
operation: 'Operation'
3535
},
3636
login: {
3737
authentication: 'Login Authentication',
@@ -109,6 +109,25 @@ export default {
109109
enableAuthentication: 'Enable OAuth2 Authentication',
110110
save: 'Save',
111111
saveSuccess: 'Save Success'
112+
},
113+
scanTheQRCode: {
114+
title: 'Scan the QR code',
115+
wecom: 'WeCom',
116+
dingtalk: 'DingTalk',
117+
lark: 'Lark',
118+
effective: 'Effective',
119+
alreadyTurnedOn: 'Turned On',
120+
notEnabled: 'Not Enabled',
121+
edit: 'Edit',
122+
validate: 'Validate',
123+
validateSuccess: 'Validation Successful',
124+
validateFailed: 'Validation Failed',
125+
validateFailedTip: 'Please fill in all required fields and ensure the format is correct',
126+
appKeyPlaceholder: 'Please enter App Key',
127+
appSecretPlaceholder: 'Please enter App Secret',
128+
corpIdPlaceholder: 'Please enter Corp ID',
129+
agentIdPlaceholder: 'Please enter Agent ID',
130+
callbackWarning: 'Please enter a valid URL address'
112131
}
113132
}
114133
}

ui/src/locales/lang/zh_CN/index.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ export default {
2727
add: '添加',
2828
refresh: '刷新',
2929
search: '搜索',
30-
clear:'清空',
30+
clear: '清空',
3131
professional: '购买专业版',
3232
status: '状态',
3333
createDate: '创建日期',
34-
operation: '操作',
34+
operation: '操作'
3535
},
3636
login: {
3737
authentication: '登录认证',
@@ -109,6 +109,25 @@ export default {
109109
enableAuthentication: '启用 OAuth2 认证',
110110
save: '保存',
111111
saveSuccess: '保存成功'
112+
},
113+
scanTheQRCode: {
114+
title: '扫码登录',
115+
wecom: '企业微信',
116+
dingtalk: '钉钉',
117+
lark: '飞书',
118+
effective: '有效',
119+
alreadyTurnedOn: '已开启',
120+
notEnabled: '未开启',
121+
edit: '编辑',
122+
validate: '校验',
123+
validateSuccess: '校验成功',
124+
validateFailed: '校验失败',
125+
validateFailedTip: '请填写所有必填项并确保格式正确',
126+
appKeyPlaceholder: '请输入 App Key',
127+
appSecretPlaceholder: '请输入 App Secret',
128+
corpIdPlaceholder: '请输入 Corp Id',
129+
agentIdPlaceholder: '请输入 Agent Id',
130+
callbackWarning: '请输入有效的 URL 地址'
112131
}
113132
}
114133
}

ui/src/locales/lang/zh_Hant/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,25 @@ export default {
109109
enableAuthentication: '啟用 OAuth2 認證',
110110
save: '儲存',
111111
saveSuccess: '儲存成功'
112+
},
113+
scanTheQRCode: {
114+
title: '掃碼登入',
115+
wecom: '企業微信',
116+
dingtalk: '釘釘',
117+
lark: '飛書',
118+
effective: '有效',
119+
alreadyTurnedOn: '已開啟',
120+
notEnabled: '未開啟',
121+
edit: '編輯',
122+
validate: '驗證',
123+
validateSuccess: '驗證成功',
124+
validateFailed: '驗證失敗',
125+
validateFailedTip: '請填寫所有必填項並確保格式正確',
126+
appKeyPlaceholder: '請輸入 App Key',
127+
appSecretPlaceholder: '請輸入 App Secret',
128+
corpIdPlaceholder: '請輸入 Corp Id',
129+
agentIdPlaceholder: '請輸入 Agent Id',
130+
callbackWarning: '請輸入有效的 URL 位址'
112131
}
113132
}
114133
}

ui/src/views/authentication/component/EditModal.vue

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ template
99
>
1010
<template #header>
1111
<div class="flex align-center" style="margin-left: -8px">
12-
<h4>{{ currentPlatform.name + '设置' }}</h4>
12+
<h4>{{ currentPlatform.name + ' ' + $t('common.setting') }}</h4>
1313
</div>
1414
</template>
1515

@@ -37,9 +37,9 @@ template
3737
</el-form>
3838
<template #footer>
3939
<span class="dialog-footer">
40-
<el-button @click="handleClose">取 消</el-button>
41-
<el-button @click="validateConnection">校 验</el-button>
42-
<el-button type="primary" @click="validateForm">保 存</el-button>
40+
<el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
41+
<el-button @click="validateConnection">{{ $t('login.scanTheQRCode.validate') }}</el-button>
42+
<el-button type="primary" @click="validateForm">{{ $t('common.save') }}</el-button>
4343
</span>
4444
</template>
4545
</el-drawer>
@@ -50,6 +50,7 @@ import { reactive, ref } from 'vue'
5050
import { ElForm } from 'element-plus'
5151
import platformApi from '@/api/platform-source'
5252
import { MsgError, MsgSuccess } from '@/utils/message'
53+
import { t } from '@/locales'
5354
5455
const visible = ref(false)
5556
const loading = ref(false)
@@ -83,7 +84,7 @@ const formatFieldName = (key?: any): string => {
8384
app_key: currentPlatform?.key != 'lark' ? 'APP Key' : 'App ID',
8485
app_secret: 'APP Secret',
8586
agent_id: 'Agent ID',
86-
callback_url: '回调地址'
87+
callback_url: t('views.application.applicationAccess.callback')
8788
}
8889
return (
8990
fieldNames[key as keyof typeof fieldNames] ||
@@ -94,17 +95,49 @@ const formatFieldName = (key?: any): string => {
9495
const getValidationRules = (key: any) => {
9596
switch (key) {
9697
case 'app_key':
97-
return [{ required: true, message: '请输入 APP Key', trigger: ['blur', 'change'] }]
98+
return [
99+
{
100+
required: true,
101+
message: t('login.scanTheQRCode.appKeyPlaceholder'),
102+
trigger: ['blur', 'change']
103+
}
104+
]
98105
case 'app_secret':
99-
return [{ required: true, message: '请输入 APP Secret', trigger: ['blur', 'change'] }]
106+
return [
107+
{
108+
required: true,
109+
message: t('login.scanTheQRCode.appSecretPlaceholder'),
110+
trigger: ['blur', 'change']
111+
}
112+
]
100113
case 'corp_id':
101-
return [{ required: true, message: '请输入 Corp ID', trigger: ['blur', 'change'] }]
114+
return [
115+
{
116+
required: true,
117+
message: t('login.scanTheQRCode.corpIdPlaceholder'),
118+
trigger: ['blur', 'change']
119+
}
120+
]
102121
case 'agent_id':
103-
return [{ required: true, message: '请输入 Agent ID', trigger: ['blur', 'change'] }]
122+
return [
123+
{
124+
required: true,
125+
message: t('login.scanTheQRCode.agentIdPlaceholder'),
126+
trigger: ['blur', 'change']
127+
}
128+
]
104129
case 'callback_url':
105130
return [
106-
{ required: true, message: '请输入回调地址', trigger: ['blur', 'change'] },
107-
{ pattern: /^https?:\/\/.+/, message: '请输入有效的 URL 地址', trigger: ['blur', 'change'] }
131+
{
132+
required: true,
133+
message: t('views.application.applicationAccess.callbackTip'),
134+
trigger: ['blur', 'change']
135+
},
136+
{
137+
pattern: /^https?:\/\/.+/,
138+
message: t('login.scanTheQRCode.callbackWarning'),
139+
trigger: ['blur', 'change']
140+
}
108141
]
109142
default:
110143
return []
@@ -153,7 +186,7 @@ const validateForm = () => {
153186
if (valid) {
154187
saveConfig()
155188
} else {
156-
MsgError('请填写所有必填项并确保格式正确')
189+
MsgError(t('login.scanTheQRCode.validateFailedTip'))
157190
}
158191
})
159192
}
@@ -167,9 +200,9 @@ const handleClose = () => {
167200
function validateConnection() {
168201
platformApi.validateConnection(currentPlatform, loading).then((res: any) => {
169202
if (res.data) {
170-
MsgSuccess('校验成功')
203+
MsgSuccess(t('login.scanTheQRCode.validateSuccess'))
171204
} else {
172-
MsgError('校验失败')
205+
MsgError(t('login.scanTheQRCode.validateFailed'))
173206
}
174207
})
175208
}
@@ -178,9 +211,10 @@ const passwordFields = new Set(['app_secret', 'client_secret', 'secret'])
178211
179212
const isPasswordField = (key: any) => passwordFields.has(key)
180213
const emit = defineEmits(['refresh'])
214+
181215
function saveConfig() {
182216
platformApi.updateConfig(currentPlatform, loading).then((res: any) => {
183-
MsgSuccess('保存成功')
217+
MsgSuccess(t('common.saveSuccess'))
184218
emit('refresh')
185219
visible.value = false
186220
formRef.value?.clearValidate()

ui/src/views/authentication/component/SCAN.vue

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77
<div class="flex align-center ml-8 mr-8">
88
<img :src="item.logoSrc" alt="" class="icon" />
99
<h5 style="margin-left: 8px">{{ item.name }}</h5>
10-
<el-tag v-if="item.isValid" type="success" class="ml-4">有效</el-tag>
10+
<el-tag v-if="item.isValid" type="success" class="ml-4"
11+
>{{ $t('login.scanTheQRCode.effective') }}
12+
</el-tag>
1113
</div>
1214
<div>
1315
<el-button type="primary" v-if="!item.isValid" @click="showDialog(item)"
14-
>接入</el-button
15-
>
16+
>接入
17+
</el-button>
1618
<span v-if="item.isValid">
17-
<span class="mr-4">{{ item.isActive ? '已开启' : '未开启' }}</span>
19+
<span class="mr-4">{{
20+
item.isActive
21+
? $t('login.scanTheQRCode.alreadyTurnedOn')
22+
: $t('login.scanTheQRCode.notEnabled')
23+
}}</span>
1824
<el-switch
1925
size="small"
2026
v-model="item.isActive"
@@ -64,8 +70,12 @@
6470
</div>
6571
</el-col>
6672
</el-row>
67-
<el-button type="primary" @click="showDialog(item)">编辑</el-button>
68-
<el-button @click="validateConnection(item)">校验</el-button>
73+
<el-button type="primary" @click="showDialog(item)">
74+
{{ $t('login.scanTheQRCode.edit') }}
75+
</el-button>
76+
<el-button @click="validateConnection(item)">
77+
{{ $t('login.scanTheQRCode.validate') }}
78+
</el-button>
6979
</div>
7080
</el-collapse-transition>
7181
</el-card>
@@ -81,6 +91,7 @@ import { copyClick } from '@/utils/clipboard'
8191
import EditModel from './EditModal.vue'
8292
import platformApi from '@/api/platform-source'
8393
import { MsgError, MsgSuccess } from '@/utils/message'
94+
import { t } from '@/locales'
8495
8596
interface PlatformConfig {
8697
[key: string]: string
@@ -106,9 +117,9 @@ onMounted(() => {
106117
107118
function initializePlatforms(): Platform[] {
108119
return [
109-
createPlatform('wecom', '企业微信'),
110-
createPlatform('dingtalk', '钉钉'),
111-
createPlatform('lark', '飞书')
120+
createPlatform('wecom', t('login.scanTheQRCode.wecom')),
121+
createPlatform('dingtalk', t('login.scanTheQRCode.dingtalk')),
122+
createPlatform('lark', t('login.scanTheQRCode.lark'))
112123
]
113124
}
114125
@@ -151,7 +162,7 @@ function formatFieldName(key?: any, item?: Platform): string {
151162
app_key: item?.key != 'lark' ? 'APP Key' : 'App ID',
152163
app_secret: 'APP Secret',
153164
agent_id: 'Agent ID',
154-
callback_url: '回调地址'
165+
callback_url: t('views.application.applicationAccess.callback')
155166
}
156167
return (
157168
fieldNames[key as keyof typeof fieldNames] ||
@@ -190,7 +201,9 @@ function getPlatformInfo() {
190201
191202
function validateConnection(currentPlatform: Platform) {
192203
platformApi.validateConnection(currentPlatform, loading).then((res: any) => {
193-
res.data ? MsgSuccess('校验成功') : MsgError('校验失败')
204+
res.data
205+
? MsgSuccess(t('login.scanTheQRCode.validateSuccess'))
206+
: MsgError(t('login.scanTheQRCode.validateFailed'))
194207
})
195208
}
196209
@@ -200,7 +213,7 @@ function refresh() {
200213
201214
function changeStatus(currentPlatform: Platform) {
202215
platformApi.updateConfig(currentPlatform, loading).then((res: any) => {
203-
MsgSuccess('操作成功')
216+
MsgSuccess(t('common.saveSuccess'))
204217
})
205218
}
206219

ui/src/views/authentication/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const tabList = [
4747
component: OAuth2
4848
},
4949
{
50-
label: '扫码登录',
50+
label: t('login.scanTheQRCode.title'),
5151
name: 'SCAN',
5252
component: SCAN
5353
}

0 commit comments

Comments
 (0)