Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 密钥关联规则检测不够灵敏 --bug=118043305 #2807

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,17 +111,25 @@ const handleRevoke = (index: number) => {
updateRuleParams();
};

const testRule = (rule: string) => {
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 @@ -154,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 @@ -219,6 +228,7 @@ defineExpose({ handleRuleValidate });
}
}
.error-info {
margin: 4px 0 6px;
height: 16px;
color: #ea3636;
font-size: 12px;
Expand Down
Loading