From 8bf4a6d861a1630241dc917c06c60065475eef15 Mon Sep 17 00:00:00 2001 From: jhd <1684074631@qq.com> Date: Mon, 6 Jul 2026 15:40:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(config):=20=E6=B7=BB=E5=8A=A0=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8URL=E9=85=8D=E7=BD=AE=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=96=87=E4=BB=B6=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 application.yml 中添加 server-url 配置项,支持各环境profile覆盖 - 在 application-dev.yml 和 application-prod.yml 中分别配置对应的服务器地址 - 移除 @flyfish-group/file-viewer-web 依赖,改用 iframe 方式实现文件预览 - 更新 drawingDesign、installFeedback、layout 和 manuals 等模块的预览逻辑 - 在 ServerConfig 中实现优先使用配置的 server-url 的逻辑 - 移除相关的 viewerCtrl 控制器和生命周期钩子函数 --- .../src/main/resources/application-dev.yml | 5 ++++ .../src/main/resources/application-prod.yml | 4 +++ .../src/main/resources/application.yml | 5 ++-- .../ruoyi/framework/config/ServerConfig.java | 10 +++++++ ruoyi-ui/src/views/rm/drawingDesign/index.vue | 28 ++----------------- .../src/views/rm/installFeedback/index.vue | 27 +++--------------- ruoyi-ui/src/views/rm/layout/index.vue | 28 ++----------------- ruoyi-ui/src/views/rm/manuals/index.vue | 28 ++----------------- 8 files changed, 35 insertions(+), 100 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index cfbb80e..52bf511 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -1,3 +1,8 @@ +--- # 本地开发环境覆盖 +ruoyi: + profile: /home/wy/oa/uploadPath + server-url: http://localhost:8080 + --- # 监控中心配置 spring.boot.admin.client: # 增加客户端开关 diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index 86747ce..b0e348d 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -1,3 +1,7 @@ +--- # 生产环境覆盖 +ruoyi: + profile: /home/wy/oa/uploadPath + server-url: http://49.232.154.205:8080 --- # 监控中心配置 spring.boot.admin.client: diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 7a76333..2ea01bd 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -12,9 +12,10 @@ ruoyi: addressEnabled: true # 缓存懒加载 cacheLazy: false - # 文件路径 + # 服务地址(各环境 profile 覆盖此值) + server-url: http://localhost:8080 + # 文件路径(各环境 profile 覆盖此值) profile: /home/wy/oa/uploadPath -# profile: F:\work\fad_oa系统\fad_oa\temp captcha: # 页面 <参数设置> 可开启关闭 验证码校验 diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java index a65e640..3a9b8c0 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java @@ -4,6 +4,8 @@ package com.ruoyi.framework.config; import javax.servlet.http.HttpServletRequest; import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; /** @@ -14,13 +16,21 @@ import org.springframework.stereotype.Component; @Component public class ServerConfig { + + @Value("${ruoyi.server-url:}") + private String serverUrl; + /** * 获取完整的请求路径,包括:域名,端口,上下文访问路径 + * 优先使用配置的 ruoyi.server-url,未配置时从请求动态解析 * * @return 服务地址 */ public String getUrl() { + if (StringUtils.isNotEmpty(serverUrl)) { + return serverUrl; + } HttpServletRequest request = ServletUtils.getRequest(); return getDomain(request); } diff --git a/ruoyi-ui/src/views/rm/drawingDesign/index.vue b/ruoyi-ui/src/views/rm/drawingDesign/index.vue index 33e2959..7d7dc53 100644 --- a/ruoyi-ui/src/views/rm/drawingDesign/index.vue +++ b/ruoyi-ui/src/views/rm/drawingDesign/index.vue @@ -126,8 +126,9 @@ -
{{ selected ? '暂未上传文件' : '点击左侧图纸进行预览' }}
点击左侧文件进行预览
{{ selected ? '暂未上传文件' : '点击左侧文件进行预览' }}