Skip to content

Commit

Permalink
Merge remote-tracking branch 'github-bk-bcs/master'
Browse files Browse the repository at this point in the history
* github-bk-bcs/master:
  Fix: 密钥关联规则检测不够灵敏 --bug=118043305 (#2807)
  fix: 修复密钥关联配置文件规则无法保存*符号的问题 (#2805)
  • Loading branch information
wenxinlee2015 committed Dec 8, 2023
2 parents fd7c45a + 4ec2e9b commit 5baac4d
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class="rule-input"
placeholder="请填写"
:disabled="rule.type === 'del'"
@input="handleInput(index)"
@blur="handleRuleContentChange(index)"
>
<template #suffix>
Expand Down Expand Up @@ -110,11 +111,25 @@ const handleRevoke = (index: number) => {
updateRuleParams();
};
const testRule = (rule: string) => /\/([A-Za-z0-9]+[A-Za-z0-9-_.]*\/?)*$/.test(rule);
const validateRule = (rule: string) => {
if (rule.length < 2) {
return false;
}
const paths = rule.split('/');
return paths.length > 1 && paths.every(path => path.length > 0);
};
// 产品逻辑:没有检测到输入错误时:鼠标失焦后检测;如果检测到错误时:输入框只要有内容变化就要检测
const handleInput = (index: number) => {
const rule = localRules.value[index];
if (!rule.isRight) {
rule.isRight = validateRule(rule.content);
}
};
const handleRuleContentChange = (index: number) => {
const rule = localRules.value[index];
localRules.value[index].isRight = testRule(rule.content);
localRules.value[index].isRight = validateRule(rule.content);
if (rule.id) {
rule.type = rule.content === rule.original ? '' : 'modify';
}
Expand Down Expand Up @@ -148,7 +163,7 @@ const updateRuleParams = () => {
const handleRuleValidate = () => {
localRules.value.forEach((item) => {
item.isRight = testRule(item.content);
item.isRight = validateRule(item.content);
});
return localRules.value.some(item => !item.isRight);
};
Expand Down Expand Up @@ -213,6 +228,7 @@ defineExpose({ handleRuleValidate });
}
}
.error-info {
margin: 4px 0 6px;
height: 16px;
color: #ea3636;
font-size: 12px;
Expand Down

0 comments on commit 5baac4d

Please sign in to comment.