-
Notifications
You must be signed in to change notification settings - Fork 31
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 #102 from nini22P/dev
v1.7.3
- Loading branch information
Showing
28 changed files
with
410 additions
and
236 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,33 +1,28 @@ | ||
import { useMsal } from '@azure/msal-react' | ||
import { loginRequest } from '@/graph/authConfig' | ||
import usePlayQueueStore from '@/store/usePlayQueueStore' | ||
import useUiStore from '@/store/useUiStore' | ||
import { AccountInfo } from '@azure/msal-browser' | ||
|
||
const useUser = () => { | ||
const { instance, accounts } = useMsal() | ||
const currentAccount = useUiStore(state => state.currentAccount) | ||
|
||
const account: AccountInfo | null = accounts[currentAccount] || null | ||
|
||
// 登入 | ||
const login = () => { | ||
instance.loginRedirect(loginRequest) | ||
.catch(e => { | ||
console.log(e) | ||
}) | ||
} | ||
|
||
//登出 | ||
const logout = () => { | ||
usePlayQueueStore.persist.clearStorage() | ||
useUiStore.persist.clearStorage() | ||
const logout = (account: AccountInfo) => { | ||
instance.logoutRedirect({ | ||
account: account, | ||
postLogoutRedirectUri: '/', | ||
}) | ||
location.reload() | ||
} | ||
|
||
const account: AccountInfo | null = accounts[0] || null | ||
|
||
return { account, login, logout } | ||
return { accounts, account, login, logout } | ||
} | ||
|
||
export default useUser |
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
Oops, something went wrong.