-
Notifications
You must be signed in to change notification settings - Fork 726
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34e943e
commit efa5518
Showing
8 changed files
with
94 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
import type { SetupUserApiResponse, UserApiResponse } from "~/types"; | ||
import type { SetupUserApiResponse, User, UserApiResponse } from "~/types"; | ||
import { fetchUserInfo } from "~/services/auth"; | ||
import { http } from "./http"; | ||
|
||
export async function fetchSetupNewUser(data: { username: string; avatar: string }) { | ||
return await http.post<SetupUserApiResponse, SetupUserApiResponse>("/user/setup", data); | ||
} | ||
|
||
export async function fetchCurrentUser() { | ||
return await http.get<UserApiResponse, UserApiResponse>("/user"); | ||
// 这里必须在 client 获取 user info | ||
// 他会触发 token 的刷新 | ||
const logtoUserInfo = await fetchUserInfo(); | ||
const extraInfo = await http.get<UserApiResponse, UserApiResponse>("/user"); | ||
|
||
return { | ||
...logtoUserInfo, | ||
...extraInfo, | ||
avatar: logtoUserInfo!.picture || "", // 添加 avatar 字段,默认值为 picture ( picture 这个属性不够清晰 不喜欢) | ||
} as User; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import { type UserInfoResponse } from "@logto/vue"; | ||
|
||
import { type UserApiResponse } from "../api/user"; | ||
|
||
export interface User extends UserApiResponse {} | ||
export type User = UserInfoResponse & | ||
UserApiResponse & { | ||
avatar: string; | ||
}; |