feat: added avatar tailoring and uploading

Signed-off-by: Kininaru <shiftregister233@outlook.com>

fixed type errors

Signed-off-by: Kininaru <shiftregister233@outlook.com>

fixed the wrong folder

Signed-off-by: Kininaru <shiftregister233@outlook.com>

rewrite login check logic, added unix time to avatar url

Signed-off-by: Kininaru <shiftregister233@outlook.com>

fixed a bug about strconv

Signed-off-by: Kininaru <shiftregister233@outlook.com>

supported oss

Signed-off-by: Kininaru <shiftregister233@outlook.com>

disabled oss provide qiniu

Signed-off-by: Kininaru <shiftregister233@outlook.com>

Fixed avatar url error

Signed-off-by: Kininaru <shiftregister233@outlook.com>

Fixed avatar length bug

Signed-off-by: Kininaru <shiftregister233@outlook.com>

Fixed avatar length bug

Signed-off-by: Kininaru <shiftregister233@outlook.com>

fixed oss.conf

Signed-off-by: Kininaru <shiftregister233@outlook.com>

Put uploading avatar into UserEditPage

Signed-off-by: Kininaru <shiftregister233@outlook.com>

removed avatar dir

Signed-off-by: Kininaru <shiftregister233@outlook.com>

removed avatar in main.go

Signed-off-by: Kininaru <shiftregister233@outlook.com>

Made CropperDiv a reusable component, and updated README for OSS config

Signed-off-by: Kininaru <shiftregister233@outlook.com>

Convert ts to js

Signed-off-by: Kininaru <shiftregister233@outlook.com>

removed ts

Signed-off-by: Kininaru <shiftregister233@outlook.com>

fix: set avatar link to string 255

Signed-off-by: Kininaru <shiftregister233@outlook.com>

fix: updated yarn lock

Signed-off-by: Kininaru <shiftregister233@outlook.com>

add: Casbin license

Signed-off-by: Kininaru <shiftregister233@outlook.com>
This commit is contained in:
Kininaru
2021-03-14 15:50:36 +08:00
parent 202a94a8e5
commit 1908f528c8
17 changed files with 420 additions and 8 deletions

View File

@ -13,6 +13,7 @@
// limitations under the License.
import * as Setting from "../Setting";
import * as AuthBackend from "../auth/AuthBackend";
export function getGlobalUsers() {
return fetch(`${Setting.ServerUrl}/api/get-global-users`, {
@ -61,3 +62,20 @@ export function deleteUser(user) {
body: JSON.stringify(newUser),
}).then(res => res.json());
}
export function uploadAvatar(avatar) {
let account;
AuthBackend.getAccount().then((res) => {
account = Setting.parseJson(res.data);
let formData = new FormData();
formData.append("avatarfile", avatar);
formData.append("password", account.password);
fetch(`${Setting.ServerUrl}/api/upload-avatar`, {
body: formData,
method: 'POST',
credentials: 'include',
}).then((res) => {
window.location.href = "/account";
});
});
}