From 9fb6be8bb355a027ac0ceca0ad198f7356af4bb1 Mon Sep 17 00:00:00 2001
From: 1708-huayu <57060237+1708-huayu@users.noreply.github.com>
Date: Tue, 26 Aug 2025 18:59:09 +0800
Subject: [PATCH] =?UTF-8?q?feat:=E8=B7=B3=E8=BD=AC=E7=99=BB=E5=BD=95?=
=?UTF-8?q?=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docker/Dockerfile | 4 +-
docker/deploy.md | 4 +-
docker/indexv.html | 573 ++++++++++++++++++++++++++++++++++++++++++
docker/nginx-yun.conf | 4 -
docker/nginx.conf | 19 ++
src/utils/axiosReq.ts | 10 +-
6 files changed, 607 insertions(+), 7 deletions(-)
create mode 100644 docker/indexv.html
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 5dd7be5..04435fd 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,7 +1,9 @@
# nginx配置
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
+COPY outd /usr/share/nginx/html/todo
+COPY outd /usr/share/nginx/html
+COPY index.html /usr/share/nginx/html/index.html
COPY cert /etc/nginx/cert
-COPY out /html
EXPOSE 3001 3002
CMD ["nginx", "-g", "daemon off;"]
\ No newline at end of file
diff --git a/docker/deploy.md b/docker/deploy.md
index 8743595..7ab5e3b 100644
--- a/docker/deploy.md
+++ b/docker/deploy.md
@@ -16,7 +16,9 @@ docker rmi task-manager-nginx
cd /home/shixiaohua/docker/todo-web/
docker build -t task-manager-nginx .
-docker run -d -p 3001:80 -p 3002:443 --network task-manager --restart unless-stopped -v ./out:/usr/share/nginx/html --name task-manager-nginx task-manager-nginx
+docker run -d -p 3001:80 -p 3002:443 --network task-manager --restart unless-stopped --name task-manager-nginx task-manager-nginx
+
+docker run -d -p 3001:80 -p 3002:443 --network task-manager --restart unless-stopped -v ./outd:/usr/share/nginx/html/ --name task-manager-nginx task-manager-nginx
# 进入容器
docker exec -it a3ca9658cc6ce331cc0e4f84996088940a386b39b3e2edd56549d335a52ab581 /bin/sh
```
diff --git a/docker/indexv.html b/docker/indexv.html
new file mode 100644
index 0000000..3806792
--- /dev/null
+++ b/docker/indexv.html
@@ -0,0 +1,573 @@
+
+
+
+
+
+
+ 马上行计划管理
+
+
+
+
+
+
+
+
+
+
+
+
+
+
公众号
+

+
+ 扫描关注获取更多功能
+
+
+
+
小程序
+

+
+ 扫描直接使用应用
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docker/nginx-yun.conf b/docker/nginx-yun.conf
index 42dec47..0e167d0 100644
--- a/docker/nginx-yun.conf
+++ b/docker/nginx-yun.conf
@@ -61,10 +61,6 @@ http {
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
- # 确保不会重定向到带端口的URL
- add_header X-Forwarded-Host $host;
- add_header X-Forwarded-Port 443;
- add_header X-Forwarded-Proto https;
# 预检请求的处理
if ($request_method = 'OPTIONS') {
return 204;
diff --git a/docker/nginx.conf b/docker/nginx.conf
index 24a6457..0deefe4 100644
--- a/docker/nginx.conf
+++ b/docker/nginx.conf
@@ -57,6 +57,13 @@ http {
add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type,Authorization,Origin,source-client' always;
# 缓存时间
add_header 'Access-Control-Max-Age' 1728000 always;
+
+ # 确保不会重定向到带端口的URL
+ add_header X-Forwarded-Host $host;
+ add_header X-Forwarded-Port 443;
+ add_header X-Forwarded-Proto https;
+
+
# 预检请求的处理
if ($request_method = 'OPTIONS') {
return 204;
@@ -72,6 +79,18 @@ http {
try_files $uri $uri.html $uri/ =404;
# try_files $uri $uri/ =404;
}
+ location /todo {
+ # 关键配置:禁用重定向中的端口和绝对路径
+ absolute_redirect off;
+ port_in_redirect off;
+
+ # 指定根目录
+ alias /usr/share/nginx/html/todo;
+ index index.html index.htm;
+
+ # 正确的文件查找逻辑:所有路由都返回 index.html
+ try_files $uri $uri.html $uri/ /todo/index.html;
+ }
# 第二个页面的配置
location ^~ /mobile/ {
diff --git a/src/utils/axiosReq.ts b/src/utils/axiosReq.ts
index 6b63162..ff7fc1f 100644
--- a/src/utils/axiosReq.ts
+++ b/src/utils/axiosReq.ts
@@ -16,6 +16,7 @@ export const httpReq = axios.create({
})
// 创建一个取消令牌
const cancelTokenSource: CancelTokenSource = axios.CancelToken.source();
+const isProduction = process.env.NODE_ENV === 'production'
// 默认json格式
httpReq.defaults.headers.common['Accept'] = 'application/json';
// 请求前处理
@@ -102,6 +103,10 @@ httpReq.interceptors.response.use(
message.error('系统异常');
} else if (response.status >= 400 && response.status <= 500) {
message.warning('无权限');
+ localStorage.removeItem("platform-security");
+ Cookies.remove("platform-security");
+ // window.location.href = isProduction?"https://www.huaruyu.com/todo":""+`/login?callBack=${encodeURIComponent(window.location.pathname + window.location.search)}`;
+ window.location.href = (isProduction?"/todo":"")+`/login?callBack=${encodeURIComponent(window.location.pathname + window.location.search)}`;
} else if (response.data.status.success == false) {
message.error(response.data.status.message);
return Promise.reject(response.data.status.message);
@@ -118,7 +123,10 @@ httpReq.interceptors.response.use(
message.error('系统异常');
} else if (error.response.status >= 400 && error.response.status <= 500) {
message.warning('无权限');
- window.location.href = `/login?callBack=${encodeURIComponent(window.location.pathname + window.location.search)}`;
+ localStorage.removeItem("platform-security");
+ Cookies.remove("platform-security");
+ // window.location.href = isProduction?"https://www.huaruyu.com/todo":""+`/login?callBack=${encodeURIComponent(window.location.pathname + window.location.search)}`;
+ window.location.href = (isProduction?"/todo":"")+`/login?callBack=${encodeURIComponent(window.location.pathname + window.location.search)}`;
}
// switch (error.response.status) {
// case 401: