Skip to content

Commit 8b397d2

Browse files
authored
Merge pull request #27 from MGdaasLab/v1.3.0
feat: 更新 Draw.io URL 配置,支持相对路径通过 Nginx 反向代理
2 parents 5a31586 + 7fda510 commit 8b397d2

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

WHartTest_Vue/nginx.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ server {
5252
}
5353

5454
# Draw.io 图表编辑器代理
55-
location /drawio/ {
55+
# 使用 ^~ 确保优先级高于静态资源缓存的正则匹配
56+
location ^~ /drawio/ {
5657
proxy_pass http://drawio:8080/;
5758
proxy_set_header Host $host;
5859
proxy_set_header X-Real-IP $remote_addr;

WHartTest_Vue/src/features/diagrams/views/AiDiagramView.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,13 @@ const loadFromStorage = () => {
216216
217217
// Draw.io URL 配置
218218
// 支持自托管:设置环境变量 VITE_DRAWIO_URL 为自托管地址,如 http://localhost:8920
219+
// 生产环境可使用相对路径如 /drawio,通过 Nginx 反向代理
219220
// 默认使用官方 embed 服务
220-
const DRAWIO_BASE_URL = import.meta.env.VITE_DRAWIO_URL || 'https://embed.diagrams.net';
221+
const DRAWIO_ENV_URL = import.meta.env.VITE_DRAWIO_URL || 'https://embed.diagrams.net';
222+
// 处理相对路径:转换为完整 URL
223+
const DRAWIO_BASE_URL = DRAWIO_ENV_URL.startsWith('/')
224+
? `${window.location.origin}${DRAWIO_ENV_URL}`
225+
: DRAWIO_ENV_URL;
221226
const DRAWIO_ORIGIN = new URL(DRAWIO_BASE_URL).origin;
222227
223228
// Draw.io URL (使用 embed 模式,启用自动保存)

0 commit comments

Comments
 (0)