diff --git a/.env.development b/.env.development index a7fabd6..c2f8fba 100644 --- a/.env.development +++ b/.env.development @@ -2,5 +2,8 @@ # NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8092 # NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091 -NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:80/todo-server -NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:80/security-server \ No newline at end of file +# NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:80/todo-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 \ No newline at end of file diff --git a/docker/nginx.conf b/docker/nginx.conf index 8b3c41c..5afcb53 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -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. 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; # 缓存时间 @@ -42,6 +42,13 @@ http { try_files $uri $uri.html $uri/ =404; # try_files $uri $uri/ =404; } + + # 第二个页面的配置 + location /mobile { + root /usr/share/nginx/html; + index index.html; + } + location ^~ /todo-server/ { # 预检请求的处理 if ($request_method = 'OPTIONS') { diff --git a/package-lock.json b/package-lock.json index 33a7006..c439300 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "postcss": "8.4.31", "react": "^18", "react-big-calendar": "^1.12.2", + "react-device-detect": "^2.2.3", "react-dom": "^18", "sass": "^1.77.3", "tailwindcss": "3.3.3" @@ -6139,6 +6140,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": { "version": "18.2.0", "resolved": "https://registry.npmmirror.com/react-dom/-/react-dom-18.2.0.tgz", @@ -7248,6 +7261,31 @@ "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": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz", diff --git a/package.json b/package.json index f9e0e29..e57b7b8 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "postcss": "8.4.31", "react": "^18", "react-big-calendar": "^1.12.2", + "react-device-detect": "^2.2.3", "react-dom": "^18", "sass": "^1.77.3", "tailwindcss": "3.3.3" diff --git a/src/ui/login/Page.tsx b/src/ui/login/Page.tsx index 9cba4bd..9c3b7fa 100644 --- a/src/ui/login/Page.tsx +++ b/src/ui/login/Page.tsx @@ -1,16 +1,10 @@ 'use client' import { - AlipayOutlined, LockOutlined, MailOutlined, - MobileOutlined, - TaobaoOutlined, UserOutlined, - WeiboOutlined, } from '@ant-design/icons'; import { - LoginForm, LoginFormPage, - ProConfigProvider, ProFormCaptcha, ProFormCheckbox, ProFormText, @@ -22,8 +16,8 @@ import {useState} from 'react'; import {CaptchaLoginSuccess, LoginObject} from "@/lib/login/definitions"; import {httpReq} from "@/utils/axiosReq"; import {useRouter} from 'next/navigation' -import {use} from 'react'; -import Loading from "@/app/loading"; +import { isMobile } from 'react-device-detect'; +import Cookies from "js-cookie"; type LoginType = 'email' | 'account'; @@ -37,6 +31,11 @@ const iconStyles: CSSProperties = { export default function Page() { const [loaded, setLoaded] = useState(false); useLayoutEffect(() => { + if (isMobile){ + console.log("手机端") + }else { + console.log("PC端") + } console.log('页面所有资源加载完毕'); setLoaded(true); }) @@ -53,7 +52,11 @@ export default function Page() { content: "使用帐号" + captchaLoginSuccess.username + "登录成功" }) localStorage.setItem('platform-security', captchaLoginSuccess.token) - router.push('/task/project') + if (isMobile){ + router.push('/mobile/listTask') + }else { + router.push('/task/project') + } setOpen(false) setLoading(false) } @@ -110,9 +113,13 @@ export default function Page() { // 删除名为 'platform-security' 的Cookie // Cookies.remove('platform-security'); // 设置一个有效期为7天的Cookie - // Cookies.set('platform-security', response.data.data, { expires: 7 }); + Cookies.set('platform-security', response.data.data, { expires: 7 }); // 登录成功,跳转到首页或者回调 - router.push('/task/project') + if (isMobile){ + router.push('/mobile/listTask') + }else { + router.push('/task/project') + } } else { messageApi.open({ type: 'error', @@ -137,9 +144,13 @@ export default function Page() { // 删除名为 'platform-security' 的Cookie // Cookies.remove('platform-security'); // 设置一个有效期为7天的Cookie - // Cookies.set('platform-security', response.data.data, { expires: 7 }); + Cookies.set('platform-security', response.data.data, { expires: 7 }); // 登录成功,跳转到首页或者回调 - router.push('/task/project') + if (isMobile){ + router.push('/mobile/listTask') + }else { + router.push('/task/project') + } } } else { messageApi.open({ diff --git a/src/ui/task/project/TreeTablePro.tsx b/src/ui/task/project/TreeTablePro.tsx index ba56a60..8bfe581 100644 --- a/src/ui/task/project/TreeTablePro.tsx +++ b/src/ui/task/project/TreeTablePro.tsx @@ -28,8 +28,8 @@ const TreeTablePro: React.FC = () => { const [filterChecked, setFilterChecked] = React.useState(true); const [current,setCurrent] = React.useState(1); const [pageSize,setPageSize] = React.useState(10); - - const pid = useSearchParams().get('pid')?useSearchParams().get('pid'):'0'; + const pathPid = useSearchParams().get('pid'); + const pid = pathPid?pathPid:'0'; const { RangePicker } = DatePicker; console.log("TreeTablePro",useSearchParams().get('pid')) const columns: ProColumns[] = [