Login & Register

This commit is contained in:
Limo Saplf
2019-09-01 21:56:21 +08:00
parent d9a8408535
commit 4480fc8e19
12 changed files with 231 additions and 23 deletions

View File

@@ -14,6 +14,11 @@ export async function getAreaCodes(): Promise<AreaCodes> {
const res = await http.get<AreaCodes>('/sign/code');
if (res.ok && res.data) {
res.data = res.data.map((it: any) => ({
id: it.id || it.pode,
areacode: it.areacode || it.itc.match(/\d+/)[0],
areaname: it.areaname || it.name_native || it.name_en,
}));
storeAreaCode(res.data);
return res.data;
}
@@ -24,7 +29,7 @@ export async function getAreaCodes(): Promise<AreaCodes> {
export async function getUserInfo(refresh = false): Promise<User> {
if (!refresh) {
const userCache = loadUser() as User;
if (userCache) {
if (userCache && userCache.id) {
return userCache;
}
}