✨ Channel manage
This commit is contained in:
@@ -9,6 +9,7 @@ export interface Userinfo {
|
||||
isReady: boolean
|
||||
isLoggedIn: boolean
|
||||
displayName: string
|
||||
idSet: { [id: string]: number }
|
||||
data: any
|
||||
}
|
||||
|
||||
@@ -16,6 +17,7 @@ const defaultUserinfo: Userinfo = {
|
||||
isReady: false,
|
||||
isLoggedIn: false,
|
||||
displayName: "Citizen",
|
||||
idSet: {},
|
||||
data: null
|
||||
}
|
||||
|
||||
@@ -47,17 +49,29 @@ export const useUserinfo = defineStore("userinfo", () => {
|
||||
const res = await request("identity", "/api/users/me", {
|
||||
headers: { Authorization: `Bearer ${await getAtk()}` }
|
||||
})
|
||||
|
||||
if (res.status !== 200) {
|
||||
return
|
||||
}
|
||||
|
||||
const data = await res.json()
|
||||
|
||||
const federationResp = await Promise.all([
|
||||
request("interactive", "/api/users/me", {
|
||||
headers: { Authorization: `Bearer ${await getAtk()}` }
|
||||
}),
|
||||
request("messaging", "/api/users/me", {
|
||||
headers: { Authorization: `Bearer ${await getAtk()}` }
|
||||
})
|
||||
])
|
||||
|
||||
userinfo.value = {
|
||||
isReady: true,
|
||||
isLoggedIn: true,
|
||||
displayName: data["nick"],
|
||||
idSet: {
|
||||
interactive: (await federationResp[0].json())["id"],
|
||||
messaging: (await federationResp[1].json())["id"]
|
||||
},
|
||||
data: data
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user