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 */ module.exports = function (s) {
// 四则运算
!(function () {
var calculate = function (s) {
s = s.trim(); s = s.trim();
const stack = new Array(); const stack = new Array();
let preSign = '+'; let preSign = '+';
@ -22,7 +18,7 @@
numStr = `${calculate(s.slice(i + 1, j))}`; numStr = `${calculate(s.slice(i + 1, j))}`;
i = 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); let num = parseFloat(numStr);
switch (preSign) { switch (preSign) {
case '+': case '+':
@ -50,5 +46,3 @@
} }
return ans; return ans;
}; };
module.exports = calculate;
})();

View File

@ -851,7 +851,7 @@ function setStringPrototype(screenK, scale) {
const formula = /^calc\((.+)\)$/.exec(this); const formula = /^calc\((.+)\)$/.exec(this);
if (formula && formula[1]) { if (formula && formula[1]) {
// 进行 calc 计算 // 进行 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('.'); const [id, attr] = word.split('.');
return penCache.viewRect[id][attr]; return penCache.viewRect[id][attr];
}); });