Compare commits

..

No commits in common. "master" and "2.2.1" have entirely different histories.

2 changed files with 46 additions and 52 deletions

View File

@ -1,8 +1,4 @@
/* eslint-disable */
// 四则运算
!(function () {
var calculate = function (s) {
module.exports = function (s) {
s = s.trim();
const stack = new Array();
let preSign = '+';
@ -22,7 +18,7 @@
numStr = `${calculate(s.slice(i + 1, j))}`;
i = j;
}
if ((isNaN(Number(s[i])) && s[i] !== '.') || i === n - 1) {
if (isNaN(Number(s[i]) && s[i] !== '.') || i === n - 1) {
let num = parseFloat(numStr);
switch (preSign) {
case '+':
@ -49,6 +45,4 @@
ans += stack.pop();
}
return ans;
};
module.exports = calculate;
})();
};

View File

@ -851,7 +851,7 @@ function setStringPrototype(screenK, scale) {
const formula = /^calc\((.+)\)$/.exec(this);
if (formula && formula[1]) {
// 进行 calc 计算
const afterOne = formula[1].replace(/([^\s\(\+\-\*\/]+)\.(left|right|bottom|top|width|height)/g, word => {
const afterOne = formula[1].replace(/([^\s]+)\.(left|right|bottom|top|width|height)/g, word => {
const [id, attr] = word.split('.');
return penCache.viewRect[id][attr];
});