From 7c5ddacbaa1ccb8d26133fce7fc54618cc7552f6 Mon Sep 17 00:00:00 2001 From: 1708-huayu <57060237+1708-huayu@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:49:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B7=B3=E8=BD=ACmobile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/nginx.conf | 5 +++-- src/app/page.tsx | 9 ++++++++- src/ui/login/Page.tsx | 6 +++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docker/nginx.conf b/docker/nginx.conf index 5afcb53..cfed3c0 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -44,9 +44,10 @@ http { } # 第二个页面的配置 - location /mobile { + location ^~ /mobile/ { root /usr/share/nginx/html; - index index.html; + index index.html index.htm; + try_files $uri $uri.html $uri/ =404; } location ^~ /todo-server/ { diff --git a/src/app/page.tsx b/src/app/page.tsx index 97e6b88..0ea4f1f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -2,11 +2,18 @@ import { useRouter} from "next/navigation"; import dayjs from "dayjs"; import {useEffect} from "react"; +import { isMobile } from 'react-device-detect'; export default function Home() { const {replace} = useRouter(); useEffect(()=>{ - replace("/login") + if(localStorage.getItem('platform-security')){ + if (isMobile){ + window.location.href = 'http://www.huaruyu.com/mobile' + }else { + replace("/task/project") + } + } },[]) dayjs.locale('zh-cn') return ( diff --git a/src/ui/login/Page.tsx b/src/ui/login/Page.tsx index 9c3b7fa..9010129 100644 --- a/src/ui/login/Page.tsx +++ b/src/ui/login/Page.tsx @@ -53,7 +53,7 @@ export default function Page() { }) localStorage.setItem('platform-security', captchaLoginSuccess.token) if (isMobile){ - router.push('/mobile/listTask') + window.location.href = '/mobile' }else { router.push('/task/project') } @@ -116,7 +116,7 @@ export default function Page() { Cookies.set('platform-security', response.data.data, { expires: 7 }); // 登录成功,跳转到首页或者回调 if (isMobile){ - router.push('/mobile/listTask') + window.location.href = '/mobile' }else { router.push('/task/project') } @@ -147,7 +147,7 @@ export default function Page() { Cookies.set('platform-security', response.data.data, { expires: 7 }); // 登录成功,跳转到首页或者回调 if (isMobile){ - router.push('/mobile/listTask') + window.location.href = '/mobile' }else { router.push('/task/project') }