code refactor

This commit is contained in:
MaysWind
2023-04-08 15:58:07 +08:00
parent c4b07b98aa
commit 8c33243c90
8 changed files with 16 additions and 16 deletions
+2 -2
View File
@@ -125,7 +125,7 @@ export default {
return str; return str;
} }
let integer = str.substr(0, dotPos); let integer = str.substring(0, dotPos);
let decimals = str.substring(dotPos + 1, str.length); let decimals = str.substring(dotPos + 1, str.length);
let newDecimals = ''; let newDecimals = '';
@@ -232,7 +232,7 @@ export default {
return; return;
} }
this.currentValue = this.currentValue.substr(0, this.currentValue.length - 1); this.currentValue = this.currentValue.substring(0, this.currentValue.length - 1);
}, },
clear() { clear() {
this.currentValue = ''; this.currentValue = '';
+1 -1
View File
@@ -13,6 +13,6 @@ export default function (rate) {
} }
} }
return rateStr.substr(0, Math.max(6, Math.max(firstNonZeroPos, rateStr.indexOf('.') + 2))); return rateStr.substring(0, Math.max(6, Math.max(firstNonZeroPos, rateStr.indexOf('.') + 2)));
} }
} }
+1 -1
View File
@@ -15,5 +15,5 @@ export default function (value, maxLength) {
return value; return value;
} }
return value.substr(0, maxLength - 3) + '...'; return value.substring(0, maxLength - 3) + '...';
} }
+1 -1
View File
@@ -14,7 +14,7 @@ const appLockStateSessionStorageKey = 'ebk_user_app_lock_state'; // { 'username'
function getAppLockSecret(pinCode) { function getAppLockSecret(pinCode) {
const hashedPinCode = CryptoJS.SHA256(appLockSecretBaseStringPrefix + pinCode).toString(); const hashedPinCode = CryptoJS.SHA256(appLockSecretBaseStringPrefix + pinCode).toString();
return hashedPinCode.substr(0, 24); // put secret into user id of webauthn (user id total length must less 64 bytes) return hashedPinCode.substring(0, 24); // put secret into user id of webauthn (user id total length must less 64 bytes)
} }
function getEncryptedToken(token, appLockState) { function getEncryptedToken(token, appLockState) {
+8 -8
View File
@@ -455,11 +455,11 @@ function appendThousandsSeparator(value) {
const negative = value.charAt(0) === '-'; const negative = value.charAt(0) === '-';
if (negative) { if (negative) {
value = value.substr(1); value = value.substring(1);
} }
const dotPos = value.indexOf('.'); const dotPos = value.indexOf('.');
const integer = dotPos < 0 ? value : value.substr(0, dotPos); const integer = dotPos < 0 ? value : value.substring(0, dotPos);
const decimals = dotPos < 0 ? '' : value.substring(dotPos + 1, value.length); const decimals = dotPos < 0 ? '' : value.substring(dotPos + 1, value.length);
const finalChars = []; const finalChars = [];
@@ -492,7 +492,7 @@ function numericCurrencyToString(num) {
const negative = str.charAt(0) === '-'; const negative = str.charAt(0) === '-';
if (negative) { if (negative) {
str = str.substr(1); str = str.substring(1);
} }
if (str.length === 0) { if (str.length === 0) {
@@ -502,8 +502,8 @@ function numericCurrencyToString(num) {
} else if (str.length === 2) { } else if (str.length === 2) {
str = '0.' + str; str = '0.' + str;
} else { } else {
let integer = str.substr(0, str.length - 2); let integer = str.substring(0, str.length - 2);
let decimals = str.substr(str.length - 2, 2); let decimals = str.substring(str.length - 2);
integer = appendThousandsSeparator(integer); integer = appendThousandsSeparator(integer);
@@ -525,7 +525,7 @@ function stringCurrencyToNumeric(str) {
const negative = str.charAt(0) === '-'; const negative = str.charAt(0) === '-';
if (negative) { if (negative) {
str = str.substr(1); str = str.substring(1);
} }
if (!str || str.length < 1) { if (!str || str.length < 1) {
@@ -547,7 +547,7 @@ function stringCurrencyToNumeric(str) {
dotPos++; dotPos++;
} }
const integer = str.substr(0, dotPos); const integer = str.substring(0, dotPos);
const decimals = str.substring(dotPos + 1, str.length); const decimals = str.substring(dotPos + 1, str.length);
if (decimals.length < 1) { if (decimals.length < 1) {
@@ -557,7 +557,7 @@ function stringCurrencyToNumeric(str) {
} else if (decimals.length === 2) { } else if (decimals.length === 2) {
return sign * parseInt(integer) * 100 + sign * parseInt(decimals); return sign * parseInt(integer) * 100 + sign * parseInt(decimals);
} else { } else {
return sign * parseInt(integer) * 100 + sign * parseInt(decimals.substr(0, 2)); return sign * parseInt(integer) * 100 + sign * parseInt(decimals.substring(0, 2));
} }
} }
+1 -1
View File
@@ -478,7 +478,7 @@ export default {
return; return;
} }
const id = event.el.id.substr(8); // account_ const id = event.el.id.substring(8); // account_
self.$store.dispatch('changeAccountDisplayOrder', { self.$store.dispatch('changeAccountDisplayOrder', {
accountId: id, accountId: id,
+1 -1
View File
@@ -250,7 +250,7 @@ export default {
return; return;
} }
const id = event.el.id.substr(9); // category_ const id = event.el.id.substring(9); // category_
self.$store.dispatch('changeCategoryDisplayOrder', { self.$store.dispatch('changeCategoryDisplayOrder', {
categoryId: id, categoryId: id,
+1 -1
View File
@@ -259,7 +259,7 @@ export default {
return; return;
} }
const id = event.el.id.substr(4); // tag_ const id = event.el.id.substring(4); // tag_
self.$store.dispatch('changeTagDisplayOrder', { self.$store.dispatch('changeTagDisplayOrder', {
tagId: id, tagId: id,