supports local file system object storage and use it as the default avatar provider

This commit is contained in:
MaysWind
2024-07-27 23:29:18 +08:00
parent 731b6e8bad
commit 2e04affb00
26 changed files with 858 additions and 29 deletions
+32
View File
@@ -2,12 +2,14 @@ import axios from 'axios';
import apiConstants from '@/consts/api.js';
import userState from './userstate.js';
import { isBoolean } from './common.js';
import {
getGoogleMapAPIKey,
getBaiduMapAK,
getAmapApplicationKey
} from './server_settings.js';
import { getTimezoneOffsetMinutes } from './datetime.js';
import { generateRandomUUID } from './misc.js';
let needBlockRequest = false;
let blockedRequests = [];
@@ -192,6 +194,14 @@ export default {
incomeAmountColor
});
},
updateAvatar: ({ avatarFile }) => {
return axios.postForm('v1/users/avatar/update.json', {
avatar: avatarFile
});
},
removeAvatar: () => {
return axios.post('v1/users/avatar/remove.json');
},
resendVerifyEmailByLoginedUser: () => {
return axios.post('v1/users/verify_email/resend.json');
},
@@ -552,5 +562,27 @@ export default {
},
generateAmapApiInternalProxyUrl: () => {
return `${window.location.origin}${apiConstants.baseAmapApiProxyUrlPath}`;
},
getInternalAvatarUrlWithToken(avatarUrl, disableBrowserCache) {
if (!avatarUrl) {
return avatarUrl;
}
const params = [];
params.push('token=' + userState.getToken());
if (disableBrowserCache) {
if (isBoolean(disableBrowserCache)) {
params.push('_nocache=' + generateRandomUUID());
} else {
params.push('_nocache=' + disableBrowserCache);
}
}
if (avatarUrl.indexOf('?') >= 0) {
return avatarUrl + '&' + params.join('&');
} else {
return avatarUrl + '?' + params.join('&');
}
}
};