Skip to content

Commit 178632c

Browse files
committed
修复选择语言后布局变化的问题
1 parent fa0f345 commit 178632c

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/components/ExpressionEditor.vue

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -750,13 +750,7 @@ const deleteLast = () => {
750750
const lastChar = beforeCursor[beforeCursor.length - 1];
751751
const isLastCharNumber = /\d/.test(lastChar);
752752
753-
if (isLastCharNumber) {
754-
// 如果光标在数字后面,删除该数字
755-
displayExpression.value = beforeCursor.slice(0, -1) + afterCursor;
756-
} else {
757-
// 如果是操作符,直接删除前一个字符
758-
displayExpression.value = beforeCursor.slice(0, -1) + afterCursor;
759-
}
753+
displayExpression.value = beforeCursor.slice(0, -1) + afterCursor;
760754
}
761755
762756
expression.value = convertDisplayToReal(displayExpression.value);
@@ -987,23 +981,22 @@ const toggleShowExpression = () => {
987981
showExpression.value = !showExpression.value;
988982
};
989983
990-
// 修改校验函数
984+
// 修改验证表达式的处理方法
991985
const validateExpression = () => {
992986
// 如果公式为空
993987
if (!displayExpression.value.trim()) {
994988
showValidationError.value = true;
995989
showValidationSuccess.value = false;
996-
validationMessage.value = t('editor.emptyFormula');
990+
validationMessage.value = t('messages.emptyFormula');
997991
validationStatus.value = 'error';
998992
999-
// 设置3秒后自动清除校验状态
1000993
if (validationTimer) {
1001994
clearTimeout(validationTimer);
1002995
}
1003996
validationTimer = window.setTimeout(() => {
1004997
showValidationSuccess.value = false;
1005998
showValidationError.value = false;
1006-
validationMessage.value = defaultTipMessage.value; // 恢复默认提示
999+
validationMessage.value = defaultTipMessage.value;
10071000
validationStatus.value = '';
10081001
}, 3000);
10091002
return;
@@ -1016,21 +1009,20 @@ const validateExpression = () => {
10161009
if (!result) {
10171010
showValidationError.value = true;
10181011
showValidationSuccess.value = false;
1019-
validationMessage.value = t('editor.invalidFormula');
1012+
validationMessage.value = t('messages.validError');
10201013
validationStatus.value = 'error';
10211014
} else if (!isFormulaComplete.value) {
10221015
showValidationError.value = true;
10231016
showValidationSuccess.value = false;
1024-
validationMessage.value = t('editor.incompleteFormula');
1017+
validationMessage.value = t('editor.incompleteTip');
10251018
validationStatus.value = 'error';
10261019
} else {
10271020
showValidationSuccess.value = true;
10281021
showValidationError.value = false;
1029-
validationMessage.value = t('editor.validFormula');
1022+
validationMessage.value = t('messages.validSuccess');
10301023
validationStatus.value = 'success';
10311024
}
10321025
1033-
// 设置3秒后自动清除校验状态
10341026
if (validationTimer) {
10351027
clearTimeout(validationTimer);
10361028
}
@@ -1044,7 +1036,7 @@ const validateExpression = () => {
10441036
} catch (error) {
10451037
showValidationError.value = true;
10461038
showValidationSuccess.value = false;
1047-
validationMessage.value = t('editor.invalidFormula');
1039+
validationMessage.value = t('messages.validError');
10481040
validationStatus.value = 'error';
10491041
}
10501042
};
@@ -1399,11 +1391,15 @@ const handleSettingsSave = (settings: {
13991391
autoCompleteBrackets.value = settings.autoCompleteBrackets;
14001392
bracketColorEnabled.value = settings.bracketColorEnabled;
14011393
horizontalLayout.value = settings.horizontalLayout;
1402-
// 添加语言设置的保存
1394+
// 添加语言设置的保存,保持布局设置不变
14031395
if (settings.language !== props.language) {
14041396
emit('update:language', settings.language);
14051397
}
1406-
localStorage.setItem('editor-settings', JSON.stringify(settings));
1398+
// 保存所有设置,包括当前的布局设置
1399+
localStorage.setItem('editor-settings', JSON.stringify({
1400+
...settings,
1401+
horizontalLayout: horizontalLayout.value
1402+
}));
14071403
settingsDialogVisible.value = false;
14081404
};
14091405

0 commit comments

Comments
 (0)