forked from aboutmydreams/aiis.read
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from BuidlerDAO/nig-672-binmax
feat: 调整 store 处理 token 的位置
- Loading branch information
Showing
13 changed files
with
104 additions
and
102 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
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
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,25 +1,49 @@ | ||
/** | ||
* @file 全局状态,自动同步到 storage | ||
*/ | ||
import { create } from 'zustand'; | ||
import { persist } from 'zustand/middleware'; | ||
|
||
interface GlobalStoreProps { | ||
export enum PageType { | ||
Login = 'login', | ||
Invite = 'invite', | ||
Congratulation = 'congratulation', | ||
Profile = 'profile', | ||
Wallet = 'wallet', | ||
} | ||
|
||
export interface GlobalStoreProps { | ||
page: PageType; | ||
token: string; | ||
message: string; | ||
messageType: string; | ||
messageOpen: boolean; | ||
closeMessage: () => void; | ||
isShowPrice: boolean; | ||
isShowDrawer: boolean; | ||
userInfo: UserInfo | null; | ||
goPage(page: PageType): void; | ||
logout(): void; | ||
} | ||
|
||
const useGlobalStore = create<GlobalStoreProps>((set) => ({ | ||
token: '', | ||
message: '', | ||
messageType: '', | ||
messageOpen: false, | ||
closeMessage() { | ||
set({ | ||
messageOpen: false, | ||
message: '', | ||
messageType: '', | ||
}); | ||
}, | ||
})); | ||
const useGlobalStore = create<GlobalStoreProps>()( | ||
persist( | ||
(set) => ({ | ||
page: PageType.Login, | ||
token: '', | ||
isShowPrice: false, | ||
isShowDrawer: false, | ||
userInfo: null, | ||
goPage(page: PageType) { | ||
set({ page }); | ||
}, | ||
logout() { | ||
set({ | ||
token: '', | ||
page: PageType.Login, | ||
}); | ||
}, | ||
}), | ||
{ | ||
name: 'xfans-user-config', | ||
} | ||
) | ||
); | ||
|
||
export default useGlobalStore; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { create } from 'zustand'; | ||
|
||
interface ToasterStoreProps { | ||
message: string; | ||
messageType: string; | ||
messageOpen: boolean; | ||
closeMessage: () => void; | ||
} | ||
|
||
const useToasterStore = create<ToasterStoreProps>((set) => ({ | ||
message: '', | ||
messageType: '', | ||
messageOpen: false, | ||
closeMessage() { | ||
set({ | ||
messageOpen: false, | ||
message: '', | ||
messageType: '', | ||
}); | ||
}, | ||
})); | ||
|
||
export default useToasterStore; |
Oops, something went wrong.