mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 15:37:33 +08:00
migrate user profile page to composition API and typescript
This commit is contained in:
+1
-21
@@ -372,27 +372,7 @@ export const useRootStore = defineStore('root', () => {
|
||||
|
||||
function updateUserProfile({ profile, currentPassword }: { profile: User, currentPassword?: string }): Promise<UserProfileUpdateResponse> {
|
||||
return new Promise((resolve, reject) => {
|
||||
services.updateProfile({
|
||||
password: profile.password,
|
||||
oldPassword: currentPassword,
|
||||
email: profile.email,
|
||||
nickname: profile.nickname,
|
||||
defaultAccountId: profile.defaultAccountId,
|
||||
transactionEditScope: profile.transactionEditScope,
|
||||
language: profile.language,
|
||||
defaultCurrency: profile.defaultCurrency,
|
||||
firstDayOfWeek: profile.firstDayOfWeek,
|
||||
longDateFormat: profile.longDateFormat,
|
||||
shortDateFormat: profile.shortDateFormat,
|
||||
longTimeFormat: profile.longTimeFormat,
|
||||
shortTimeFormat: profile.shortTimeFormat,
|
||||
decimalSeparator: profile.decimalSeparator,
|
||||
digitGroupingSymbol: profile.digitGroupingSymbol,
|
||||
digitGrouping: profile.digitGrouping,
|
||||
currencyDisplayType: profile.currencyDisplayType,
|
||||
expenseAmountColor: profile.expenseAmountColor,
|
||||
incomeAmountColor: profile.incomeAmountColor
|
||||
}).then(response => {
|
||||
services.updateProfile(profile.toProfileUpdateRequest(currentPassword)).then(response => {
|
||||
const data = response.data;
|
||||
|
||||
if (!data || !data.success || !data.result) {
|
||||
|
||||
+12
-3
@@ -19,6 +19,7 @@ import type {
|
||||
|
||||
import {
|
||||
isObject,
|
||||
isString,
|
||||
isNumber
|
||||
} from '@/lib/common.ts';
|
||||
|
||||
@@ -289,12 +290,20 @@ export const useUserStore = defineStore('user', () => {
|
||||
});
|
||||
}
|
||||
|
||||
function getUserAvatarUrl(userInfo: UserBasicInfo, disableBrowserCache: boolean | string): string | null {
|
||||
if (!userInfo || !userInfo.avatar) {
|
||||
function getUserAvatarUrl(userInfoOrAvatarUrl: UserBasicInfo | string, disableBrowserCache: boolean | string): string | null {
|
||||
let avatarUrl = '';
|
||||
|
||||
if (isObject(userInfoOrAvatarUrl)) {
|
||||
avatarUrl = userInfoOrAvatarUrl.avatar;
|
||||
} else if (isString(userInfoOrAvatarUrl)) {
|
||||
avatarUrl = userInfoOrAvatarUrl;
|
||||
}
|
||||
|
||||
if (!avatarUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return services.getInternalAvatarUrlWithToken(userInfo.avatar, disableBrowserCache);
|
||||
return services.getInternalAvatarUrlWithToken(avatarUrl, disableBrowserCache);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user