mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-08 07:28:37 +08:00
1
This commit is contained in:
@@ -523,6 +523,7 @@ const styles = StyleSheet.create({
|
|||||||
searchBar: {
|
searchBar: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
height: 30,
|
height: 30,
|
||||||
|
marginLeft: 8,
|
||||||
backgroundColor: "#f0f0f0",
|
backgroundColor: "#f0f0f0",
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
|
|||||||
@@ -25,19 +25,16 @@ export const useAuthStore = create<AuthState>((set) => ({
|
|||||||
login: async (sessdata, uid, username) => {
|
login: async (sessdata, uid, username) => {
|
||||||
await setSecure('SESSDATA', sessdata);
|
await setSecure('SESSDATA', sessdata);
|
||||||
// Migrate: remove SESSDATA from AsyncStorage if it was there before
|
// Migrate: remove SESSDATA from AsyncStorage if it was there before
|
||||||
await AsyncStorage.removeItem('SESSDATA').catch(() => {});
|
await AsyncStorage.removeItem('SESSDATA').catch(() => { });
|
||||||
set({ sessdata, uid: uid || null, username: username || null, isLoggedIn: true });
|
set({ sessdata, uid: uid || null, username: username || null, isLoggedIn: true });
|
||||||
// 延迟 1s 后台拉取头像,避免与登录后立即触发的其他请求(如 getFollowedLiveRooms)并发
|
|
||||||
setTimeout(() => {
|
|
||||||
getUserInfo().then(async (info) => {
|
getUserInfo().then(async (info) => {
|
||||||
await AsyncStorage.multiSet([
|
await AsyncStorage.multiSet([
|
||||||
['UID', String(info.mid)],
|
['UID', String(info.mid)],
|
||||||
['USERNAME', info.uname],
|
['USERNAME', info.uname],
|
||||||
['FACE', info.face],
|
['FACE', info.face],
|
||||||
]).catch(() => {});
|
]).catch(() => { });
|
||||||
set({ face: info.face, username: info.uname, uid: String(info.mid) });
|
set({ face: info.face, username: info.uname, uid: String(info.mid) });
|
||||||
}).catch(() => {});
|
}).catch(() => { });
|
||||||
}, 1000);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
logout: async () => {
|
logout: async () => {
|
||||||
@@ -63,7 +60,7 @@ export const useAuthStore = create<AuthState>((set) => ({
|
|||||||
const info = await getUserInfo();
|
const info = await getUserInfo();
|
||||||
await AsyncStorage.setItem('FACE', info.face);
|
await AsyncStorage.setItem('FACE', info.face);
|
||||||
set({ face: info.face, username: info.uname, uid: String(info.mid) });
|
set({ face: info.face, username: info.uname, uid: String(info.mid) });
|
||||||
} catch {}
|
} catch { }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user