feat(config): 添加服务器URL配置并优化文件预览功能

- 在 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 控制器和生命周期钩子函数
This commit is contained in:
jhd
2026-07-06 15:40:56 +08:00
parent 5544056833
commit 8bf4a6d861
8 changed files with 35 additions and 100 deletions

View File

@@ -1,3 +1,8 @@
--- # 本地开发环境覆盖
ruoyi:
profile: /home/wy/oa/uploadPath
server-url: http://localhost:8080
--- # 监控中心配置
spring.boot.admin.client:
# 增加客户端开关

View File

@@ -1,3 +1,7 @@
--- # 生产环境覆盖
ruoyi:
profile: /home/wy/oa/uploadPath
server-url: http://49.232.154.205:8080
--- # 监控中心配置
spring.boot.admin.client:

View File

@@ -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:
# 页面 <参数设置> 可开启关闭 验证码校验

View File

@@ -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);
}

View File

@@ -126,8 +126,9 @@
</el-collapse-item>
</el-collapse>
<!-- Viewer -->
<div class="viewer-area" ref="viewerContainer">
<div v-if="!selected || !selected.fileUrl" class="viewer-placeholder">
<div class="viewer-area">
<iframe v-if="selected && selected.fileUrl" :src="selected.fileUrl" style="width:100%;height:100%;border:0;" />
<div v-else class="viewer-placeholder">
<i class="el-icon-view" style="font-size:48px;color:#c0c4cc;"></i>
<p style="color:#909399;margin-top:8px;">{{ selected ? '暂未上传文件' : '点击左侧图纸进行预览' }}</p>
</div>
@@ -254,7 +255,6 @@ import { listProject } from '@/api/rm/project'
import { listFileReview, addFileReview } from '@/api/rm/fileReview'
import { listRmTask } from '@/api/oa/task'
import { getToken } from '@/utils/auth'
import { mountViewerFrame } from '@flyfish-group/file-viewer-web'
export default {
name: 'RmDrawingDesign',
@@ -274,7 +274,6 @@ export default {
uploadUrl: process.env.VUE_APP_BASE_API + '/common/upload',
uploadHeaders: { Authorization: 'Bearer ' + getToken() },
selected: null,
viewerCtrl: null,
collapseActive: [],
fileReviews: [],
rmTasks: [],
@@ -287,9 +286,6 @@ export default {
}
},
created() { this.loadCurrentProject() },
beforeDestroy() {
this.destroyViewer()
},
methods: {
loadRmTasks(projectId) {
if (!projectId) return
@@ -329,25 +325,8 @@ export default {
handlePageChange(val) { this.query.pageNum = val; this.loadList() },
handleRowClick(row) {
this.selected = row
this.$nextTick(() => {
this.mountPreview(row)
})
this.loadReviews('drawing_design', row.drawingId)
},
mountPreview(row) {
this.destroyViewer()
if (!row.fileUrl || !this.$refs.viewerContainer) return
this.viewerCtrl = mountViewerFrame(this.$refs.viewerContainer, {
url: row.fileUrl,
options: { theme: 'light' }
})
},
destroyViewer() {
if (this.viewerCtrl) {
this.viewerCtrl.destroy()
this.viewerCtrl = null
}
},
handleAdd() {
this.dialogTitle = '新增图纸'
if (!this.currentProjectId) { this.$message.warning('请先在项目总览中创建项目'); return }
@@ -368,7 +347,6 @@ export default {
delDrawingDesign(row.drawingId).then(() => {
this.$message.success('删除成功')
if (this.selected && this.selected.drawingId === row.drawingId) {
this.destroyViewer()
this.selected = null
this.fileReviews = []
}

View File

@@ -88,7 +88,9 @@
<el-button type="text" size="mini" icon="el-icon-download" style="margin-left:auto;" @click.stop="downloadFile(f)">下载</el-button>
</div>
<!-- Preview area (below attachments) -->
<div v-if="previewFile" class="attach-preview" ref="viewerContainer"></div>
<div v-if="previewFile" class="attach-preview">
<iframe :src="previewFile" style="width:100%;height:100%;border:0;" />
</div>
</div>
</div>
<!-- No selection -->
@@ -154,7 +156,6 @@
import { listInstallFeedbackAll, addInstallFeedback, updateInstallFeedback, delInstallFeedback } from '@/api/rm/installFeedback'
import { listProject } from '@/api/rm/project'
import { getToken } from '@/utils/auth'
import { mountViewerFrame } from '@flyfish-group/file-viewer-web'
export default {
name: 'RmInstallFeedback',
@@ -173,8 +174,7 @@ export default {
selected: null,
filterTitle: '',
filterStatus: '',
previewFile: null,
viewerCtrl: null
previewFile: null
}
},
computed: {
@@ -191,9 +191,6 @@ export default {
}
},
created() { this.loadCurrentProject() },
beforeDestroy() {
this.destroyViewer()
},
methods: {
statusTag(status) {
return { pending: 'warning', processing: 'primary', resolved: 'success' }[status] || ''
@@ -225,24 +222,9 @@ export default {
handleRowClick(row) {
this.selected = row
this.previewFile = null
this.destroyViewer()
},
previewAttachment(url) {
this.previewFile = url
this.$nextTick(() => {
this.destroyViewer()
if (!this.$refs.viewerContainer) return
this.viewerCtrl = mountViewerFrame(this.$refs.viewerContainer, {
url: url,
options: { theme: 'light' }
})
})
},
destroyViewer() {
if (this.viewerCtrl) {
this.viewerCtrl.destroy()
this.viewerCtrl = null
}
},
handleAdd() {
this.dialogTitle = '反馈问题'
@@ -274,7 +256,6 @@ export default {
this.$confirm('确认删除?', '提示', { type: 'warning' }).then(() => {
delInstallFeedback(row.feedbackId).then(() => {
if (this.selected && this.selected.feedbackId === row.feedbackId) {
this.destroyViewer()
this.selected = null
this.previewFile = null
}

View File

@@ -138,8 +138,9 @@
</el-collapse-item>
</el-collapse>
<!-- Viewer -->
<div class="viewer-area" ref="viewerContainer">
<div v-if="!selectedFile || !selectedFile.fileUrl" class="viewer-placeholder">
<div class="viewer-area">
<iframe v-if="selectedFile && selectedFile.fileUrl" :src="selectedFile.fileUrl" style="width:100%;height:100%;border:0;" />
<div v-else class="viewer-placeholder">
<i class="el-icon-view" style="font-size:48px;color:#c0c4cc;"></i>
<p style="color:#909399;margin-top:8px;">点击左侧文件进行预览</p>
</div>
@@ -242,7 +243,6 @@ import { listProject } from '@/api/rm/project'
import { listFileReview, addFileReview } from '@/api/rm/fileReview'
import { listRmTask } from '@/api/oa/task'
import { getToken } from '@/utils/auth'
import { mountViewerFrame } from '@flyfish-group/file-viewer-web'
export default {
name: 'RmLayoutFile',
@@ -262,7 +262,6 @@ export default {
uploadUrl: process.env.VUE_APP_BASE_API + '/common/upload',
uploadHeaders: { Authorization: 'Bearer ' + getToken() },
selectedFile: null,
viewerCtrl: null,
collapseActive: [],
fileReviews: [],
rmTasks: [],
@@ -275,9 +274,6 @@ export default {
}
},
created() { this.loadCurrentProject() },
beforeDestroy() {
this.destroyViewer()
},
methods: {
loadCurrentProject() {
const pid = this.$route.query.projectId || sessionStorage.getItem('rm_current_project_id')
@@ -317,9 +313,6 @@ export default {
handlePageChange(val) { this.query.pageNum = val; this.loadList() },
handleRowClick(row) {
this.selectedFile = row
this.$nextTick(() => {
this.mountPreview(row)
})
this.loadReviews('layout', row.layoutFileId)
},
loadReviews(fileModule, fileId) {
@@ -328,20 +321,6 @@ export default {
this.fileReviews = res.data || []
})
},
mountPreview(row) {
this.destroyViewer()
if (!row.fileUrl || !this.$refs.viewerContainer) return
this.viewerCtrl = mountViewerFrame(this.$refs.viewerContainer, {
url: row.fileUrl,
options: { theme: 'light' }
})
},
destroyViewer() {
if (this.viewerCtrl) {
this.viewerCtrl.destroy()
this.viewerCtrl = null
}
},
handleAdd() {
this.dialogTitle = '新增布局图'
if (!this.currentProjectId) { this.$message.warning('请先在项目总览中创建项目'); return }
@@ -362,7 +341,6 @@ export default {
delLayoutFile(row.layoutFileId).then(() => {
this.$message.success('删除成功')
if (this.selectedFile && this.selectedFile.layoutFileId === row.layoutFileId) {
this.destroyViewer()
this.selectedFile = null
this.fileReviews = []
}

View File

@@ -88,8 +88,9 @@
</el-collapse-item>
</el-collapse>
<!-- Viewer -->
<div class="viewer-area" ref="viewerContainer">
<div v-if="!selected || !selected.fileUrl" class="viewer-placeholder">
<div class="viewer-area">
<iframe v-if="selected && selected.fileUrl" :src="selected.fileUrl" style="width:100%;height:100%;border:0;" />
<div v-else class="viewer-placeholder">
<i class="el-icon-view" style="font-size:48px;color:#c0c4cc;"></i>
<p style="color:#909399;margin-top:8px;">{{ selected ? '暂未上传文件' : '点击左侧文件进行预览' }}</p>
</div>
@@ -168,7 +169,6 @@ import { listProject } from '@/api/rm/project'
import { listFileReview, addFileReview } from '@/api/rm/fileReview'
import { listRmTask } from '@/api/oa/task'
import { getToken } from '@/utils/auth'
import { mountViewerFrame } from '@flyfish-group/file-viewer-web'
export default {
name: 'RmManual',
@@ -186,7 +186,6 @@ export default {
uploadUrl: process.env.VUE_APP_BASE_API + '/common/upload',
uploadHeaders: { Authorization: 'Bearer ' + getToken() },
selected: null,
viewerCtrl: null,
collapseActive: [],
fileReviews: [],
rmTasks: [],
@@ -210,9 +209,6 @@ export default {
}
},
created() { this.loadCurrentProject() },
beforeDestroy() {
this.destroyViewer()
},
methods: {
tagType(type) {
return { '说明书': 'primary', '图纸': 'success', '维护手册': 'warning', '备件清单': 'info' }[type] || ''
@@ -240,25 +236,8 @@ export default {
clearFilter() { this.filterName = ''; this.filterType = '' },
handleRowClick(row) {
this.selected = row
this.$nextTick(() => {
this.mountPreview(row)
})
this.loadReviews('manual', row.manualId)
},
mountPreview(row) {
this.destroyViewer()
if (!row.fileUrl || !this.$refs.viewerContainer) return
this.viewerCtrl = mountViewerFrame(this.$refs.viewerContainer, {
url: row.fileUrl,
options: { theme: 'light' }
})
},
destroyViewer() {
if (this.viewerCtrl) {
this.viewerCtrl.destroy()
this.viewerCtrl = null
}
},
handleAdd() {
this.dialogTitle = '上传说明书/图纸'
this.form = { manualName: '', docType: '说明书', version: 'V1.0', uploadDate: new Date().toISOString().slice(0, 10), fileUrl: '', description: '' }
@@ -281,7 +260,6 @@ export default {
this.$confirm('确认删除?', '提示', { type: 'warning' }).then(() => {
delManual(row.manualId).then(() => {
if (this.selected && this.selected.manualId === row.manualId) {
this.destroyViewer()
this.selected = null
this.fileReviews = []
}