mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 06:57:35 +08:00
code refactor
This commit is contained in:
+6
-6
@@ -43,7 +43,7 @@ export const useRootStore = defineStore('root', {
|
||||
|
||||
if (resetUserInfoAndSettings) {
|
||||
const userStore = useUserStore();
|
||||
userStore.resetUserInfo();
|
||||
userStore.resetUserBasicInfo();
|
||||
}
|
||||
},
|
||||
authorize({ loginName, password }) {
|
||||
@@ -81,7 +81,7 @@ export const useRootStore = defineStore('root', {
|
||||
|
||||
if (data.result.user && isObject(data.result.user)) {
|
||||
const userStore = useUserStore();
|
||||
userStore.storeUserInfo(data.result.user);
|
||||
userStore.storeUserBasicInfo(data.result.user);
|
||||
}
|
||||
|
||||
resolve(data.result);
|
||||
@@ -142,7 +142,7 @@ export const useRootStore = defineStore('root', {
|
||||
|
||||
if (data.result.user && isObject(data.result.user)) {
|
||||
const userStore = useUserStore();
|
||||
userStore.storeUserInfo(data.result.user);
|
||||
userStore.storeUserBasicInfo(data.result.user);
|
||||
}
|
||||
|
||||
resolve(data.result);
|
||||
@@ -192,7 +192,7 @@ export const useRootStore = defineStore('root', {
|
||||
|
||||
if (data.result.user && isObject(data.result.user)) {
|
||||
const userStore = useUserStore();
|
||||
userStore.storeUserInfo(data.result.user);
|
||||
userStore.storeUserBasicInfo(data.result.user);
|
||||
}
|
||||
|
||||
resolve(data.result);
|
||||
@@ -267,7 +267,7 @@ export const useRootStore = defineStore('root', {
|
||||
|
||||
if (data.result.user && isObject(data.result.user)) {
|
||||
const userStore = useUserStore();
|
||||
userStore.storeUserInfo(data.result.user);
|
||||
userStore.storeUserBasicInfo(data.result.user);
|
||||
}
|
||||
|
||||
resolve(data.result);
|
||||
@@ -401,7 +401,7 @@ export const useRootStore = defineStore('root', {
|
||||
|
||||
if (data.result.user && isObject(data.result.user)) {
|
||||
const userStore = useUserStore();
|
||||
userStore.storeUserInfo(data.result.user);
|
||||
userStore.storeUserBasicInfo(data.result.user);
|
||||
}
|
||||
|
||||
const accountsStore = useAccountsStore();
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ export const useTokensStore = defineStore('tokens', {
|
||||
|
||||
if (data && data.success && data.result && data.result.user && isObject(data.result.user)) {
|
||||
const userStore = useUserStore();
|
||||
userStore.storeUserInfo(data.result.user);
|
||||
userStore.storeUserBasicInfo(data.result.user);
|
||||
}
|
||||
|
||||
if (data && data.success && data.result && data.result.newToken) {
|
||||
|
||||
+21
-21
@@ -9,73 +9,73 @@ import { isNumber } from '@/lib/common.js';
|
||||
|
||||
export const useUserStore = defineStore('user', {
|
||||
state: () => ({
|
||||
currentUserInfo: userState.getUserInfo()
|
||||
currentUserBasicInfo: userState.getUserInfo()
|
||||
}),
|
||||
getters: {
|
||||
currentUserNickname(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.nickname || userInfo.username || null;
|
||||
},
|
||||
currentUserAvatar(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.avatar || null;
|
||||
},
|
||||
currentUserDefaultAccountId(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.defaultAccountId || '';
|
||||
},
|
||||
currentUserLanguage(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.language;
|
||||
},
|
||||
currentUserDefaultCurrency(state) {
|
||||
const settingsStore = useSettingsStore();
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.defaultCurrency || settingsStore.localeDefaultSettings.currency;
|
||||
},
|
||||
currentUserFirstDayOfWeek(state) {
|
||||
const settingsStore = useSettingsStore();
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return isNumber(userInfo.firstDayOfWeek) ? userInfo.firstDayOfWeek : settingsStore.localeDefaultSettings.firstDayOfWeek;
|
||||
},
|
||||
currentUserLongDateFormat(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.longDateFormat;
|
||||
},
|
||||
currentUserShortDateFormat(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.shortDateFormat;
|
||||
},
|
||||
currentUserLongTimeFormat(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.longTimeFormat;
|
||||
},
|
||||
currentUserShortTimeFormat(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.shortTimeFormat;
|
||||
},
|
||||
currentUserDecimalSeparator(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.decimalSeparator;
|
||||
},
|
||||
currentUserDigitGroupingSymbol(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.digitGroupingSymbol;
|
||||
},
|
||||
currentUserDigitGrouping(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.digitGrouping;
|
||||
},
|
||||
currentUserCurrencyDisplayType(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.currencyDisplayType;
|
||||
},
|
||||
currentUserExpenseAmountColor(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.expenseAmountColor;
|
||||
},
|
||||
currentUserIncomeAmountColor(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
const userInfo = state.currentUserBasicInfo || {};
|
||||
return userInfo.incomeAmountColor;
|
||||
}
|
||||
},
|
||||
@@ -94,12 +94,12 @@ export const useUserStore = defineStore('user', {
|
||||
firstDayOfWeek: settingsStore.localeDefaultSettings.firstDayOfWeek,
|
||||
};
|
||||
},
|
||||
storeUserInfo(userInfo) {
|
||||
this.currentUserInfo = userInfo;
|
||||
storeUserBasicInfo(userInfo) {
|
||||
this.currentUserBasicInfo = userInfo;
|
||||
userState.updateUserInfo(userInfo);
|
||||
},
|
||||
resetUserInfo() {
|
||||
this.currentUserInfo = null;
|
||||
resetUserBasicInfo() {
|
||||
this.currentUserBasicInfo = null;
|
||||
userState.clearUserInfo();
|
||||
},
|
||||
getCurrentUserProfile() {
|
||||
|
||||
@@ -175,7 +175,7 @@ export default {
|
||||
self.verifyingByWebAuthn = true;
|
||||
|
||||
webauthn.verifyCredential(
|
||||
self.userStore.currentUserInfo,
|
||||
self.userStore.currentUserBasicInfo,
|
||||
self.$user.getWebAuthnCredentialId()
|
||||
).then(({ id, userName, userSecret }) => {
|
||||
self.verifyingByWebAuthn = false;
|
||||
@@ -217,7 +217,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = self.userStore.currentUserInfo;
|
||||
const user = self.userStore.currentUserBasicInfo;
|
||||
|
||||
if (!user || !user.username) {
|
||||
self.$refs.snackbar.showMessage('An error occurred');
|
||||
|
||||
@@ -107,7 +107,7 @@ export default {
|
||||
|
||||
webauthn.registerCredential(
|
||||
self.$user.getUserAppLockState(),
|
||||
self.userStore.currentUserInfo,
|
||||
self.userStore.currentUserBasicInfo,
|
||||
).then(({ id }) => {
|
||||
self.enablingWebAuthn = false;
|
||||
|
||||
@@ -158,7 +158,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = this.userStore.currentUserInfo;
|
||||
const user = this.userStore.currentUserBasicInfo;
|
||||
|
||||
if (!user || !user.username) {
|
||||
this.pinCode = '';
|
||||
|
||||
@@ -81,7 +81,7 @@ export default {
|
||||
|
||||
webauthn.registerCredential(
|
||||
self.$user.getUserAppLockState(),
|
||||
self.userStore.currentUserInfo,
|
||||
self.userStore.currentUserBasicInfo,
|
||||
).then(({ id }) => {
|
||||
self.$hideLoading();
|
||||
|
||||
@@ -136,7 +136,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = this.userStore.currentUserInfo;
|
||||
const user = this.userStore.currentUserBasicInfo;
|
||||
|
||||
if (!user || !user.username) {
|
||||
this.$alert('An error occurred');
|
||||
|
||||
@@ -128,7 +128,7 @@ export default {
|
||||
self.$showLoading();
|
||||
|
||||
webauthn.verifyCredential(
|
||||
self.userStore.currentUserInfo,
|
||||
self.userStore.currentUserBasicInfo,
|
||||
self.$user.getWebAuthnCredentialId()
|
||||
).then(({ id, userName, userSecret }) => {
|
||||
self.$hideLoading();
|
||||
@@ -175,7 +175,7 @@ export default {
|
||||
}
|
||||
|
||||
const router = self.f7router;
|
||||
const user = self.userStore.currentUserInfo;
|
||||
const user = self.userStore.currentUserBasicInfo;
|
||||
|
||||
if (!user || !user.username) {
|
||||
self.$alert('An error occurred');
|
||||
|
||||
Reference in New Issue
Block a user