From f065760fa7df1f88747395ab4b55349ce8b2faf0 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期一, 25 十二月 2023 13:35:43 +0800 Subject: [PATCH] Update#178944: 移除 lodash 套件 --- PAMapp/components/careerSelect.vue | 7 - PAMapp/components/editConsultantAvatar.vue | 5 PAMapp/pages/quickFilter/index.vue | 1 PAMapp/layouts/default.vue | 5 PAMapp/pages/questionnaire/_agentNo.vue | 84 +++++++++----------- PAMapp/store/localStorage.service.ts | 18 ++-- PAMapp/pages/accountSetting/index.vue | 49 ++++++------ PAMapp/shared/services/httpClient.ts | 12 +- PAMapp/shared/services/login.service.ts | 8 - PAMapp/pages/myAppointmentList.vue | 6 - PAMapp/components/BackActionBar.vue | 3 PAMapp/components/NavBar.vue | 9 +- PAMapp/components/singleSelectBtn.vue | 3 PAMapp/layouts/home.vue | 3 14 files changed, 97 insertions(+), 116 deletions(-) diff --git a/PAMapp/components/BackActionBar.vue b/PAMapp/components/BackActionBar.vue index 9623972..c6c5ef7 100644 --- a/PAMapp/components/BackActionBar.vue +++ b/PAMapp/components/BackActionBar.vue @@ -11,7 +11,6 @@ import { namespace } from 'nuxt-property-decorator'; import { Vue, Component,} from 'vue-property-decorator'; -import * as _ from 'lodash'; import { Role } from '~/shared/models/enum/Role'; const appointmentStore = namespace('appointment.store'); @@ -54,7 +53,7 @@ break; case 'agentInfo': const agentFeatureLabel = this.$route.name.includes('edit') ? '蝺刻摩撣唾����' : '���董�����'; - featureLabel = _.isEqual(this.currentRole,Role.ADMIN) + featureLabel = this.currentRole === Role.ADMIN ? agentFeatureLabel : '璆剖�鞈��' break; diff --git a/PAMapp/components/NavBar.vue b/PAMapp/components/NavBar.vue index 3242e17..992f570 100644 --- a/PAMapp/components/NavBar.vue +++ b/PAMapp/components/NavBar.vue @@ -54,7 +54,6 @@ import { Vue, Component } from 'vue-property-decorator'; import { Action, namespace, State, Watch } from 'nuxt-property-decorator'; import { Role } from '~/shared/models/enum/Role'; - import * as _ from 'lodash'; import { NotificationList } from '~/shared/models/reviews.model'; import { AppointmentLog } from '~/shared/models/appointment.model'; import loginService from '~/shared/services/login.service' @@ -156,20 +155,20 @@ routerNavigateTo(url: string): void { (this.$refs.dropdown as any).hide(); - _.isEqual(url,'') + url === '' ? this.logout() - : this.$router.push(_.isEqual(url,'/agentInfo/') ? url+this.consultantId :url); + : this.$router.push(url === '/agentInfo/' ? url+this.consultantId : url); } pushRouterByLoginRole(): void { - const link = _.isEqual(this.currentRole, Role.ADMIN) ? '/myAppointmentList/appointmentList' : '/'; + const link = this.currentRole === Role.ADMIN ? '/myAppointmentList/appointmentList' : '/'; this.$router.push(link); } logout(): void { loginService.logout().then(() => { this.storageClear(); - _.isEqual(this.$route.name, 'index') ? location.reload() : this.$router.push('/'); + this.$route.name === 'index' ? location.reload() : this.$router.push('/'); }); } diff --git a/PAMapp/components/careerSelect.vue b/PAMapp/components/careerSelect.vue index 3a0f848..30bf3d1 100644 --- a/PAMapp/components/careerSelect.vue +++ b/PAMapp/components/careerSelect.vue @@ -41,7 +41,6 @@ <script lang="ts"> import { Component , PropSync , Vue} from "vue-property-decorator"; - import * as _ from 'lodash'; @Component export default class CareerSelect extends Vue { @@ -83,7 +82,7 @@ patchInitValue(): void{ if(this.syncCareerSelect){ - if(_.includes(['憭','��'],this.syncCareerSelect)){ + if (['憭','��'].includes(this.syncCareerSelect)) { this.career = this.syncCareerSelect; }else{ this.career = '�隞�'; @@ -95,8 +94,8 @@ patchCareer(): void { this.showJobDrawer = false; this.syncCareerSelect = this.career === '�隞�' - ? _.cloneDeep(this.career_Other) - : _.cloneDeep(this.career); + ? JSON.parse(JSON.stringify(this.career_Other)) + : JSON.parse(JSON.stringify(this.career)); } get isCareerValid(): boolean { diff --git a/PAMapp/components/editConsultantAvatar.vue b/PAMapp/components/editConsultantAvatar.vue index 0b3832c..d36439d 100644 --- a/PAMapp/components/editConsultantAvatar.vue +++ b/PAMapp/components/editConsultantAvatar.vue @@ -38,7 +38,6 @@ import { MessageBox } from 'element-ui'; import { MessageBoxData } from 'element-ui/types/message-box'; - import _ from 'lodash'; import myConsultantService from '~/shared/services/my-consultant.service'; @@ -74,7 +73,7 @@ } handleAvatarUploaded(file:any): void { - const isFollowUploadRule =_.includes(file.raw.type,'image/'); + const isFollowUploadRule = file.raw.type.includes('image/'); isFollowUploadRule ? this.getImgSrc(file) : this.showFileUploadErrorMsg() } @@ -96,7 +95,7 @@ } private splitBase64WithCommon(base64: string): void { - const splitBase64= _.split(base64, ','); // �鈭�� data:image , base64 閫������; + const splitBase64 = base64.split(','); // �鈭�� data:image , base64 閫������; this.syncPhotoBase64 = splitBase64[1]; // NOTE: �����誑 agentNO ���� avatar ��仃���� // ����迨��靘蝭���*蝷�'������'���瘜�� [Tomas, 2022/1/3] diff --git a/PAMapp/components/singleSelectBtn.vue b/PAMapp/components/singleSelectBtn.vue index b7a4a55..8fbcd3b 100644 --- a/PAMapp/components/singleSelectBtn.vue +++ b/PAMapp/components/singleSelectBtn.vue @@ -21,7 +21,6 @@ <script lang="ts"> import { Component, Prop, PropSync, Vue } from "nuxt-property-decorator"; import { OptionBtnDto } from "~/shared/models/optionBtnDto.model"; - import * as _ from 'lodash'; @Component export default class SingleSelectBtn extends Vue { @@ -35,7 +34,7 @@ ////////////////////////////////////////////////////////////////////// patchValue(value: string | number): void { // 銝餉�圾瘙箸����甈∟��嚗暺������ - this.syncSingleSelected = _.isEqual(this.syncSingleSelected, value) ? "" : value; + this.syncSingleSelected = this.syncSingleSelected === value ? "" : value; } } </script> diff --git a/PAMapp/layouts/default.vue b/PAMapp/layouts/default.vue index 890a74c..e7d36c1 100644 --- a/PAMapp/layouts/default.vue +++ b/PAMapp/layouts/default.vue @@ -25,7 +25,6 @@ <script lang="ts"> import { Vue, Component } from 'vue-property-decorator'; - import * as _ from 'lodash'; @Component export default class DefaultLayout extends Vue { @@ -52,13 +51,13 @@ // format to {page}-container tag private routeFormatContainClass(route: string): string { const needContainBgRoutes = ['recommendConsultant', 'questionnaire-agentNo']; - return _.includes(needContainBgRoutes, route) ? route + '-container' : ''; + return needContainBgRoutes.includes(route) ? route + '-container' : ''; }; // format to {page}-banner or pam-no-banner tag private routeFormatBannerClass(route: string): string { const needBannerRoutes = ['recommendConsultant', 'quickFilter', 'myConsultantList-consultantList', 'myConsultantList-contactedList', 'myAppointmentList-appointmentList', 'myAppointmentList-contactedList', 'login', 'notification']; - return _.includes(needBannerRoutes, route) ? route + '-banner' : 'pam-no-banner'; + return needBannerRoutes.includes(route) ? route + '-banner' : 'pam-no-banner'; }; private bannerText: FeatureBannerTitle= { diff --git a/PAMapp/layouts/home.vue b/PAMapp/layouts/home.vue index 0ea0947..abfaaa9 100644 --- a/PAMapp/layouts/home.vue +++ b/PAMapp/layouts/home.vue @@ -9,7 +9,6 @@ </template> <script lang="ts"> import { Component ,Vue } from "nuxt-property-decorator"; - import * as _ from 'lodash'; @Component export default class DefaultLayout extends Vue { @@ -34,4 +33,4 @@ } } -</style> \ No newline at end of file +</style> diff --git a/PAMapp/pages/accountSetting/index.vue b/PAMapp/pages/accountSetting/index.vue index bf3a713..ded0832 100644 --- a/PAMapp/pages/accountSetting/index.vue +++ b/PAMapp/pages/accountSetting/index.vue @@ -164,8 +164,6 @@ import { Vue,Component } from 'vue-property-decorator' import { namespace } from 'vuex-class'; -import _ from 'lodash'; - import accountSettingService from '~/shared/services/account-setting.service'; import { UserSetting } from '~/shared/models/account.model'; @@ -202,28 +200,29 @@ //////////////////////////////////////////////////////////// mounted(){ - accountSettingService.getUserAccountSetting().then((userInfo: UserSetting)=>{ - this.defaultUserSetting = _.cloneDeep({ - name : userInfo.name || '', - phone: userInfo.phone || '', - email: userInfo.email || '', - }); - this.phoneValue = this.defaultUserSetting.phone!; - this.userNameValue = this.defaultUserSetting.name!; - this.emailValue = this.defaultUserSetting.email!; - }) - } + accountSettingService.getUserAccountSetting().then((userInfo: UserSetting)=>{ + this.defaultUserSetting = { + name : userInfo.name || '', + phone: userInfo.phone || '', + email: userInfo.email || '', + }; + this.phoneValue = this.defaultUserSetting.phone!; + this.userNameValue = this.defaultUserSetting.name!; + this.emailValue = this.defaultUserSetting.email!; + }) + } //////////////////////////////////////////////////////////// editField(fieldName: string): void { - const enablePromise = new Promise((resolve, reject) => { // 甇斤promise隤�� - resolve((this as any)[`${fieldName}Disabled`] = false); - }); - const targetInput = this.$refs[fieldName] as any; - enablePromise.then((_) => { - targetInput.focus(); - }); - } + const enablePromise = new Promise((resolve, reject) => { // 甇斤promise隤�� + resolve((this as any)[`${fieldName}Disabled`] = false); + }); + const targetInput = this.$refs[fieldName] as any; + enablePromise.then((_) => { + targetInput.focus(); + }); + } + updateAccountSetting(): void { const editSettingInfo: UserSetting = { name: this.userNameValue, @@ -238,10 +237,10 @@ } private resetSettingForm(): void { - this.userNameDisabled = true; - this.userPhoneDisabled = true; - this.userEmailDisabled = true ; - } + this.userNameDisabled = true; + this.userPhoneDisabled = true; + this.userEmailDisabled = true ; + } editOtherContactType(){ this.otherContactType = true; diff --git a/PAMapp/pages/myAppointmentList.vue b/PAMapp/pages/myAppointmentList.vue index 646cede..aa776da 100644 --- a/PAMapp/pages/myAppointmentList.vue +++ b/PAMapp/pages/myAppointmentList.vue @@ -64,8 +64,6 @@ <script lang="ts"> import { Vue, Component, Watch, namespace } from 'nuxt-property-decorator'; -import * as _ from 'lodash'; - import appointmentService from '~/shared/services/appointment.service'; import { Appointment } from '~/shared/models/appointment.model'; import { ContactStatus } from '~/shared/models/enum/contact-status'; @@ -183,8 +181,8 @@ // format to {page}-banner or pam-no-banner tag private routeFormatBannerClass(route: string): string { - const needBannerTags = ['myAppointmentList-appointmentList', 'myAppointmentList-closedList']; - return _.includes(needBannerTags, route) ? route + '-banner' : 'pam-no-banner'; + const needBannerTags = ['myAppointmentList-appointmentList', 'myAppointmentList-closedList']; + return needBannerTags.includes(route) ? route + '-banner' : 'pam-no-banner'; }; } </script> diff --git a/PAMapp/pages/questionnaire/_agentNo.vue b/PAMapp/pages/questionnaire/_agentNo.vue index 9208efb..a2552b9 100644 --- a/PAMapp/pages/questionnaire/_agentNo.vue +++ b/PAMapp/pages/questionnaire/_agentNo.vue @@ -160,7 +160,6 @@ <script lang="ts"> import { Vue, Component, State, Action, Watch, namespace } from 'nuxt-property-decorator'; import { getRequestsFromStorage, removeRequestQuestionFromStorage, setRequestsToStorage } from '~/shared/storageRequests'; -import _ from 'lodash'; import accountSettingService from '~/shared/services/account-setting.service'; import appointmentService from '~/shared/services/appointment.service'; @@ -277,37 +276,37 @@ ]; quesAboutList = [ - { - title:'�摨瑁����', - content:'����澈擃憿批末嚗�靽�兢蝳�嚗��������嚗��飩������摮拙��粥銝��頝荔�犖����迤閬����' - }, - { - title:'摮戊��', - content:'摮拙���������葦銋摮貊��撠靘�蒂�雿嚗飛���������������瓷嚗��楝銝���韏瑕飛��' - }, - { - title:'鞈閬��', - content:'��迤��瓷撖��雓寡�����嚗鈭箇�����蝳西瓷��◢�����Ⅱ靽�蝛拙��嚗�摰嗆��靘�末��皞���' - }, - { - title:'璅暑��隡�', - content:'�銝�頛拙����隡��摮���翰瘣鳴�停敺�����������隡瓷����撌勗�帘摰�嚗蝎曉蔗���僑鈭箇�������' - }, - { - title:'靽�瑼�/閬��', - content:'��瑼Z�撌梁������蝚血����靘�◢�蝘餉��瘙��' - }, - { - title:'����', - content:'���������憸券�����鈭怒�����嚗���摰帘摰漲嚗��隞亙��澈��ˊ�靽���嚗�' - } + { + title:'�摨瑁����', + content:'����澈擃憿批末嚗�靽�兢蝳�嚗��������嚗��飩������摮拙��粥銝��頝荔�犖����迤閬����' + }, + { + title:'摮戊��', + content:'摮拙���������葦銋摮貊��撠靘�蒂�雿嚗飛���������������瓷嚗��楝銝���韏瑕飛��' + }, + { + title:'鞈閬��', + content:'��迤��瓷撖��雓寡�����嚗鈭箇�����蝳西瓷��◢�����Ⅱ靽�蝛拙��嚗�摰嗆��靘�末��皞���' + }, + { + title:'璅暑��隡�', + content:'�銝�頛拙����隡��摮���翰瘣鳴�停敺�����������隡瓷����撌勗�帘摰�嚗蝎曉蔗���僑鈭箇�������' + }, + { + title:'靽�瑼�/閬��', + content:'��瑼Z�撌梁������蝚血����靘�◢�蝘餉��瘙��' + }, + { + title:'����', + content:'���������憸券�����鈭怒�����嚗���摰帘摰漲嚗��隞亙��澈��ˊ�靽���嚗�' + } ]; myRequest: AppointmentRequests = { name : '', phone : '', email : '', - contactType : _.isEqual(this.userInfo?.contactType,ContactType.SMS) ? ContactType.PHONE: ContactType.EMAIL, + contactType : this.userInfo?.contactType === ContactType.SMS ? ContactType.PHONE: ContactType.EMAIL, gender : '', age : '', job : '', @@ -452,26 +451,21 @@ //////////////////////////////////////////////////////////////////////////// + async sentDemand() { - if (!this.isEditBtn) { + if (this.isEditBtn) { + await this.editAppointmentDemand(); + } else { // 雿輻 async/await 靘��甇交����蝯�� const addFavoriteAgentList = [{ agentNo: this.$route.params.agentNo, createdTime: new Date().toISOString() }]; const response = await queryConsultantService.addFavoriteConsultant(addFavoriteAgentList); // 蝣箔�甇交����蝯�� null ��� undefined - if (!response) { - throw new Error('queryConsultantService.addFavoriteConsultant returned null-like value.'); + if (response !== null) { + await this.sentAppointmentDemand(); } else { - if (typeof this.editAppointmentDemand === 'function') { - // 蝣箔�� this.editAppointmentDemand �銝��� - await this.editAppointmentDemand(); - } else { - // ���� this.editAppointmentDemand �摰儔����� - throw new Error('this.editAppointmentDemand is not defined or not a function.'); - } + throw new Error('queryConsultantService.addFavoriteConsultant returned null-like value.'); } - } else { - await this.editAppointmentDemand(); } const editSettingInfo: UserSetting = { @@ -484,10 +478,11 @@ this.storageUserInfo(this.userInfo); } + private editAppointmentDemand() { const info = { ...this.myRequest, - requirement: _.map(this.myRequest.requirement,o=>o).toString(), + requirement: this.myRequest.requirement.map(o => o).toString(), hopeContactTime: this.myRequest.phone && this.phoneValid ? this.getHopeContactTime() :'', id: this.appointmentId, otherRequirement: null @@ -502,7 +497,7 @@ private sentAppointmentDemand() { const data: AppointmentParams = { ...this.myRequest, - requirement: _.map(this.myRequest.requirement,o=>o).toString(), + requirement: this.myRequest.requirement.map(o => o).toString(), hopeContactTime: this.myRequest.phone && this.phoneValid ? this.getHopeContactTime() :'', agentNo: this.$route.params.agentNo }; @@ -543,7 +538,7 @@ get phoneValid(): boolean { const rule = /^09[0-9]{8}$/; return this.myRequest.phone - ? rule.test(this.myRequest.phone) && _.isEqual(this.myRequest.phone.length,10) + ? rule.test(this.myRequest.phone) && this.myRequest.phone.length === 10 : true; } @@ -558,9 +553,9 @@ } get isDisabledSubmitBtn(): boolean { - return _.includes(this.myRequest.contactType,ContactType.PHONE) - ? !this.isHopeContactTimeDone() || !this.emailValid - : !this.phoneValid; + return this.myRequest.contactType.includes(ContactType.PHONE) + ? !this.isHopeContactTimeDone() || !this.emailValid + : !this.phoneValid; } private isHopeContactTimeDone():boolean{ @@ -745,4 +740,3 @@ </style> - diff --git a/PAMapp/pages/quickFilter/index.vue b/PAMapp/pages/quickFilter/index.vue index 5ec1194..55a78e7 100644 --- a/PAMapp/pages/quickFilter/index.vue +++ b/PAMapp/pages/quickFilter/index.vue @@ -71,7 +71,6 @@ import { Seniority } from '~/shared/models/enum/seniority'; import { Vue, Component, namespace } from 'nuxt-property-decorator'; import queryConsultantService from '~/shared/services/query-consultant.service'; - import _ from 'lodash'; const localStorage = namespace('localStorage'); const seniorityMap={ diff --git a/PAMapp/shared/services/httpClient.ts b/PAMapp/shared/services/httpClient.ts index 08a5b6e..8fe7bad 100644 --- a/PAMapp/shared/services/httpClient.ts +++ b/PAMapp/shared/services/httpClient.ts @@ -1,6 +1,4 @@ -import { AxiosRequestConfig, AxiosError, AxiosResponse} from 'axios'; -import axios from 'axios'; -import _ from 'lodash'; +import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; import messageBoxService from './message-box.service'; @@ -86,11 +84,15 @@ messageBoxService.showErrorMessage('', error); return } - if (!_.includes(notRequireInterceptorErrorUrl, error.config.url)) { + if (!notRequireInterceptorErrorUrl.includes(error.config.url)) { switch (error.response.status) { case 401: Promise.all([messageBoxService.showErrorMessage('���暹��'), window.$nuxt.$store.dispatch('localStorage/actionStorageClear')]).then(() => { - _.isEqual(window.$nuxt.$route.name, 'index') ? location.reload() : window.$nuxt.$router.push('/'); + if (window.$nuxt.$route.name === 'index') { + location.reload(); + } else { + window.$nuxt.$router.push('/'); + } }); break; diff --git a/PAMapp/shared/services/login.service.ts b/PAMapp/shared/services/login.service.ts index eb61ccb..98ac692 100644 --- a/PAMapp/shared/services/login.service.ts +++ b/PAMapp/shared/services/login.service.ts @@ -1,8 +1,6 @@ -import { http } from "./httpClient"; import { AxiosResponse } from 'axios'; -import _ from "lodash"; -import CryptoJS from "crypto-js"; import forge from "node-forge"; +import { http } from "./httpClient"; // import CryptoJS from "asmcrypto-js"; import { ConsultantLoginInfo } from "../models/ConsultantLoginInfo"; @@ -73,8 +71,8 @@ return http.get('/login/validate/get_img_code',{ responseType : 'arraybuffer' }) .then( response => { const toBase64 = window.btoa( - _.reduce( new Uint8Array(response.data),(data,byte) => - data + String.fromCharCode(byte),'') + Array.from(new Uint8Array(response.data)).reduce((data, byte) => + data + String.fromCharCode(byte), '') ); const imgSrc = `data:image/jpeg;base64,${toBase64}`; return imgSrc; diff --git a/PAMapp/store/localStorage.service.ts b/PAMapp/store/localStorage.service.ts index 6ff4d9e..5470ad4 100644 --- a/PAMapp/store/localStorage.service.ts +++ b/PAMapp/store/localStorage.service.ts @@ -1,5 +1,4 @@ -import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators'; -import _ from 'lodash'; +import { Action, Module, Mutation, VuexModule } from 'vuex-module-decorators'; export enum LocalStorageItem { @@ -32,9 +31,9 @@ //** ���隞嗥���� **// private getInitLocalStorageDto(): storageDataDto { const initLocalStorageDto = {} as storageDataDto; - _.forEach( LocalStorageItem , keyName => - initLocalStorageDto[keyName] = this.processOfStorageGetItem(keyName) - ) + Object.values(LocalStorageItem).forEach(keyName => { + initLocalStorageDto[keyName] = this.processOfStorageGetItem(keyName); + }); return initLocalStorageDto; } //** ���� localStorage鞈�� **/ @@ -42,13 +41,12 @@ const storageData = localStorage.getItem(keyName); const itemType = initialValueOfStorageItemDto[keyName]; const prepareData = storageData - ? _.isEqual(itemType,String) + ? typeof itemType === 'string' ? storageData : JSON.parse(storageData) : null; return prepareData } - ///////////////////////////////////////////////// Mutation /** �摮�� localStorageDto **/ @@ -64,7 +62,7 @@ //** 蝘駁���隞� **// @Mutation clearStoreData(): void { - _.keys(this.localStorageDto) + Object.keys(this.localStorageDto) .forEach(keyName => { localStorage.removeItem(keyName); this.localStorageDto[keyName]=null; @@ -75,7 +73,7 @@ //** �隞嗅摮� **// @Action storeData( data: storageDataDto ): void { - _.keys(data).forEach(keyName=>{ + Object.keys(data).forEach(keyName=>{ const newObj = { keyName:keyName, value:data[keyName] @@ -87,7 +85,7 @@ //** 撠�閬� 摮�� localStorage �撘� **// @Action localStorageSet( setItem:SetItemDto ): void { const itemType = initialValueOfStorageItemDto[setItem.keyName]; - const prepareData = _.isEqual(itemType,String) + const prepareData = typeof itemType === 'string' ? setItem.value : JSON.stringify(setItem.value); localStorage.setItem(setItem.keyName,prepareData); -- Gitblit v1.8.0