From ab43fa2457bac0e45fdad43fc97be29e2122afdd Mon Sep 17 00:00:00 2001
From: Joshi <3040996759@qq.com>
Date: Thu, 11 Jun 2026 14:32:28 +0800
Subject: [PATCH] =?UTF-8?q?feat(auth):=20=E5=AE=9E=E7=8E=B0=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=E7=99=BB=E5=BD=95=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98?=
=?UTF-8?q?=E5=8C=96API=E8=AF=B7=E6=B1=82=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在App.vue中添加onMounted钩子自动执行autoLogin函数
- 新增auth.js工具模块实现自动登录逻辑
- 配置API请求优先从localStorage获取Token
- 添加对localStorage和Cookie中Token的兼容性处理
- 集成echarts-china-map依赖包
- 移除测试用硬编码Token和调试日志
- 统一API基础路径为/api
- 添加Docker部署配置文件和nginx反向代理设置
---
.dockerignore | 11 +++++++++
Dockerfile | 16 +++++++++++++
nginx.conf | 20 ++++++++++++++++
package.json | 1 +
src/App.vue | 6 +++++
src/api/request.js | 26 ++++++++------------
src/utils/auth.js | 57 ++++++++++++++++++++++++++++++++++++++++++++
src/utils/request.js | 26 ++++++++------------
8 files changed, 131 insertions(+), 32 deletions(-)
create mode 100644 .dockerignore
create mode 100644 Dockerfile
create mode 100644 nginx.conf
create mode 100644 src/utils/auth.js
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..aeb2738
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,11 @@
+node_modules
+.git
+.gitignore
+.idea
+*.md
+deploy.sh
+.env
+src
+public
+scripts
+node_modules
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..038d1ca
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,16 @@
+# ============================================
+# Docker 部署 - 数据大屏管理系统
+# 使用 Nginx 托管前端 + 反向代理 API
+# ============================================
+
+FROM nginx:alpine
+
+# 将构建好的前端静态文件复制到 Nginx
+COPY dist/ /usr/share/nginx/html/
+
+# 替换 Nginx 配置
+COPY nginx.conf /etc/nginx/conf.d/default.conf
+
+EXPOSE 18800
+
+CMD ["nginx", "-g", "daemon off;"]
diff --git a/nginx.conf b/nginx.conf
new file mode 100644
index 0000000..c74da9b
--- /dev/null
+++ b/nginx.conf
@@ -0,0 +1,20 @@
+server {
+ listen 18800;
+ server_name localhost;
+
+ # 前端静态文件
+ location / {
+ root /usr/share/nginx/html;
+ index index.html;
+ try_files $uri $uri/ /index.html; # Vue Router 历史模式支持
+ }
+
+ # API 反向代理到真实后端
+ location /api/ {
+ proxy_pass http://140.143.206.120/prod-api/;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ }
+}
diff --git a/package.json b/package.json
index ec837d9..2494045 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,7 @@
"axios": "^1.6.7",
"cors": "^2.8.6",
"echarts": "^5.6.0",
+ "echarts-china-map": "^1.0.4",
"element-plus": "^2.6.1",
"express": "^5.2.1",
"mysql2": "^3.22.3",
diff --git a/src/App.vue b/src/App.vue
index b9e2ce7..8b8ff88 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -3,6 +3,12 @@