-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adjust sign-in page login flow (#93)
- Loading branch information
1 parent
e25ee2f
commit c420a58
Showing
2 changed files
with
25 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
import { getRedirectionStorage } from './storage'; | ||
|
||
export default function openLoginWindow( | ||
redirection = '/', | ||
redirection = '', | ||
target = '/login/popup', | ||
) { | ||
const width = 520; | ||
const height = 760; | ||
const left = (window.innerWidth - width) / 2; | ||
const top = (window.innerHeight - height) / 2; | ||
const left = (window.screen.width - width) / 2; | ||
const top = (window.screen.height - height) / 2; | ||
const features = `left=${left},top=${top},width=${width},height=${height}`; | ||
const loginWindow = window.open('', '_blank', features); | ||
getRedirectionStorage().set(redirection); | ||
if (redirection) getRedirectionStorage().set(redirection); | ||
if (loginWindow) loginWindow.location = target; | ||
|
||
return new Promise((resolve) => { | ||
const loop = setInterval(() => { | ||
if (loginWindow.closed) { | ||
clearInterval(loop); | ||
resolve(); | ||
} | ||
}, 500); | ||
}); | ||
} |