@@ -16,7 +16,7 @@ type SID = {
16
16
17
17
export default function WebView ( ) {
18
18
const { i18n } = useTranslation ( )
19
- const { pathname } = useLocation ( )
19
+ const { pathname, search } = useLocation ( )
20
20
const { t } = useTranslation ( )
21
21
const { handleFilter, handleCategory } = useContext ( ContextProvider )
22
22
const [ loading , setLoading ] = useState < {
@@ -34,7 +34,7 @@ export default function WebView() {
34
34
lang = 'pt-BR'
35
35
}
36
36
37
- const loginUrl =
37
+ const epicLoginUrl =
38
38
'https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Fapi%2Fredirect'
39
39
const epicStore = `https://www.epicgames.com/store/${ lang } /`
40
40
const gogStore = `https://gog.com`
@@ -46,17 +46,24 @@ export default function WebView() {
46
46
47
47
const trueAsStr = 'true' as unknown as boolean | undefined
48
48
const { runner } = useParams ( ) as { runner : Runner }
49
- const startUrl = runner
50
- ? runner == 'legendary'
51
- ? '/loginEpic'
52
- : '/loginGOG'
53
- : pathname
49
+
54
50
const urls = {
55
51
'/epicstore' : epicStore ,
56
52
'/gogstore' : gogStore ,
57
53
'/wiki' : wikiURL ,
58
- '/loginEpic' : loginUrl ,
59
- '/loginGOG' : gogLoginUrl
54
+ '/loginEpic' : epicLoginUrl ,
55
+ '/loginGOG' : gogLoginUrl ,
56
+ '/login/legandary' : epicLoginUrl ,
57
+ '/login/gog' : gogLoginUrl
58
+ }
59
+ let startUrl = urls [ pathname ]
60
+
61
+ if ( pathname . match ( / s t o r e - p a g e / ) ) {
62
+ const searchParams = new URLSearchParams ( search )
63
+ const queryParam = searchParams . get ( 'store-url' )
64
+ if ( queryParam ) {
65
+ startUrl = queryParam
66
+ }
60
67
}
61
68
62
69
useLayoutEffect ( ( ) => {
@@ -131,15 +138,15 @@ export default function WebView() {
131
138
< div className = "WebView" >
132
139
< WebviewControls
133
140
webview = { webviewRef . current }
134
- initURL = { urls [ startUrl ] }
141
+ initURL = { startUrl }
135
142
openInBrowser = { ! startUrl . startsWith ( '/login' ) }
136
143
/>
137
144
{ loading . refresh && < UpdateComponent message = { loading . message } /> }
138
145
< webview
139
146
ref = { webviewRef }
140
147
className = "WebView__webview"
141
148
partition = "persist:epicstore"
142
- src = { urls [ startUrl ] }
149
+ src = { startUrl }
143
150
allowpopups = { trueAsStr }
144
151
/>
145
152
</ div >
0 commit comments