From a760fbfb1fd235a0a214658b4aad37cc34aa181e Mon Sep 17 00:00:00 2001 From: 1708-huayu <57060237+1708-huayu@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:05:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=8A=A0=E8=BD=BD=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 7 +++++-- docker/nginx.conf | 35 ++++++++++++----------------------- src/app/loading.tsx | 4 +++- src/app/login/loading.tsx | 4 +++- src/app/login/page.tsx | 4 ++-- src/ui/login/Page.tsx | 4 ++-- 6 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.env.development b/.env.development index e065a5f..a7fabd6 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,6 @@ # 前缀为NEXT_PUBLIC_才可以被浏览器使用 -NEXT_PUBLIC_TODO_REQUEST_URL=http://localhost:8092 -NEXT_PUBLIC_SECURITY_REQUEST_URL=http://localhost:8091 \ No newline at end of file +# 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 diff --git a/docker/nginx.conf b/docker/nginx.conf index b3ebd00..f93c788 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -17,6 +17,18 @@ http { server { listen 3001; + # 设置允许跨域的域,* 表示允许任何域,也可以设置特定的域 + add_header 'Access-Control-Allow-Origin' '*'; + # 允许的方法 + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + # 允许的头信息字段 + add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type'; + # 缓存时间 + add_header 'Access-Control-Max-Age' 1728000; + # 预检请求的处理 + if ($request_method = 'OPTIONS') { + return 204; + } # 服务器名称 server_name localhost; # 访问日志路径 @@ -38,18 +50,6 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_body_buffer_size 16k; client_max_body_size 100M; - - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With'; - - # 如果请求方法为 OPTIONS,则直接返回 204 状态码 - if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With'; - return 204; - } } location ^~ /security-server/ { # rewrite ^/security-server/(.*)$ /$1 break; @@ -60,17 +60,6 @@ http { client_body_buffer_size 16k; client_max_body_size 100M; - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With'; - - # 如果请求方法为 OPTIONS,则直接返回 204 状态码 - if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Content-Type, Accept, X-Requested-With'; - return 204; - } } location /task/ { rewrite ^/task/(.*)$ /task/$1.html break; diff --git a/src/app/loading.tsx b/src/app/loading.tsx index 438d658..81f75b3 100644 --- a/src/app/loading.tsx +++ b/src/app/loading.tsx @@ -1,3 +1,5 @@ +import { Skeleton } from "antd"; + export default function Loading() { - return
/Loading...
; + return ; } \ No newline at end of file diff --git a/src/app/login/loading.tsx b/src/app/login/loading.tsx index eeef040..81f75b3 100644 --- a/src/app/login/loading.tsx +++ b/src/app/login/loading.tsx @@ -1,3 +1,5 @@ +import { Skeleton } from "antd"; + export default function Loading() { - return
/login/Loading...
; + return ; } \ No newline at end of file diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index 4818bd2..52d6a8a 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -1,9 +1,9 @@ 'use client' import {ProConfigProvider} from "@ant-design/pro-components"; import React, {lazy, Suspense} from "react"; -// import Page from "@/ui/login/Page"; +import Page from "@/ui/login/Page"; import Loading from "@/app/loading"; -const Page = lazy(() => import('@/ui/login/Page')); +// const Page = lazy(() => import('@/ui/login/Page')); export default function Login() { return ( diff --git a/src/ui/login/Page.tsx b/src/ui/login/Page.tsx index 45c67d6..9cba4bd 100644 --- a/src/ui/login/Page.tsx +++ b/src/ui/login/Page.tsx @@ -16,7 +16,7 @@ import { ProFormText, } from '@ant-design/pro-components'; -import {Divider, Space, Tabs, message, theme, Modal, Button} from 'antd'; +import {Divider, Space, Tabs, message, theme, Modal, Button, Skeleton} from 'antd'; import React, {CSSProperties, Suspense, useCallback, useEffect, useLayoutEffect} from 'react'; import {useState} from 'react'; import {CaptchaLoginSuccess, LoginObject} from "@/lib/login/definitions"; @@ -358,7 +358,7 @@ export default function Page() { 忘记密码 - :} + :} ); }; \ No newline at end of file