Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b275ea6798 | |||
| 2e7e90f411 | |||
| 3eefc074a8 | |||
| 730af827ad | |||
| b6facb0857 |
@@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* 对外开放 API
|
* 对外开放 API
|
||||||
* <p>
|
* <p>
|
||||||
* Token 一次消费:每个 token 只能用一次,消费后立即失效
|
* Token 一次消费:每个 token 只能用一次,消费后立即失效
|
||||||
* API 文档地址:http://服务地址:9002/doc.html → "对外开放API" 分组
|
* API 文档地址:http://服务地址:32002/doc.html → "对外开放API" 分组
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
|
|||||||
@@ -1116,7 +1116,7 @@ export default defineConfig({
|
|||||||
<!-- 配置项通过 data-* 属性传入 -->
|
<!-- 配置项通过 data-* 属性传入 -->
|
||||||
<div
|
<div
|
||||||
id="mokee-user-chip"
|
id="mokee-user-chip"
|
||||||
data-api-base="http://127.0.0.1:9000"
|
data-api-base="http://127.0.0.1:32000"
|
||||||
data-login-url="http://127.0.0.1:5001/login"
|
data-login-url="http://127.0.0.1:5001/login"
|
||||||
data-select-url="http://127.0.0.1:5001/select"
|
data-select-url="http://127.0.0.1:5001/select"
|
||||||
></div>
|
></div>
|
||||||
@@ -1136,7 +1136,7 @@ export default defineConfig({
|
|||||||
<br/>
|
<br/>
|
||||||
<!-- 2. 占位元素(可配置网关地址、登录页、切换系统页) --><br/>
|
<!-- 2. 占位元素(可配置网关地址、登录页、切换系统页) --><br/>
|
||||||
<div id="mokee-user-chip"<br/>
|
<div id="mokee-user-chip"<br/>
|
||||||
data-api-base="http://127.0.0.1:9000"<br/>
|
data-api-base="http://127.0.0.1:32000"<br/>
|
||||||
data-login-url="http://127.0.0.1:5001/login"<br/>
|
data-login-url="http://127.0.0.1:5001/login"<br/>
|
||||||
data-select-url="http://127.0.0.1:5001/select"></div><br/>
|
data-select-url="http://127.0.0.1:5001/select"></div><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ def init():
|
|||||||
# ===== 阶段3: 测试系统 =====
|
# ===== 阶段3: 测试系统 =====
|
||||||
print("\n===== 阶段3: 测试系统 (test) =====")
|
print("\n===== 阶段3: 测试系统 (test) =====")
|
||||||
cur.execute("""INSERT INTO sys_system (system_code, system_name, front_url, backend_url, gateway_url, status, description)
|
cur.execute("""INSERT INTO sys_system (system_code, system_name, front_url, backend_url, gateway_url, status, description)
|
||||||
VALUES ('test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统')""")
|
VALUES ('test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:32000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统')""")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
test_sid = cur.lastrowid
|
test_sid = cur.lastrowid
|
||||||
print(f" 系统: id={test_sid}")
|
print(f" 系统: id={test_sid}")
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
- [项目概览](project-overview.md) — 统一登录网关平台完整信息、架构、状态、已知问题
|
- [项目概览](project-overview.md) — 统一登录网关平台完整信息、架构、状态、已知问题
|
||||||
|
- [2026-07-16 会话-1](session-20260716-1.md) — IconPicker 增加直接上传图片功能
|
||||||
- [2026-06-28 会话-1](session-20260628-1.md) — 修复登录后 /open/token 和文件下载接口重复调用
|
- [2026-06-28 会话-1](session-20260628-1.md) — 修复登录后 /open/token 和文件下载接口重复调用
|
||||||
- [2026-06-09 会话](session-log.md) — 完整开发过程、决策、Bug修复、待办
|
- [2026-06-09 会话](session-log.md) — 完整开发过程、决策、Bug修复、待办
|
||||||
- [2026-06-10 会话-1](session-20260610-1.md) — 数据库地址变更、前端环境变量整理
|
- [2026-06-10 会话-1](session-20260610-1.md) — 数据库地址变更、前端环境变量整理
|
||||||
|
|||||||
@@ -95,8 +95,8 @@ metadata:
|
|||||||
|
|
||||||
## 待处理
|
## 待处理
|
||||||
- [x] **PROD 数据库 sys_file 表迁移** — 已完成,QA和PROD结构一致
|
- [x] **PROD 数据库 sys_file 表迁移** — 已完成,QA和PROD结构一致
|
||||||
- [ ] 部署前端到PROD(Nginx 10.10.1.160)
|
- [ ] 部署前端到PROD(Nginx 10.20.1.160)
|
||||||
- [ ] 部署后端到PROD(10.10.1.170)
|
- [ ] 部署后端到PROD(10.20.1.170)
|
||||||
- [ ] 验证头像上传端到端流程
|
- [ ] 验证头像上传端到端流程
|
||||||
- [ ] E-1 Cookie域localhost问题(开发环境限制,暂不处理)
|
- [ ] E-1 Cookie域localhost问题(开发环境限制,暂不处理)
|
||||||
- [ ] F-3 bindSystems/unbindSystems Redis同步(低优先级)
|
- [ ] F-3 bindSystems/unbindSystems Redis同步(低优先级)
|
||||||
|
|||||||
@@ -11,32 +11,32 @@ metadata:
|
|||||||
# 2026-06-12 第2次会话
|
# 2026-06-12 第2次会话
|
||||||
|
|
||||||
## 会话摘要
|
## 会话摘要
|
||||||
用户反馈 Vue 前端通过 VPN 访问非常慢(JS/CSS 加载要 1 分钟)。诊断发现根因是 Nginx 代理层(10.10.1.160)丢失了 gzip 压缩,导致 1MB+ 的文件通过 VPN 窄带宽原样传输。用户自行修复。
|
用户反馈 Vue 前端通过 VPN 访问非常慢(JS/CSS 加载要 1 分钟)。诊断发现根因是 Nginx 代理层(10.20.1.160)丢失了 gzip 压缩,导致 1MB+ 的文件通过 VPN 窄带宽原样传输。用户自行修复。
|
||||||
|
|
||||||
## 关键操作
|
## 关键操作
|
||||||
|
|
||||||
### VPN 网络诊断 — 前端加载慢
|
### VPN 网络诊断 — 前端加载慢
|
||||||
- **问题现象**: 通过域名 `web.gw.zgitm.com` 访问前端,JS/CSS 加载要 40 秒~1 分钟
|
- **问题现象**: 通过域名 `web.gw.zgitm.com` 访问前端,JS/CSS 加载要 40 秒~1 分钟
|
||||||
- **网络拓扑**: 用户电脑(10.10.1.5) → 公网VPN → 阿里云VPN(10.10.1.1) → Nginx代理(10.10.1.160) → 前端服务(10.10.1.170:5001)
|
- **网络拓扑**: 用户电脑(10.20.1.5) → 公网VPN → 阿里云VPN(10.20.1.1) → Nginx代理(10.20.1.160) → 前端服务(10.20.1.170:5001)
|
||||||
- **域名解析**: `web.gw.zgitm.com` 和 `login.user.zgitm.com` 均解析到 10.10.1.160
|
- **域名解析**: `web.gw.zgitm.com` 和 `login.user.zgitm.com` 均解析到 10.20.1.160
|
||||||
- **实测数据**:
|
- **实测数据**:
|
||||||
|
|
||||||
| 路径 | el.js (1.08MB) 耗时 | gzip |
|
| 路径 | el.js (1.08MB) 耗时 | gzip |
|
||||||
|------|---------------------|------|
|
|------|---------------------|------|
|
||||||
| 内网 10.1.1.170:5001 | 19ms | ✅ |
|
| 内网 10.1.1.170:5001 | 19ms | ✅ |
|
||||||
| VPN直连 10.10.1.170:5001 | 3-10秒 | ✅ |
|
| VPN直连 10.20.1.170:5001 | 3-10秒 | ✅ |
|
||||||
| Nginx代理 web.gw.zgitm.com | 20-40秒 | ❌ 丢失 |
|
| Nginx代理 web.gw.zgitm.com | 20-40秒 | ❌ 丢失 |
|
||||||
|
|
||||||
- **根因**: 10.10.1.170 上的 Nginx 返回 gzip 压缩内容,但 10.10.1.160 Nginx 代理时丢失了 gzip 压缩,导致 1MB+ 文件通过窄带宽 VPN 原样传输
|
- **根因**: 10.20.1.170 上的 Nginx 返回 gzip 压缩内容,但 10.20.1.160 Nginx 代理时丢失了 gzip 压缩,导致 1MB+ 文件通过窄带宽 VPN 原样传输
|
||||||
- **Ping延迟**: 5-15ms(正常),**不是延迟问题是带宽+压缩问题**
|
- **Ping延迟**: 5-15ms(正常),**不是延迟问题是带宽+压缩问题**
|
||||||
- **修复方案**: 在 10.10.1.160 Nginx 配置中添加 `proxy_set_header Accept-Encoding "gzip"` 和/或开启本地 gzip — 用户自行修复
|
- **修复方案**: 在 10.20.1.160 Nginx 配置中添加 `proxy_set_header Accept-Encoding "gzip"` 和/或开启本地 gzip — 用户自行修复
|
||||||
|
|
||||||
## 重要信息
|
## 重要信息
|
||||||
- VPN 网关: 10.10.1.1(阿里云)
|
- VPN 网关: 10.20.1.1(阿里云)
|
||||||
- VPN 子网: 10.10.1.x
|
- VPN 子网: 10.20.1.x
|
||||||
- 前端服务: 10.10.1.170:5001(内网 10.1.1.170:5001)
|
- 前端服务: 10.20.1.170:5001(内网 10.1.1.170:5001)
|
||||||
- Nginx 代理: 10.10.1.160
|
- Nginx 代理: 10.20.1.160
|
||||||
- DNS 服务器: 10.10.1.150
|
- DNS 服务器: 10.20.1.150
|
||||||
- 公网 IP: zgitm.com → 8.133.197.85
|
- 公网 IP: zgitm.com → 8.133.197.85
|
||||||
- 生产前端域名: web.gw.zgitm.com, login.user.zgitm.com
|
- 生产前端域名: web.gw.zgitm.com, login.user.zgitm.com
|
||||||
- Nginx 版本: 160 上是 1.14.1,170 上是 1.30.2
|
- Nginx 版本: 160 上是 1.14.1,170 上是 1.30.2
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ metadata:
|
|||||||
## 关键操作
|
## 关键操作
|
||||||
|
|
||||||
### 一、数据库地址变更
|
### 一、数据库地址变更
|
||||||
- MySQL + Redis 地址: `10.10.1.122` → `10.1.1.122`
|
- MySQL + Redis 地址: `10.20.1.122` → `10.1.1.122`
|
||||||
- 14个文件全局替换(yml/py/md)
|
- 14个文件全局替换(yml/py/md)
|
||||||
|
|
||||||
### 二、前后端字段匹配审计 + Bug修复
|
### 二、前后端字段匹配审计 + Bug修复
|
||||||
@@ -68,6 +68,6 @@ MenuList.vue统一用URL传id
|
|||||||
|
|
||||||
## 重要信息
|
## 重要信息
|
||||||
- 数据库: 10.1.1.122:3306
|
- 数据库: 10.1.1.122:3306
|
||||||
- 微服务端口: gateway:9000, auth:9001, admin:9002
|
- 微服务端口: gateway:32000, auth:32001, admin:32002
|
||||||
- 前端构建: `npm run build:prod` (跳过vue-tsc类型检查)
|
- 前端构建: `npm run build:prod` (跳过vue-tsc类型检查)
|
||||||
- Node版本: 服务器Node 18,Vite 5.4兼容
|
- Node版本: 服务器Node 18,Vite 5.4兼容
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ metadata:
|
|||||||
|
|
||||||
## 重要信息
|
## 重要信息
|
||||||
- Redis 前缀机制详情见 [[session-20260620-1]] 的 "Redis Key 加统一前缀 GATEWAY:" 章节
|
- Redis 前缀机制详情见 [[session-20260620-1]] 的 "Redis Key 加统一前缀 GATEWAY:" 章节
|
||||||
- Auth 服务(9001)、Admin 服务(9002)、Gateway(9000) 三个服务共享同一个 Redis 实例
|
- Auth 服务(32001)、Admin 服务(32002)、Gateway(32000) 三个服务共享同一个 Redis 实例
|
||||||
- 所有 Redis key 操作都必须通过 `RedisUtil.key()` 方法,不能直接拼字符串
|
- 所有 Redis key 操作都必须通过 `RedisUtil.key()` 方法,不能直接拼字符串
|
||||||
|
|
||||||
## 待处理
|
## 待处理
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ metadata:
|
|||||||
## 关键操作
|
## 关键操作
|
||||||
|
|
||||||
### /zgapi/v1/auth/system/list 性能排查
|
### /zgapi/v1/auth/system/list 性能排查
|
||||||
- **做了什么**: 完整追踪请求链路:Nginx → Gateway(9000) → TokenAuthFilter → RateLimitFilter → HeaderInjectFilter → ApiPermissionFilter → GatewayController → [HTTP转发] → Auth(9001) → DB/Redis
|
- **做了什么**: 完整追踪请求链路:Nginx → Gateway(32000) → TokenAuthFilter → RateLimitFilter → HeaderInjectFilter → ApiPermissionFilter → GatewayController → [HTTP转发] → Auth(32001) → DB/Redis
|
||||||
- **发现的浪费**:
|
- **发现的浪费**:
|
||||||
1. JWT 签名验证执行了 3 次(TokenAuthFilter + RateLimitFilter + AuthServiceImpl)
|
1. JWT 签名验证执行了 3 次(TokenAuthFilter + RateLimitFilter + AuthServiceImpl)
|
||||||
2. 同一个 Redis key 被查询了 4 次(TokenAuthFilter GET+GETEXPIRE + AuthServiceImpl GET+GETEXPIRE)
|
2. 同一个 Redis key 被查询了 4 次(TokenAuthFilter GET+GETEXPIRE + AuthServiceImpl GET+GETEXPIRE)
|
||||||
|
|||||||
46
memory/session-20260716-1.md
Normal file
46
memory/session-20260716-1.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
name: session-20260716-1
|
||||||
|
description: 2026-07-16 第1次会话 — IconPicker 增加直接上传图片功能
|
||||||
|
metadata:
|
||||||
|
type: session
|
||||||
|
date: 2026-07-16
|
||||||
|
sessionNumber: 1
|
||||||
|
startTime: 2026-07-16T00:00:00+08:00
|
||||||
|
---
|
||||||
|
|
||||||
|
# 2026-07-16 第1次会话
|
||||||
|
|
||||||
|
## 会话摘要
|
||||||
|
|
||||||
|
用户反馈前端图标选择器(IconPicker)缺少直接上传功能——需要先到文件管理页面上传图片,再回到表单选择。本次在 IconPicker 组件的"已上传"标签页中增加了上传按钮,支持直接在弹窗内上传图标图片,上传完成后自动选中。
|
||||||
|
|
||||||
|
## 关键操作
|
||||||
|
|
||||||
|
### IconPicker 增加上传按钮
|
||||||
|
|
||||||
|
- **做了什么**: 在 IconPicker.vue 的"已上传"标签页头部增加了「上传」按钮,点击后选择图片即自动上传到文件服务(fileType=icon),上传完成自动刷新列表并选中新图标
|
||||||
|
- **涉及文件**: `mokee-gateway-web/src/components/IconPicker.vue`
|
||||||
|
- **具体改动**:
|
||||||
|
1. 模板:在 popup-header 中添加 `<el-button>` 上传按钮(仅在 tab==='upload' 时显示)+ 隐藏 `<input type="file">`
|
||||||
|
2. 模板:添加 `.upload-status-bar` 上传进度条(el-progress + Loading 动画)
|
||||||
|
3. 脚本:导入 `Upload`, `Loading` 图标和 `ElMessage`
|
||||||
|
4. 脚本:添加 `FILE_SERVICE`, `uploading`, `uploadPercent`, `fileInputRef` 状态
|
||||||
|
5. 脚本:实现 `getFileServiceToken()` — 直调文件服务获取 Token(带缓存)
|
||||||
|
6. 脚本:实现 `triggerUploadIcon()` / `onIconFileSelected()` — 选择文件后自动上传
|
||||||
|
7. 样式:添加 `@keyframes spin` 和 `.upload-status-bar` 样式
|
||||||
|
|
||||||
|
- **上传流程**: 选择图片 → 获取文件服务 Token → FormData 上传(fileType=icon)→ file.wg.zgitm.com/api/upload → 刷新列表 → 自动选中新图标
|
||||||
|
|
||||||
|
- **结果**: TypeScript 编译通过,IconPicker.vue 无类型错误
|
||||||
|
|
||||||
|
## 重要信息
|
||||||
|
|
||||||
|
- 文件服务 URL: `VITE_FILE_SERVICE_URL` 环境变量,默认 `https://file.wg.zgitm.com`
|
||||||
|
- 上传 API: `POST {FILE_SERVICE}/api/upload`,FormData 包含 `file` + `fileType`
|
||||||
|
- 上传 Token: `POST {FILE_SERVICE}/api/token`,body: `{ systemCode: 'gateway' }`
|
||||||
|
- 图标列表查询: `GET /zgapi/v1/admin/file/list?fileType=icon`
|
||||||
|
- 文件服务直写 `sys_file` 表,admin 后端只做元信息查询
|
||||||
|
|
||||||
|
## 待处理
|
||||||
|
|
||||||
|
- [ ] 通知用户确认前端部署后功能正常
|
||||||
@@ -18,8 +18,8 @@ public class AdminApplication {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(AdminApplication.class, args);
|
SpringApplication.run(AdminApplication.class, args);
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
System.out.println(" 业务管理服务启动成功! 端口: 9002");
|
System.out.println(" 业务管理服务启动成功! 端口: 32002");
|
||||||
System.out.println(" Knife4j 文档: http://localhost:9002/doc.html");
|
System.out.println(" Knife4j 文档: http://localhost:32002/doc.html");
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,11 +114,11 @@ public class DashboardController {
|
|||||||
|
|
||||||
// 微服务健康状态:用 TCP 端口检测替代 HTTP(快 10 倍)
|
// 微服务健康状态:用 TCP 端口检测替代 HTTP(快 10 倍)
|
||||||
List<Map<String, Object>> services = new ArrayList<>();
|
List<Map<String, Object>> services = new ArrayList<>();
|
||||||
services.add(checkTcpPort("网关服务 (Gateway)", "127.0.0.1", 9000));
|
// services.add(checkTcpPort("网关服务 (Gateway)", "127.0.0.1", 32000));
|
||||||
services.add(checkTcpPort("认证服务 (Auth)", "127.0.0.1", 9001));
|
// services.add(checkTcpPort("认证服务 (Auth)", "127.0.0.1", 32001));
|
||||||
Map<String, Object> adminSvc = new LinkedHashMap<>();
|
Map<String, Object> adminSvc = new LinkedHashMap<>();
|
||||||
adminSvc.put("name", "管理服务 (Admin)");
|
adminSvc.put("name", "管理服务 (Admin)");
|
||||||
adminSvc.put("port", 9002);
|
adminSvc.put("port", 32002);
|
||||||
adminSvc.put("status", "UP");
|
adminSvc.put("status", "UP");
|
||||||
adminSvc.put("responseTime", 0);
|
adminSvc.put("responseTime", 0);
|
||||||
services.add(adminSvc);
|
services.add(adminSvc);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* 对外开放 API
|
* 对外开放 API
|
||||||
* <p>
|
* <p>
|
||||||
* Token 一次消费:每个 token 只能用一次,消费后立即失效
|
* Token 一次消费:每个 token 只能用一次,消费后立即失效
|
||||||
* API 文档地址:http://服务地址:9002/doc.html → "对外开放API" 分组
|
* API 文档地址:http://服务地址:32002/doc.html → "对外开放API" 分组
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ public class AuthApplication {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(AuthApplication.class, args);
|
SpringApplication.run(AuthApplication.class, args);
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
System.out.println(" 认证用户服务启动成功! 端口: 9001");
|
System.out.println(" 认证用户服务启动成功! 端口: 32001");
|
||||||
System.out.println(" Knife4j 文档: http://localhost:9001/doc.html");
|
System.out.println(" Knife4j 文档: http://localhost:32001/doc.html");
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class GatewayApplication {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(GatewayApplication.class, args);
|
SpringApplication.run(GatewayApplication.class, args);
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
System.out.println(" 网关服务启动成功! 端口: 9000");
|
System.out.println(" 网关服务启动成功! 端口: 32000");
|
||||||
System.out.println("========================================");
|
System.out.println("========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ public class GatewayController {
|
|||||||
private final RestTemplate restTemplate;
|
private final RestTemplate restTemplate;
|
||||||
private final SysSystemMapper sysSystemMapper;
|
private final SysSystemMapper sysSystemMapper;
|
||||||
|
|
||||||
@Value("${gateway.route.auth-url:http://127.0.0.1:9001}")
|
@Value("${gateway.route.auth-url:http://127.0.0.1:32001}")
|
||||||
private String authServiceUrl;
|
private String authServiceUrl;
|
||||||
|
|
||||||
@Value("${gateway.route.admin-url:http://127.0.0.1:9002}")
|
@Value("${gateway.route.admin-url:http://127.0.0.1:32002}")
|
||||||
private String adminServiceUrl;
|
private String adminServiceUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ mybatis-plus:
|
|||||||
|
|
||||||
gateway:
|
gateway:
|
||||||
route:
|
route:
|
||||||
auth-url: http://10.10.1.170:9001
|
auth-url: http://10.20.1.170:32001
|
||||||
admin-url: http://10.10.1.170:9002
|
admin-url: http://10.20.1.170:32002
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ mybatis-plus:
|
|||||||
|
|
||||||
gateway:
|
gateway:
|
||||||
route:
|
route:
|
||||||
auth-url: http://127.0.0.1:9001
|
auth-url: http://127.0.0.1:32001
|
||||||
admin-url: http://127.0.0.1:9002
|
admin-url: http://127.0.0.1:32002
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|||||||
4
mokee-gateway-web/Dockerfile
Normal file
4
mokee-gateway-web/Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM harbor.zgitm.com/library/nginx:alpine
|
||||||
|
COPY dist/ /usr/share/nginx/html/
|
||||||
|
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
EXPOSE 80
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
-->
|
-->
|
||||||
<div
|
<div
|
||||||
id="mokee-user-chip"
|
id="mokee-user-chip"
|
||||||
data-api-base="http://127.0.0.1:9000"
|
data-api-base="http://127.0.0.1:32000"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
52
mokee-gateway-web/nginx/nginx.conf
Normal file
52
mokee-gateway-web/nginx/nginx.conf
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# ==========================================
|
||||||
|
# Vue 项目 Nginx 配置模板
|
||||||
|
# 配合 Dockerfile.vue 使用
|
||||||
|
# ==========================================
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
# 日志格式
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
|
||||||
|
# 站点根目录
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# 静态资源长期缓存
|
||||||
|
location /assets/ {
|
||||||
|
expires 30d;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Vue Router history 模式支持
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# API 代理(如果有后端代理需求,可在此配置)
|
||||||
|
# location /api/ {
|
||||||
|
# proxy_pass http://backend-server:8080/;
|
||||||
|
# proxy_set_header Host $host;
|
||||||
|
# proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
# }
|
||||||
|
|
||||||
|
# Gzip 压缩
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types
|
||||||
|
text/plain
|
||||||
|
text/css
|
||||||
|
text/xml
|
||||||
|
text/javascript
|
||||||
|
application/json
|
||||||
|
application/javascript
|
||||||
|
application/xml+rss
|
||||||
|
application/x-javascript
|
||||||
|
image/svg+xml;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_proxied any;
|
||||||
|
}
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
-->
|
-->
|
||||||
<div
|
<div
|
||||||
id="mokee-user-chip"
|
id="mokee-user-chip"
|
||||||
data-api-base="http://127.0.0.1:9000"
|
data-api-base="http://127.0.0.1:32000"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
<el-radio-button value="builtin">内置图标</el-radio-button>
|
<el-radio-button value="builtin">内置图标</el-radio-button>
|
||||||
<el-radio-button value="upload">已上传</el-radio-button>
|
<el-radio-button value="upload">已上传</el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
|
<el-button v-if="tab === 'upload'" size="small" type="primary" :loading="uploading" @click="triggerUploadIcon">
|
||||||
|
<el-icon><Upload /></el-icon>上传
|
||||||
|
</el-button>
|
||||||
|
<input ref="fileInputRef" type="file" accept="image/*" style="display:none" @change="onIconFileSelected" />
|
||||||
<el-input v-model="search" placeholder="搜索..." size="small" clearable style="width:200px" />
|
<el-input v-model="search" placeholder="搜索..." size="small" clearable style="width:200px" />
|
||||||
<span class="count">{{ filtered.length }} 个</span>
|
<span class="count">{{ filtered.length }} 个</span>
|
||||||
<el-icon class="close-btn" :size="20" @click="visible = false"><Close /></el-icon>
|
<el-icon class="close-btn" :size="20" @click="visible = false"><Close /></el-icon>
|
||||||
@@ -37,6 +41,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 已上传图标 -->
|
<!-- 已上传图标 -->
|
||||||
|
<div v-if="tab === 'upload' && uploading" class="upload-status-bar">
|
||||||
|
<el-icon class="is-loading"><Loading /></el-icon>
|
||||||
|
<span>正在上传图标...</span>
|
||||||
|
<el-progress :percentage="uploadPercent" :stroke-width="6" :show-text="true" style="flex:1;max-width:200px" />
|
||||||
|
</div>
|
||||||
<div class="icon-grid uploaded-grid" v-if="tab === 'upload' && filteredUploads.length > 0">
|
<div class="icon-grid uploaded-grid" v-if="tab === 'upload' && filteredUploads.length > 0">
|
||||||
<div
|
<div
|
||||||
v-for="item in filteredUploads" :key="item.id"
|
v-for="item in filteredUploads" :key="item.id"
|
||||||
@@ -59,7 +68,8 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { ArrowDown, Close } from '@element-plus/icons-vue'
|
import { ArrowDown, Close, Upload, Loading } from '@element-plus/icons-vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
import * as Icons from '@element-plus/icons-vue'
|
import * as Icons from '@element-plus/icons-vue'
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
@@ -71,6 +81,12 @@ const search = ref('')
|
|||||||
const tab = ref('builtin')
|
const tab = ref('builtin')
|
||||||
const uploadedIcons = ref<{id:string, fileName:string}[]>([])
|
const uploadedIcons = ref<{id:string, fileName:string}[]>([])
|
||||||
|
|
||||||
|
// 上传相关状态
|
||||||
|
const FILE_SERVICE = import.meta.env.VITE_FILE_SERVICE_URL || 'https://file.wg.zgitm.com'
|
||||||
|
const uploading = ref(false)
|
||||||
|
const uploadPercent = ref(0)
|
||||||
|
const fileInputRef = ref<HTMLInputElement>()
|
||||||
|
|
||||||
const gatewayUrl = import.meta.env.VITE_GATEWAY_URL || ''
|
const gatewayUrl = import.meta.env.VITE_GATEWAY_URL || ''
|
||||||
|
|
||||||
function isUrl(v: string) { return v && (v.startsWith('http') || v.startsWith('/zgapi')) }
|
function isUrl(v: string) { return v && (v.startsWith('http') || v.startsWith('/zgapi')) }
|
||||||
@@ -101,6 +117,77 @@ async function fetchUploadedIcons() {
|
|||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取文件服务上传 Token(直调文件服务,不走网关) */
|
||||||
|
let cachedFileToken = ''
|
||||||
|
async function getFileServiceToken(): Promise<string> {
|
||||||
|
if (cachedFileToken) return cachedFileToken
|
||||||
|
try {
|
||||||
|
const axios = (await import('axios')).default
|
||||||
|
const res = await axios.post(`${FILE_SERVICE}/api/token`, { systemCode: 'gateway' }, { timeout: 10000 })
|
||||||
|
const token = res.data?.data?.token || ''
|
||||||
|
if (token) cachedFileToken = token
|
||||||
|
return token
|
||||||
|
} catch { return '' }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 触发文件选择器 */
|
||||||
|
function triggerUploadIcon() {
|
||||||
|
fileInputRef.value?.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 文件选择后立即上传 */
|
||||||
|
async function onIconFileSelected(e: Event) {
|
||||||
|
const files = (e.target as HTMLInputElement).files
|
||||||
|
if (!files || files.length === 0) return
|
||||||
|
const file = files[0]
|
||||||
|
// 重置 input 以允许重复选择同一文件
|
||||||
|
if (fileInputRef.value) fileInputRef.value.value = ''
|
||||||
|
|
||||||
|
uploading.value = true
|
||||||
|
uploadPercent.value = 0
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. 获取上传 Token
|
||||||
|
const token = await getFileServiceToken()
|
||||||
|
if (!token) {
|
||||||
|
ElMessage.error('获取上传 Token 失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 上传到文件服务(指定 fileType=icon)
|
||||||
|
const axios = (await import('axios')).default
|
||||||
|
const fd = new FormData()
|
||||||
|
fd.append('file', file)
|
||||||
|
fd.append('fileType', 'icon')
|
||||||
|
const uploadRes = await axios.post(`${FILE_SERVICE}/api/upload`, fd, {
|
||||||
|
timeout: 120000,
|
||||||
|
headers: { Authorization: 'Bearer ' + token },
|
||||||
|
onUploadProgress: (e: any) => {
|
||||||
|
if (e.total > 0) uploadPercent.value = Math.round((e.loaded / e.total) * 100)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// Token 用完即清
|
||||||
|
cachedFileToken = ''
|
||||||
|
|
||||||
|
// 3. 刷新已上传图标列表
|
||||||
|
await fetchUploadedIcons()
|
||||||
|
|
||||||
|
// 4. 自动选中新上传的图标
|
||||||
|
const fileId = uploadRes.data?.data?.fileId
|
||||||
|
if (fileId) {
|
||||||
|
select(getFileUrl(fileId))
|
||||||
|
}
|
||||||
|
ElMessage.success('图标上传成功')
|
||||||
|
} catch {
|
||||||
|
cachedFileToken = ''
|
||||||
|
ElMessage.error('图标上传失败')
|
||||||
|
} finally {
|
||||||
|
uploading.value = false
|
||||||
|
uploadPercent.value = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function select(val: string) {
|
function select(val: string) {
|
||||||
emit('update:modelValue', val)
|
emit('update:modelValue', val)
|
||||||
visible.value = false
|
visible.value = false
|
||||||
@@ -122,7 +209,7 @@ onMounted(fetchUploadedIcons)
|
|||||||
.arrow { color: var(--text-muted); flex-shrink: 0; }
|
.arrow { color: var(--text-muted); flex-shrink: 0; }
|
||||||
|
|
||||||
.icon-overlay {
|
.icon-overlay {
|
||||||
position: fixed; inset: 0; z-index: 9000;
|
position: fixed; inset: 0; z-index: 32000;
|
||||||
background: rgba(0,0,0,0.35);
|
background: rgba(0,0,0,0.35);
|
||||||
display: flex; align-items: center; justify-content: center;
|
display: flex; align-items: center; justify-content: center;
|
||||||
}
|
}
|
||||||
@@ -159,10 +246,21 @@ onMounted(fetchUploadedIcons)
|
|||||||
/* 触发器中的图片预览 */
|
/* 触发器中的图片预览 */
|
||||||
.trigger-img { width:20px; height:20px; object-fit:contain; border-radius:3px; }
|
.trigger-img { width:20px; height:20px; object-fit:contain; border-radius:3px; }
|
||||||
|
|
||||||
|
/* 上传进度条 */
|
||||||
|
.upload-status-bar {
|
||||||
|
display: flex; align-items: center; gap: 10px;
|
||||||
|
padding: 12px 20px; margin: 0 20px;
|
||||||
|
background: var(--color-primary-bg, #eef2ff); border-radius: var(--radius-md);
|
||||||
|
font-size: 13px; color: var(--color-primary);
|
||||||
|
}
|
||||||
|
.upload-status-bar .is-loading { animation: spin 1s linear infinite; }
|
||||||
|
|
||||||
/* 已上传图标 */
|
/* 已上传图标 */
|
||||||
.uploaded-grid { grid-template-columns: repeat(8, 1fr); }
|
.uploaded-grid { grid-template-columns: repeat(8, 1fr); }
|
||||||
.upload-icon-thumb { width:48px; height:48px; object-fit:contain; border-radius:var(--radius-sm); }
|
.upload-icon-thumb { width:48px; height:48px; object-fit:contain; border-radius:var(--radius-sm); }
|
||||||
|
|
||||||
|
@keyframes spin { to { transform: rotate(360deg); } }
|
||||||
|
|
||||||
@media (max-width:960px) {
|
@media (max-width:960px) {
|
||||||
.icon-popup { width:98vw; max-height:90vh; }
|
.icon-popup { width:98vw; max-height:90vh; }
|
||||||
.icon-grid { grid-template-columns: repeat(6, 1fr); }
|
.icon-grid { grid-template-columns: repeat(6, 1fr); }
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ cur.execute("INSERT INTO sys_user (id, username, password, real_name, email, pho
|
|||||||
test_sid = uid()
|
test_sid = uid()
|
||||||
gw_sid = uid()
|
gw_sid = uid()
|
||||||
cur.execute("INSERT INTO sys_system (id,system_code,system_name,front_url,backend_url,gateway_url,status,description) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
|
cur.execute("INSERT INTO sys_system (id,system_code,system_name,front_url,backend_url,gateway_url,status,description) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",
|
||||||
(test_sid, 'test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统'))
|
(test_sid, 'test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:32000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统'))
|
||||||
cur.execute("INSERT INTO sys_system (id,system_code,system_name,front_url,backend_url,gateway_url,icon,sort_order,status,description,doc_token) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
|
cur.execute("INSERT INTO sys_system (id,system_code,system_name,front_url,backend_url,gateway_url,icon,sort_order,status,description,doc_token) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
|
||||||
(gw_sid, 'gateway', '网关管理平台', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/gateway', '', 0, 1, '统一登录网关管理后台', 'gateway1234567890'))
|
(gw_sid, 'gateway', '网关管理平台', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/gateway', '', 0, 1, '统一登录网关管理后台', 'gateway1234567890'))
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ ALTER TABLE sys_system MODIFY doc_token VARCHAR(128) DEFAULT NULL;
|
|||||||
-- 去重约束
|
-- 去重约束
|
||||||
ALTER TABLE sys_system ADD UNIQUE KEY uk_gateway_url (gateway_url);
|
ALTER TABLE sys_system ADD UNIQUE KEY uk_gateway_url (gateway_url);
|
||||||
-- 更新现有数据: 给每个系统一个不同的 gateway_url
|
-- 更新现有数据: 给每个系统一个不同的 gateway_url
|
||||||
UPDATE sys_system SET gateway_url = CONCAT('http://127.0.0.1:9000/', system_code) WHERE gateway_url = '';
|
UPDATE sys_system SET gateway_url = CONCAT('http://127.0.0.1:32000/', system_code) WHERE gateway_url = '';
|
||||||
|
|
||||||
-- 2. sys_file: 重建为新结构(文件二进制存入数据库)
|
-- 2. sys_file: 重建为新结构(文件二进制存入数据库)
|
||||||
DROP TABLE IF EXISTS sys_file;
|
DROP TABLE IF EXISTS sys_file;
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ VALUES (REPLACE(UUID(),'-',''), 'admin', '$2b$10$ffAZHF6lmUuNV6OJITADXeduD5mMTS0
|
|||||||
|
|
||||||
-- 测试系统
|
-- 测试系统
|
||||||
INSERT INTO sys_system (id, system_code, system_name, front_url, backend_url, gateway_url, status, description)
|
INSERT INTO sys_system (id, system_code, system_name, front_url, backend_url, gateway_url, status, description)
|
||||||
VALUES (REPLACE(UUID(),'-',''), 'test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/test', 1, '测试用业务系统');
|
VALUES (REPLACE(UUID(),'-',''), 'test', '测试系统', 'http://127.0.0.1:5001', 'http://127.0.0.1:32000', 'http://127.0.0.1:32000/test', 1, '测试用业务系统');
|
||||||
|
|
||||||
-- Gateway 系统
|
-- Gateway 系统
|
||||||
INSERT INTO sys_system (id, system_code, system_name, front_url, backend_url, gateway_url, icon, sort_order, status, description, doc_token)
|
INSERT INTO sys_system (id, system_code, system_name, front_url, backend_url, gateway_url, icon, sort_order, status, description, doc_token)
|
||||||
VALUES (REPLACE(UUID(),'-',''), 'gateway', '网关管理平台', 'http://127.0.0.1:5001', 'http://127.0.0.1:9000', 'http://127.0.0.1:9000/gateway', '', 0, 1, '统一登录网关管理后台', 'gateway1234567890');
|
VALUES (REPLACE(UUID(),'-',''), 'gateway', '网关管理平台', 'http://127.0.0.1:5001', 'http://127.0.0.1:32000', 'http://127.0.0.1:32000/gateway', '', 0, 1, '统一登录网关管理后台', 'gateway1234567890');
|
||||||
|
|
||||||
-- 查询已插入的ID
|
-- 查询已插入的ID
|
||||||
SELECT id INTO @uid FROM sys_user WHERE username='admin';
|
SELECT id INTO @uid FROM sys_user WHERE username='admin';
|
||||||
|
|||||||
@@ -30,23 +30,23 @@
|
|||||||
↓
|
↓
|
||||||
[业务系统前端] → [统一登录页面(https://login.user.zgitm.com)]
|
[业务系统前端] → [统一登录页面(https://login.user.zgitm.com)]
|
||||||
↓
|
↓
|
||||||
[网关服务(9000)] → [认证用户服务(9001)]
|
[网关服务(32000)] → [认证用户服务(32001)]
|
||||||
↓ ↓
|
↓ ↓
|
||||||
[业务系统后端] ← [业务管理服务(9002)]
|
[业务系统后端] ← [业务管理服务(32002)]
|
||||||
↓
|
↓
|
||||||
[MySQL数据库] ← [Redis缓存]
|
[MySQL数据库] ← [Redis缓存]
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2.2 微服务拆分与职责
|
### 2.2 微服务拆分与职责
|
||||||
|
|
||||||
#### 2.2.1 网关服务(mokee-gateway-gateway)- 端口9000
|
#### 2.2.1 网关服务(mokee-gateway-gateway)- 端口32000
|
||||||
- 统一入口:所有业务系统的接口请求和页面访问统一经过网关
|
- 统一入口:所有业务系统的接口请求和页面访问统一经过网关
|
||||||
- 路由转发:根据配置的系统信息,将请求转发到对应的业务系统后端
|
- 路由转发:根据配置的系统信息,将请求转发到对应的业务系统后端
|
||||||
- 身份认证:校验请求中的Token有效性,拦截未登录请求
|
- 身份认证:校验请求中的Token有效性,拦截未登录请求
|
||||||
- 信息透传:将用户ID、用户名、角色、岗位、系统ID等信息注入请求头,传递给业务系统后端
|
- 信息透传:将用户ID、用户名、角色、岗位、系统ID等信息注入请求头,传递给业务系统后端
|
||||||
- 接口鉴权:校验请求接口是否在业务系统的放行列表中
|
- 接口鉴权:校验请求接口是否在业务系统的放行列表中
|
||||||
|
|
||||||
#### 2.2.2 认证用户服务(mokee-gateway-auth)- 端口9001
|
#### 2.2.2 认证用户服务(mokee-gateway-auth)- 端口32001
|
||||||
- 登录认证:处理用户登录请求,验证账号密码,生成Token
|
- 登录认证:处理用户登录请求,验证账号密码,生成Token
|
||||||
- 用户管理:维护用户基本信息、用户与系统的绑定关系
|
- 用户管理:维护用户基本信息、用户与系统的绑定关系
|
||||||
- 权限管理:维护角色、菜单信息,用户与角色的绑定关系
|
- 权限管理:维护角色、菜单信息,用户与角色的绑定关系
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
- 基础接口:提供获取用户信息、系统信息、菜单路由等基础接口
|
- 基础接口:提供获取用户信息、系统信息、菜单路由等基础接口
|
||||||
- 系统选择:登录成功后判断用户绑定系统数量,返回系统列表或直接跳转
|
- 系统选择:登录成功后判断用户绑定系统数量,返回系统列表或直接跳转
|
||||||
|
|
||||||
#### 2.2.3 业务管理服务(mokee-gateway-admin)- 端口9002
|
#### 2.2.3 业务管理服务(mokee-gateway-admin)- 端口32002
|
||||||
- 系统管理:维护业务系统的基本信息、域名配置、接口放行列表
|
- 系统管理:维护业务系统的基本信息、域名配置、接口放行列表
|
||||||
- 数据字典:维护全局通用的数据字典
|
- 数据字典:维护全局通用的数据字典
|
||||||
- 日志管理:记录用户登录日志和系统操作日志
|
- 日志管理:记录用户登录日志和系统操作日志
|
||||||
|
|||||||
Reference in New Issue
Block a user