This commit is contained in:
parent
5e0bc6116d
commit
40a6f6ae7b
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 9.3 KiB |
11
src/App.tsx
11
src/App.tsx
|
|
@ -7,20 +7,25 @@ import Twins from './pages/Twins.tsx'
|
||||||
import PlaceholderPage from './components/PlaceholderPage.tsx'
|
import PlaceholderPage from './components/PlaceholderPage.tsx'
|
||||||
|
|
||||||
// http://localhost:5173?token=c3f52a99-c519-427a-af05-364c5f3e59cc
|
// http://localhost:5173?token=c3f52a99-c519-427a-af05-364c5f3e59cc
|
||||||
|
// ?package=com.btys.btwx
|
||||||
function App() {
|
function App() {
|
||||||
const [isConfigReady, setIsConfigReady] = useState(false)
|
const [isConfigReady, setIsConfigReady] = useState(false)
|
||||||
const [searchParams] = useSearchParams()
|
const [searchParams] = useSearchParams()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [initialToken] = useState(() => searchParams.get('token'))
|
const [initialToken] = useState(() => searchParams.get('token'))
|
||||||
|
const [initialPackage] = useState(() => searchParams.get('package'))
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let isMounted = true
|
let isMounted = true
|
||||||
|
|
||||||
async function initConfig() {
|
async function initConfig() {
|
||||||
|
if(initialPackage) {
|
||||||
|
window.localStorage.setItem('package', initialPackage || '')
|
||||||
|
}
|
||||||
if (initialToken) {
|
if (initialToken) {
|
||||||
window.localStorage.setItem('token', initialToken || '')
|
window.localStorage.setItem('token', initialToken || '')
|
||||||
} else if(!window.localStorage.getItem('token')) {
|
} else if(!window.localStorage.getItem('token')) {
|
||||||
navigate('/404', { replace: true })
|
navigate('/twins', { replace: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMounted) {
|
if (isMounted) {
|
||||||
|
|
@ -41,7 +46,7 @@ function App() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Navigate to="/pay" replace />} />
|
<Route path="/" element={<Navigate to="/twins" replace />} />
|
||||||
<Route path="/pay" element={<PayPage />} />
|
<Route path="/pay" element={<PayPage />} />
|
||||||
<Route path="/pay-result" element={<PayResultPage />} />
|
<Route path="/pay-result" element={<PayResultPage />} />
|
||||||
<Route path="/twins" element={<Twins />} />
|
<Route path="/twins" element={<Twins />} />
|
||||||
|
|
@ -49,7 +54,7 @@ function App() {
|
||||||
path="/404"
|
path="/404"
|
||||||
element={<PlaceholderPage path="/404" title="404" description="页面不存在" />}
|
element={<PlaceholderPage path="/404" title="404" description="页面不存在" />}
|
||||||
/>
|
/>
|
||||||
<Route path="*" element={<Navigate to="/pay" replace />} />
|
<Route path="*" element={<Navigate to="/twins" replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,14 @@ export type UserConfig = {
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
// goods
|
|
||||||
export function getConfig() {
|
export function getConfig() {
|
||||||
return get<ApiResponse<UserConfig>>('/api/user/config')
|
return get<ApiResponse<UserConfig>>('/api/user/config')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getService() {
|
||||||
|
return get<ApiResponse<UserConfig>>('/api/weixin/service')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPackage({package_name}: {package_name: string}) {
|
||||||
|
return get<ApiResponse<Package>>('/api/package')
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { useEffect } from "react"
|
||||||
|
|
||||||
function Twins() {
|
function Twins() {
|
||||||
return (
|
return (
|
||||||
|
|
@ -42,7 +43,7 @@ function Card() {
|
||||||
"· 未安装请点击下方按钮前往App Store下载;",
|
"· 未安装请点击下方按钮前往App Store下载;",
|
||||||
],
|
],
|
||||||
linkName: "前往下载",
|
linkName: "前往下载",
|
||||||
linkUrl: "",
|
linkUrl: "https://apps.apple.com/us/app/testflight/id899247664?l=zh-Hans-CN",
|
||||||
sideBg: "./images/app-twins/step1-side.png"
|
sideBg: "./images/app-twins/step1-side.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -57,6 +58,13 @@ function Card() {
|
||||||
sideBg: "./images/app-twins/step2-side.png"
|
sideBg: "./images/app-twins/step2-side.png"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
useEffect(() => {
|
||||||
|
const packageName = window.localStorage.getItem('package')
|
||||||
|
console.log("packageName", packageName)
|
||||||
|
if(packageName) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
return (
|
return (
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-title">
|
<div className="card-title">
|
||||||
|
|
@ -84,10 +92,10 @@ function Card() {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div className="contact-us">
|
<a className="contact-us" href="" >
|
||||||
<img src="./images/app-twins/icon-concat.png" alt="客服1对1指导安装"></img>
|
<img src="./images/app-twins/icon-concat.png" alt="客服1对1指导安装"></img>
|
||||||
<span>客服1对1<br/>指导安装</span>
|
<span>客服1对1<br/>指导安装</span>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue