更新模板
This commit is contained in:
@@ -44,16 +44,21 @@ export class User {
|
||||
*/
|
||||
async get() {
|
||||
if (this.token != null) {
|
||||
// 如果是模拟token,则跳过远程获取,防止由于后端校验失败导致的自动退出登录
|
||||
if (this.token.startsWith("fake-")) {
|
||||
return;
|
||||
}
|
||||
|
||||
await request({
|
||||
url: "/app/user/info/person"
|
||||
url: "/api/nongchuang/user/info"
|
||||
})
|
||||
.then((res) => {
|
||||
if (res != null) {
|
||||
this.set(res);
|
||||
this.set(res.userInfo || res); // Adapt to the map structure { userInfo: ..., stats: ... } or flat
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// this.logout();
|
||||
this.logout();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -90,8 +95,8 @@ export class User {
|
||||
|
||||
// 同步到服务端
|
||||
await request({
|
||||
url: "/app/user/info/updatePerson",
|
||||
method: "POST",
|
||||
url: "/api/nongchuang/user/info",
|
||||
method: "PUT",
|
||||
data
|
||||
});
|
||||
}
|
||||
@@ -128,7 +133,8 @@ export class User {
|
||||
*/
|
||||
logout() {
|
||||
this.clear();
|
||||
router.login();
|
||||
// 移除自动跳转,仅清除已过期的登录态,由页面自行决定是否引导登录
|
||||
// router.login();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,9 +157,9 @@ export class User {
|
||||
refreshToken(): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request({
|
||||
url: "/app/user/login/refreshToken",
|
||||
url: "/api/nongchuang/auth/refresh-token",
|
||||
method: "POST",
|
||||
data: {
|
||||
params: {
|
||||
refreshToken: storage.get("refreshToken")
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user