From 8c33243c90abcafd599782084f5acff835d1b9c8 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 8 Apr 2023 15:58:07 +0800 Subject: [PATCH] code refactor --- src/components/mobile/NumberPadSheet.vue | 4 ++-- src/filters/exchangeRate.js | 2 +- src/filters/textLimit.js | 2 +- src/lib/userstate.js | 2 +- src/lib/utils.js | 16 ++++++++-------- src/views/mobile/accounts/List.vue | 2 +- src/views/mobile/categories/List.vue | 2 +- src/views/mobile/tags/List.vue | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/mobile/NumberPadSheet.vue b/src/components/mobile/NumberPadSheet.vue index aeba5855..937c8101 100644 --- a/src/components/mobile/NumberPadSheet.vue +++ b/src/components/mobile/NumberPadSheet.vue @@ -125,7 +125,7 @@ export default { return str; } - let integer = str.substr(0, dotPos); + let integer = str.substring(0, dotPos); let decimals = str.substring(dotPos + 1, str.length); let newDecimals = ''; @@ -232,7 +232,7 @@ export default { return; } - this.currentValue = this.currentValue.substr(0, this.currentValue.length - 1); + this.currentValue = this.currentValue.substring(0, this.currentValue.length - 1); }, clear() { this.currentValue = ''; diff --git a/src/filters/exchangeRate.js b/src/filters/exchangeRate.js index 9e98ad3c..e87c9ce3 100644 --- a/src/filters/exchangeRate.js +++ b/src/filters/exchangeRate.js @@ -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))); } } diff --git a/src/filters/textLimit.js b/src/filters/textLimit.js index 711d4e22..5e5f0a1d 100644 --- a/src/filters/textLimit.js +++ b/src/filters/textLimit.js @@ -15,5 +15,5 @@ export default function (value, maxLength) { return value; } - return value.substr(0, maxLength - 3) + '...'; + return value.substring(0, maxLength - 3) + '...'; } diff --git a/src/lib/userstate.js b/src/lib/userstate.js index 2ede1b0b..7591aab5 100644 --- a/src/lib/userstate.js +++ b/src/lib/userstate.js @@ -14,7 +14,7 @@ const appLockStateSessionStorageKey = 'ebk_user_app_lock_state'; // { 'username' function getAppLockSecret(pinCode) { 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) { diff --git a/src/lib/utils.js b/src/lib/utils.js index da5e7714..e9b25f60 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -455,11 +455,11 @@ function appendThousandsSeparator(value) { const negative = value.charAt(0) === '-'; if (negative) { - value = value.substr(1); + value = value.substring(1); } 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 finalChars = []; @@ -492,7 +492,7 @@ function numericCurrencyToString(num) { const negative = str.charAt(0) === '-'; if (negative) { - str = str.substr(1); + str = str.substring(1); } if (str.length === 0) { @@ -502,8 +502,8 @@ function numericCurrencyToString(num) { } else if (str.length === 2) { str = '0.' + str; } else { - let integer = str.substr(0, str.length - 2); - let decimals = str.substr(str.length - 2, 2); + let integer = str.substring(0, str.length - 2); + let decimals = str.substring(str.length - 2); integer = appendThousandsSeparator(integer); @@ -525,7 +525,7 @@ function stringCurrencyToNumeric(str) { const negative = str.charAt(0) === '-'; if (negative) { - str = str.substr(1); + str = str.substring(1); } if (!str || str.length < 1) { @@ -547,7 +547,7 @@ function stringCurrencyToNumeric(str) { dotPos++; } - const integer = str.substr(0, dotPos); + const integer = str.substring(0, dotPos); const decimals = str.substring(dotPos + 1, str.length); if (decimals.length < 1) { @@ -557,7 +557,7 @@ function stringCurrencyToNumeric(str) { } else if (decimals.length === 2) { return sign * parseInt(integer) * 100 + sign * parseInt(decimals); } else { - return sign * parseInt(integer) * 100 + sign * parseInt(decimals.substr(0, 2)); + return sign * parseInt(integer) * 100 + sign * parseInt(decimals.substring(0, 2)); } } diff --git a/src/views/mobile/accounts/List.vue b/src/views/mobile/accounts/List.vue index b1e69443..abe8bf07 100644 --- a/src/views/mobile/accounts/List.vue +++ b/src/views/mobile/accounts/List.vue @@ -478,7 +478,7 @@ export default { return; } - const id = event.el.id.substr(8); // account_ + const id = event.el.id.substring(8); // account_ self.$store.dispatch('changeAccountDisplayOrder', { accountId: id, diff --git a/src/views/mobile/categories/List.vue b/src/views/mobile/categories/List.vue index ef6439ee..ace59537 100644 --- a/src/views/mobile/categories/List.vue +++ b/src/views/mobile/categories/List.vue @@ -250,7 +250,7 @@ export default { return; } - const id = event.el.id.substr(9); // category_ + const id = event.el.id.substring(9); // category_ self.$store.dispatch('changeCategoryDisplayOrder', { categoryId: id, diff --git a/src/views/mobile/tags/List.vue b/src/views/mobile/tags/List.vue index 57cc87e5..fce53b53 100644 --- a/src/views/mobile/tags/List.vue +++ b/src/views/mobile/tags/List.vue @@ -259,7 +259,7 @@ export default { return; } - const id = event.el.id.substr(4); // tag_ + const id = event.el.id.substring(4); // tag_ self.$store.dispatch('changeTagDisplayOrder', { tagId: id,