@@ -750,13 +750,7 @@ const deleteLast = () => {
750
750
const lastChar = beforeCursor [beforeCursor .length - 1 ];
751
751
const isLastCharNumber = / \d / .test (lastChar );
752
752
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 ;
760
754
}
761
755
762
756
expression .value = convertDisplayToReal (displayExpression .value );
@@ -987,23 +981,22 @@ const toggleShowExpression = () => {
987
981
showExpression .value = ! showExpression .value ;
988
982
};
989
983
990
- // 修改校验函数
984
+ // 修改验证表达式的处理方法
991
985
const validateExpression = () => {
992
986
// 如果公式为空
993
987
if (! displayExpression .value .trim ()) {
994
988
showValidationError .value = true ;
995
989
showValidationSuccess .value = false ;
996
- validationMessage .value = t (' editor .emptyFormula' );
990
+ validationMessage .value = t (' messages .emptyFormula' );
997
991
validationStatus .value = ' error' ;
998
992
999
- // 设置3秒后自动清除校验状态
1000
993
if (validationTimer ) {
1001
994
clearTimeout (validationTimer );
1002
995
}
1003
996
validationTimer = window .setTimeout (() => {
1004
997
showValidationSuccess .value = false ;
1005
998
showValidationError .value = false ;
1006
- validationMessage .value = defaultTipMessage .value ; // 恢复默认提示
999
+ validationMessage .value = defaultTipMessage .value ;
1007
1000
validationStatus .value = ' ' ;
1008
1001
}, 3000 );
1009
1002
return ;
@@ -1016,21 +1009,20 @@ const validateExpression = () => {
1016
1009
if (! result ) {
1017
1010
showValidationError .value = true ;
1018
1011
showValidationSuccess .value = false ;
1019
- validationMessage .value = t (' editor.invalidFormula ' );
1012
+ validationMessage .value = t (' messages.validError ' );
1020
1013
validationStatus .value = ' error' ;
1021
1014
} else if (! isFormulaComplete .value ) {
1022
1015
showValidationError .value = true ;
1023
1016
showValidationSuccess .value = false ;
1024
- validationMessage .value = t (' editor.incompleteFormula ' );
1017
+ validationMessage .value = t (' editor.incompleteTip ' );
1025
1018
validationStatus .value = ' error' ;
1026
1019
} else {
1027
1020
showValidationSuccess .value = true ;
1028
1021
showValidationError .value = false ;
1029
- validationMessage .value = t (' editor.validFormula ' );
1022
+ validationMessage .value = t (' messages.validSuccess ' );
1030
1023
validationStatus .value = ' success' ;
1031
1024
}
1032
1025
1033
- // 设置3秒后自动清除校验状态
1034
1026
if (validationTimer ) {
1035
1027
clearTimeout (validationTimer );
1036
1028
}
@@ -1044,7 +1036,7 @@ const validateExpression = () => {
1044
1036
} catch (error ) {
1045
1037
showValidationError .value = true ;
1046
1038
showValidationSuccess .value = false ;
1047
- validationMessage .value = t (' editor.invalidFormula ' );
1039
+ validationMessage .value = t (' messages.validError ' );
1048
1040
validationStatus .value = ' error' ;
1049
1041
}
1050
1042
};
@@ -1399,11 +1391,15 @@ const handleSettingsSave = (settings: {
1399
1391
autoCompleteBrackets .value = settings .autoCompleteBrackets ;
1400
1392
bracketColorEnabled .value = settings .bracketColorEnabled ;
1401
1393
horizontalLayout .value = settings .horizontalLayout ;
1402
- // 添加语言设置的保存
1394
+ // 添加语言设置的保存,保持布局设置不变
1403
1395
if (settings .language !== props .language ) {
1404
1396
emit (' update:language' , settings .language );
1405
1397
}
1406
- localStorage .setItem (' editor-settings' , JSON .stringify (settings ));
1398
+ // 保存所有设置,包括当前的布局设置
1399
+ localStorage .setItem (' editor-settings' , JSON .stringify ({
1400
+ ... settings ,
1401
+ horizontalLayout: horizontalLayout .value
1402
+ }));
1407
1403
settingsDialogVisible .value = false ;
1408
1404
};
1409
1405
0 commit comments