Skip to content

Commit

Permalink
fix: to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Feb 6, 2024
1 parent ef95da1 commit 88f4523
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions src/app/(dashboard)/dashboard/vue/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@
import { useLayoutEffect } from 'react'
import { useRouter } from 'next/navigation'

import { useResolveAdminUrl } from '~/atoms'
import { fetchAppUrl, useResolveAdminUrl } from '~/atoms'
import { FullPageLoading } from '~/components/ui/loading'

export default function Page() {
const toAdminUrl = useResolveAdminUrl()
const router = useRouter()

useLayoutEffect(() => {
window.open(toAdminUrl(), '_blank')
router.back()
const adminUrl = toAdminUrl()

if (adminUrl) {
location.href = adminUrl
} else {
fetchAppUrl().then((urls) => {
if (urls.adminUrl) {
location.href = urls.adminUrl
}
})
}
}, [router, toAdminUrl])
return null
return <FullPageLoading />
}
2 changes: 1 addition & 1 deletion src/atoms/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const fetchAppUrl = async () => {

if (data.adminUrl) jotaiStore.set(adminUrlAtom, data.adminUrl)
jotaiStore.set(webUrlAtom, data.webUrl)
return data
}

export const getWebUrl = () => jotaiStore.get(webUrlAtom)
Expand Down Expand Up @@ -54,7 +55,6 @@ export const useResolveAdminUrl = () => {
parsedUrl.searchParams.set('token', token)
}

console.log('parsedUrl', parsedUrl)
return `${parsedUrl.protocol}//${parsedUrl.host}${parsedUrl.pathname}${
path || ''
}${parsedUrl.search}`
Expand Down

0 comments on commit 88f4523

Please sign in to comment.