fix:mobile

This commit is contained in:
1708-huayu 2025-01-13 19:33:53 +08:00
parent e01989fdfd
commit 5639c6e0f0
6 changed files with 78 additions and 18 deletions

View File

@ -2,5 +2,8 @@
# NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8092 # NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8092
# NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091 # NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091
NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:80/todo-server # NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:80/todo-server
NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:80/security-server # NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:80/security-server
NEXT_PUBLIC_TODO_REQUEST_URL=http://www.huaruyu.com/todo-server
NEXT_PUBLIC_SECURITY_REQUEST_URL=http://www.huaruyu.com/security-server

View File

@ -20,7 +20,7 @@ http {
# 设置允许跨域的域,* 表示允许任何域,也可以设置特定的域,has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. # 设置允许跨域的域,* 表示允许任何域,也可以设置特定的域,has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.
add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Origin' '*';
# 允许的方法 # 允许的方法
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
# 允许的头信息字段 # 允许的头信息字段
add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type,Authorization,Origin' always; add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type,Authorization,Origin' always;
# 缓存时间 # 缓存时间
@ -42,6 +42,13 @@ http {
try_files $uri $uri.html $uri/ =404; try_files $uri $uri.html $uri/ =404;
# try_files $uri $uri/ =404; # try_files $uri $uri/ =404;
} }
# 第二个页面的配置
location /mobile {
root /usr/share/nginx/html;
index index.html;
}
location ^~ /todo-server/ { location ^~ /todo-server/ {
# 预检请求的处理 # 预检请求的处理
if ($request_method = 'OPTIONS') { if ($request_method = 'OPTIONS') {

38
package-lock.json generated
View File

@ -18,6 +18,7 @@
"postcss": "8.4.31", "postcss": "8.4.31",
"react": "^18", "react": "^18",
"react-big-calendar": "^1.12.2", "react-big-calendar": "^1.12.2",
"react-device-detect": "^2.2.3",
"react-dom": "^18", "react-dom": "^18",
"sass": "^1.77.3", "sass": "^1.77.3",
"tailwindcss": "3.3.3" "tailwindcss": "3.3.3"
@ -6139,6 +6140,18 @@
"react-dom": "^16.14.0 || ^17 || ^18" "react-dom": "^16.14.0 || ^17 || ^18"
} }
}, },
"node_modules/react-device-detect": {
"version": "2.2.3",
"resolved": "https://registry.npmmirror.com/react-device-detect/-/react-device-detect-2.2.3.tgz",
"integrity": "sha512-buYY3qrCnQVlIFHrC5UcUoAj7iANs/+srdkwsnNjI7anr3Tt7UY6MqNxtMLlr0tMBied0O49UZVK8XKs3ZIiPw==",
"dependencies": {
"ua-parser-js": "^1.0.33"
},
"peerDependencies": {
"react": ">= 0.14.0",
"react-dom": ">= 0.14.0"
}
},
"node_modules/react-dom": { "node_modules/react-dom": {
"version": "18.2.0", "version": "18.2.0",
"resolved": "https://registry.npmmirror.com/react-dom/-/react-dom-18.2.0.tgz", "resolved": "https://registry.npmmirror.com/react-dom/-/react-dom-18.2.0.tgz",
@ -7248,6 +7261,31 @@
"node": ">=14.17" "node": ">=14.17"
} }
}, },
"node_modules/ua-parser-js": {
"version": "1.0.40",
"resolved": "https://registry.npmmirror.com/ua-parser-js/-/ua-parser-js-1.0.40.tgz",
"integrity": "sha512-z6PJ8Lml+v3ichVojCiB8toQJBuwR42ySM4ezjXIqXK3M0HczmKQ3LF4rhU55PfD99KEEXQG6yb7iOMyvYuHew==",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/ua-parser-js"
},
{
"type": "paypal",
"url": "https://paypal.me/faisalman"
},
{
"type": "github",
"url": "https://github.com/sponsors/faisalman"
}
],
"bin": {
"ua-parser-js": "script/cli.js"
},
"engines": {
"node": "*"
}
},
"node_modules/unbox-primitive": { "node_modules/unbox-primitive": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmmirror.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz", "resolved": "https://registry.npmmirror.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz",

View File

@ -19,6 +19,7 @@
"postcss": "8.4.31", "postcss": "8.4.31",
"react": "^18", "react": "^18",
"react-big-calendar": "^1.12.2", "react-big-calendar": "^1.12.2",
"react-device-detect": "^2.2.3",
"react-dom": "^18", "react-dom": "^18",
"sass": "^1.77.3", "sass": "^1.77.3",
"tailwindcss": "3.3.3" "tailwindcss": "3.3.3"

View File

@ -1,16 +1,10 @@
'use client' 'use client'
import { import {
AlipayOutlined,
LockOutlined, MailOutlined, LockOutlined, MailOutlined,
MobileOutlined,
TaobaoOutlined,
UserOutlined, UserOutlined,
WeiboOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { import {
LoginForm,
LoginFormPage, LoginFormPage,
ProConfigProvider,
ProFormCaptcha, ProFormCaptcha,
ProFormCheckbox, ProFormCheckbox,
ProFormText, ProFormText,
@ -22,8 +16,8 @@ import {useState} from 'react';
import {CaptchaLoginSuccess, LoginObject} from "@/lib/login/definitions"; import {CaptchaLoginSuccess, LoginObject} from "@/lib/login/definitions";
import {httpReq} from "@/utils/axiosReq"; import {httpReq} from "@/utils/axiosReq";
import {useRouter} from 'next/navigation' import {useRouter} from 'next/navigation'
import {use} from 'react'; import { isMobile } from 'react-device-detect';
import Loading from "@/app/loading"; import Cookies from "js-cookie";
type LoginType = 'email' | 'account'; type LoginType = 'email' | 'account';
@ -37,6 +31,11 @@ const iconStyles: CSSProperties = {
export default function Page() { export default function Page() {
const [loaded, setLoaded] = useState(false); const [loaded, setLoaded] = useState(false);
useLayoutEffect(() => { useLayoutEffect(() => {
if (isMobile){
console.log("手机端")
}else {
console.log("PC端")
}
console.log('页面所有资源加载完毕'); console.log('页面所有资源加载完毕');
setLoaded(true); setLoaded(true);
}) })
@ -53,7 +52,11 @@ export default function Page() {
content: "使用帐号" + captchaLoginSuccess.username + "登录成功" content: "使用帐号" + captchaLoginSuccess.username + "登录成功"
}) })
localStorage.setItem('platform-security', captchaLoginSuccess.token) localStorage.setItem('platform-security', captchaLoginSuccess.token)
if (isMobile){
router.push('/mobile/listTask')
}else {
router.push('/task/project') router.push('/task/project')
}
setOpen(false) setOpen(false)
setLoading(false) setLoading(false)
} }
@ -110,9 +113,13 @@ export default function Page() {
// 删除名为 'platform-security' 的Cookie // 删除名为 'platform-security' 的Cookie
// Cookies.remove('platform-security'); // Cookies.remove('platform-security');
// 设置一个有效期为7天的Cookie // 设置一个有效期为7天的Cookie
// Cookies.set('platform-security', response.data.data, { expires: 7 }); Cookies.set('platform-security', response.data.data, { expires: 7 });
// 登录成功,跳转到首页或者回调 // 登录成功,跳转到首页或者回调
if (isMobile){
router.push('/mobile/listTask')
}else {
router.push('/task/project') router.push('/task/project')
}
} else { } else {
messageApi.open({ messageApi.open({
type: 'error', type: 'error',
@ -137,10 +144,14 @@ export default function Page() {
// 删除名为 'platform-security' 的Cookie // 删除名为 'platform-security' 的Cookie
// Cookies.remove('platform-security'); // Cookies.remove('platform-security');
// 设置一个有效期为7天的Cookie // 设置一个有效期为7天的Cookie
// Cookies.set('platform-security', response.data.data, { expires: 7 }); Cookies.set('platform-security', response.data.data, { expires: 7 });
// 登录成功,跳转到首页或者回调 // 登录成功,跳转到首页或者回调
if (isMobile){
router.push('/mobile/listTask')
}else {
router.push('/task/project') router.push('/task/project')
} }
}
} else { } else {
messageApi.open({ messageApi.open({
type: 'error', type: 'error',

View File

@ -28,8 +28,8 @@ const TreeTablePro: React.FC = () => {
const [filterChecked, setFilterChecked] = React.useState(true); const [filterChecked, setFilterChecked] = React.useState(true);
const [current,setCurrent] = React.useState(1); const [current,setCurrent] = React.useState(1);
const [pageSize,setPageSize] = React.useState(10); const [pageSize,setPageSize] = React.useState(10);
const pathPid = useSearchParams().get('pid');
const pid = useSearchParams().get('pid')?useSearchParams().get('pid'):'0'; const pid = pathPid?pathPid:'0';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
console.log("TreeTablePro",useSearchParams().get('pid')) console.log("TreeTablePro",useSearchParams().get('pid'))
const columns: ProColumns<DataType>[] = [ const columns: ProColumns<DataType>[] = [