Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Aug 31, 2024
1 parent 4e365f5 commit 43c3776
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/consts/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const baseProxyUrlPath = '/proxy';
const baseAmapApiProxyUrlPath = '/_AMapService';
const apiNotFoundErrorCode = 100001;
const validatorErrorCode = 200000;
const userEmailNotVerifiedErrorCode = 201020;
const transactionPictureNotFoundErrorCode = 211001;
const googleMapJavascriptUrl = 'https://maps.googleapis.com/maps/api/js';
const baiduMapJavascriptUrl = 'https://api.map.baidu.com/api?v=3.0';
const amapJavascriptUrl = 'https://webapi.amap.com/maps?v=2.0';
Expand Down Expand Up @@ -145,6 +147,8 @@ export default {
baseAmapApiProxyUrlPath: baseAmapApiProxyUrlPath,
apiNotFoundErrorCode: apiNotFoundErrorCode,
validatorErrorCode: validatorErrorCode,
userEmailNotVerifiedErrorCode: userEmailNotVerifiedErrorCode,
transactionPictureNotFoundErrorCode: transactionPictureNotFoundErrorCode,
specifiedApiNotFoundErrors: specifiedApiNotFoundErrors,
parameterizedErrors: parameterizedErrors,
googleMapJavascriptUrl: googleMapJavascriptUrl,
Expand Down
3 changes: 2 additions & 1 deletion src/views/desktop/LoginPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ import { useSettingsStore } from '@/stores/setting.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import assetConstants from '@/consts/asset.js';
import apiConstants from '@/consts/api.js';
import {
isUserRegistrationEnabled,
isUserForgetPasswordEnabled,
Expand Down Expand Up @@ -314,7 +315,7 @@ export default {
}).catch(error => {
self.logining = false;
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === 201020 && error.error.context && error.error.context.email) {
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === apiConstants.userEmailNotVerifiedErrorCode && error.error.context && error.error.context.email) {
self.$router.push(`/verify_email?email=${encodeURIComponent(error.error.context.email)}&emailSent=${error.error.context.hasValidEmailVerifyToken || false}`);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/views/desktop/transactions/list/dialogs/EditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ import fileConstants from '@/consts/file.js';
import categoryConstants from '@/consts/category.js';
import transactionConstants from '@/consts/transaction.js';
import templateConstants from '@/consts/template.js';
import apiConstants from '@/consts/api.js';
import logger from '@/lib/logger.js';
import {
isArray,
Expand Down Expand Up @@ -1161,7 +1162,7 @@ export default {
self.removingPictureId = '';
self.submitting = false;
}).catch(error => {
if (error.error && error.error.errorCode === 211001) {
if (error.error && error.error.errorCode === apiConstants.transactionPictureNotFoundErrorCode) {
for (let i = 0; i < self.transaction.pictures.length; i++) {
if (self.transaction.pictures[i].pictureId === pictureInfo.pictureId) {
self.transaction.pictures.splice(i, 1);
Expand Down
3 changes: 2 additions & 1 deletion src/views/mobile/LoginPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ import { useSettingsStore } from '@/stores/setting.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import assetConstants from '@/consts/asset.js';
import apiConstants from '@/consts/api.js';
import {
isUserRegistrationEnabled,
isUserForgetPasswordEnabled,
Expand Down Expand Up @@ -324,7 +325,7 @@ export default {
self.logining = false;
self.$hideLoading();
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === 201020 && error.error.context && error.error.context.email) {
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === apiConstants.userEmailNotVerifiedErrorCode && error.error.context && error.error.context.email) {
self.resendVerifyEmail = error.error.context.email;
self.hasValidEmailVerifyToken = error.error.context.hasValidEmailVerifyToken || false;
self.currentPasswordForResendVerifyEmail = '';
Expand Down
3 changes: 2 additions & 1 deletion src/views/mobile/transactions/EditPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ import fileConstants from '@/consts/file.js';
import categoryConstants from '@/consts/category.js';
import transactionConstants from '@/consts/transaction.js';
import templateConstants from '@/consts/template.js';
import apiConstants from '@/consts/api.js';
import logger from '@/lib/logger.js';
import {
isArray,
Expand Down Expand Up @@ -1220,7 +1221,7 @@ export default {
self.removingPictureId = '';
self.submitting = false;
}).catch(error => {
if (error.error && error.error.errorCode === 211001) {
if (error.error && error.error.errorCode === apiConstants.transactionPictureNotFoundErrorCode) {
for (let i = 0; i < self.transaction.pictures.length; i++) {
if (self.transaction.pictures[i].pictureId === pictureInfo.pictureId) {
self.transaction.pictures.splice(i, 1);
Expand Down

0 comments on commit 43c3776

Please sign in to comment.