fix;合并修复问题
This commit is contained in:
+13
-44
@@ -1,44 +1,13 @@
|
||||
import { Routes, Route, Navigate } from 'react-router-dom';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import LoginPage from './pages/LoginPage';
|
||||
|
||||
import PartnerAppRoutes from './PartnerAppRoutes';
|
||||
|
||||
import { handlePartnerWechatCallback, handlePartnerWechatLoginResult } from './lib/wechat-auth';
|
||||
|
||||
import { isLoggedIn } from './lib/api';
|
||||
|
||||
import { isWechatEnv } from './lib/weixin';
|
||||
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
|
||||
|
||||
|
||||
function WechatOAuthHandler() {
|
||||
|
||||
const location = useLocation();
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
if (!isWechatEnv() || !location.search.includes('code=')) return;
|
||||
|
||||
if (location.pathname === '/login') return;
|
||||
|
||||
void handlePartnerWechatCallback()
|
||||
|
||||
.then((result) => {
|
||||
|
||||
if (!result || !handlePartnerWechatLoginResult(result)) return;
|
||||
|
||||
const params = new URLSearchParams(location.search);
|
||||
|
||||
params.delete('code');
|
||||
|
||||
params.delete('state');
|
||||
|
||||
import { Routes, Route, Navigate } from 'react-router-dom';
|
||||
import LoginPage from './pages/LoginPage';
|
||||
import PartnerAppRoutes from './PartnerAppRoutes';
|
||||
import { isLoggedIn } from './lib/api';
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/login" element={<LoginPage />} />
|
||||
<Route path="/*" element={isLoggedIn() ? <PartnerAppRoutes /> : <Navigate to="/login" replace />} />
|
||||
</Routes>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user