page.tsx
1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use client'
import { useEffect, useState } from 'react'
import { useSearchParams } from 'next/navigation'
import Loading from '@/app/components/base/loading'
export default function SettingPage() {
const searchParams = useSearchParams()
const [url, setUrl] = useState('')
const [loading, setLoading] = useState(true)
useEffect(() => {
const settingUrl = searchParams.get('settingUrl')
const sessionId = searchParams.get('sessionId')
const corpId = searchParams.get('corpId')
if (settingUrl) {
let fullUrl = decodeURIComponent(settingUrl)
if (sessionId || corpId) {
const separator = fullUrl.includes('?') ? '&' : '?'
const params = []
if (sessionId) params.push(`sessionId=${sessionId}`)
if (corpId) params.push(`corpId=${corpId}`)
fullUrl = `${fullUrl}${separator}${params.join('&')}`
}
setUrl(fullUrl)
setLoading(false)
} else {
setLoading(false)
}
}, [searchParams])
if (loading) {
return (
<div className="flex h-screen w-full items-center justify-center">
<Loading type="app" />
</div>
)
}
if (!url) {
return (
<div className="flex h-screen w-full items-center justify-center">
<div className="text-text-secondary">无效的请求</div>
</div>
)
}
return (
<div className="h-screen w-full">
<iframe
src={url}
className="h-full w-full border-0"
title="设置页面"
sandbox="allow-same-origin allow-scripts allow-forms allow-popups"
/>
</div>
)
}