Skip to content

Commit 1eb3c61

Browse files
committed
fix(Embedded Management): The interface URL is not in the URL format and is not verified, but can be saved successfully
1 parent 758c473 commit 1eb3c61

File tree

4 files changed

+65
-34
lines changed

4 files changed

+65
-34
lines changed

frontend/src/i18n/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"menu": {
3+
"add_interface_credentials": "Please add interface credentials",
34
"Data Q&A": "Data Q&A",
45
"Data Connections": "Data Sources",
56
"Dashboard": "Dashboard",
@@ -516,6 +517,7 @@
516517
"creating_advanced_applications": "Creating Advanced Applications",
517518
"configure_interface": "Configure interface",
518519
"interface_url": "Interface URL",
520+
"format_is_incorrect": "format is incorrect",
519521
"aes_enable": "Enable AES encryption",
520522
"aes_enable_tips": "The fields (host, user, password, dataBase, schema) are all encrypted using the AES-CBC-PKCS5Padding encryption method",
521523
"bit": "bit",

frontend/src/i18n/zh-CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"menu": {
3+
"add_interface_credentials": "请添加接口凭证",
34
"Data Q&A": "智能问数",
45
"Data Connections": "数据源",
56
"Dashboard": "仪表盘",
@@ -515,6 +516,7 @@
515516
"private": "私有",
516517
"configure_interface": "配置接口",
517518
"interface_url": "接口 URL",
519+
"format_is_incorrect": "格式不对",
518520
"aes_enable": "开启 AES 加密",
519521
"aes_enable_tips": "加密字段 (host, user, password, dataBase, schema) 均采用 AES-CBC-PKCS5Padding 加密方式",
520522
"bit": "",

frontend/src/views/system/embedded/SetUi.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ defineExpose({
536536
display: flex;
537537
align-items: center;
538538
justify-content: space-between;
539-
margin-top: 16px;
539+
margin-top: 88px;
540540
}
541541
}
542542
}

frontend/src/views/system/embedded/iframe.vue

Lines changed: 60 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,23 @@ const setUiRef = ref()
250250
const handleSetUi = (row: any) => {
251251
setUiRef.value.open(row)
252252
}
253-
253+
const validateUrl = (_: any, value: any, callback: any) => {
254+
if (value === '') {
255+
callback(
256+
new Error(
257+
t('datasource.please_enter') + t('common.empty') + t('embedded.cross_domain_settings')
258+
)
259+
)
260+
} else {
261+
var Expression = /(https?:\/\/)?([\da-z\.-]+)\.([a-z]{2,6})(:\d{1,5})?([\/\w\.-]*)*\/?(#[\S]+)?/ // eslint-disable-line
262+
var objExp = new RegExp(Expression)
263+
if (objExp.test(value) && !value.endsWith('/')) {
264+
callback()
265+
} else {
266+
callback(t('embedded.format_is_incorrect'))
267+
}
268+
}
269+
}
254270
const rules = {
255271
name: [
256272
{
@@ -262,13 +278,7 @@ const rules = {
262278
domain: [
263279
{
264280
required: true,
265-
message:
266-
t('datasource.please_enter') + t('common.empty') + t('embedded.cross_domain_settings'),
267-
trigger: 'blur',
268-
},
269-
{
270-
pattern: /^(https?:\/\/)?([\w-]+\.)*[\w-]+(:\d+)?$/,
271-
message: t('embedded.origin_format_error'),
281+
validator: validateUrl,
272282
trigger: 'blur',
273283
},
274284
],
@@ -283,20 +293,42 @@ const dsRules = {
283293
},
284294
],
285295
}
296+
const validatePass = (_: any, value: any, callback: any) => {
297+
if (value === '') {
298+
callback(
299+
new Error(t('datasource.please_enter') + t('common.empty') + t('embedded.interface_url'))
300+
)
301+
} else {
302+
var Expression = /(https?:\/\/)?([\da-z\.-]+)\.([a-z]{2,6})(:\d{1,5})?([\/\w\.-]*)*\/?(#[\S]+)?/ // eslint-disable-line
303+
var objExp = new RegExp(Expression)
304+
if (objExp.test(value) && value.startsWith(currentEmbedded.domain)) {
305+
callback()
306+
} else {
307+
callback(t('embedded.format_is_incorrect'))
308+
}
309+
}
310+
}
311+
312+
const validateCertificate = (_: any, value: any, callback: any) => {
313+
if (!value.length) {
314+
callback(new Error(t('menu.add_interface_credentials')))
315+
} else {
316+
callback()
317+
}
318+
}
286319
287320
const urlRules = {
288321
endpoint: [
289322
{
290323
required: true,
291-
message: t('datasource.please_enter') + t('common.empty') + t('embedded.interface_url'),
324+
validator: validatePass,
292325
trigger: 'blur',
293326
},
294327
],
295328
certificate: [
296329
{
297330
required: true,
298-
message:
299-
t('datasource.Please_select') + t('common.empty') + t('embedded.system_credential_type'),
331+
validator: validateCertificate,
300332
trigger: 'change',
301333
},
302334
],
@@ -767,7 +799,7 @@ const saveHandler = () => {
767799
autocomplete="off"
768800
/>
769801
</el-form-item>
770-
<el-form-item class="certificate-table_form" prop="type">
802+
<el-form-item class="certificate-table_form" prop="certificate">
771803
<template #label>
772804
<div class="title-content">
773805
<span class="title-form">{{ t('embedded.interface_credentials') }}</span>
@@ -824,10 +856,7 @@ const saveHandler = () => {
824856
</el-form-item>
825857
</el-form>
826858
</div>
827-
<div
828-
v-if="activeStep === 1 && !advancedApplication"
829-
class="drawer-content drawer-content_scroll"
830-
>
859+
<div v-if="activeStep === 1 && !advancedApplication" class="drawer-content">
831860
<div class="title">
832861
{{ $t('embedded.set_data_source') }}
833862
</div>
@@ -869,23 +898,21 @@ const saveHandler = () => {
869898
</div>
870899
</template>
871900
<div class="card-ds_content">
872-
<el-scrollbar>
873-
<DsCard
874-
v-for="(ele, index) in dsListOptions"
875-
:id="ele.id"
876-
:key="ele.id"
877-
:class="[0, 1].includes(index) && 'no-margin_top'"
878-
:name="ele.name"
879-
:type="ele.type"
880-
:type-name="ele.type_name"
881-
:description="ele.description"
882-
:is-private="!dsForm.public_list.includes(ele.id)"
883-
:num="ele.num"
884-
@active="handleActive(ele)"
885-
@private="handlePrivate(ele)"
886-
@public="handlePublic(ele)"
887-
></DsCard>
888-
</el-scrollbar>
901+
<DsCard
902+
v-for="(ele, index) in dsListOptions"
903+
:id="ele.id"
904+
:key="ele.id"
905+
:class="[0, 1].includes(index) && 'no-margin_top'"
906+
:name="ele.name"
907+
:type="ele.type"
908+
:type-name="ele.type_name"
909+
:description="ele.description"
910+
:is-private="!dsForm.public_list.includes(ele.id)"
911+
:num="ele.num"
912+
@active="handleActive(ele)"
913+
@private="handlePrivate(ele)"
914+
@public="handlePublic(ele)"
915+
></DsCard>
889916
</div>
890917
</el-form-item>
891918
</el-form>

0 commit comments

Comments
 (0)