@ganwei-web/gw-base-components-plus 1.0.59 → 1.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/file-preview/filePreview.vue +35 -1
- package/package.json +1 -1
|
@@ -23,6 +23,11 @@ export default {
|
|
|
23
23
|
type: String,
|
|
24
24
|
default: ''
|
|
25
25
|
},
|
|
26
|
+
// 文件存储 ID(CAD 文件 dwg/dxf 预览时跳转 filepreview 路由使用)
|
|
27
|
+
storageFileId: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: ''
|
|
30
|
+
},
|
|
26
31
|
// 是否显示预览按钮
|
|
27
32
|
isPreview: {
|
|
28
33
|
type: Boolean,
|
|
@@ -49,6 +54,12 @@ export default {
|
|
|
49
54
|
} catch (e) {
|
|
50
55
|
return raw
|
|
51
56
|
}
|
|
57
|
+
},
|
|
58
|
+
// 从 url 提取文件扩展名(小写,不含点号)
|
|
59
|
+
fileExtension() {
|
|
60
|
+
const name = this.filename
|
|
61
|
+
if (!name || !name.includes('.')) return ''
|
|
62
|
+
return name.substring(name.lastIndexOf('.') + 1).toLowerCase()
|
|
52
63
|
}
|
|
53
64
|
},
|
|
54
65
|
methods: {
|
|
@@ -61,8 +72,31 @@ export default {
|
|
|
61
72
|
return 'https://fileview.ganweicloud.com/'
|
|
62
73
|
}
|
|
63
74
|
},
|
|
75
|
+
// 获取 index 主框架站点地址(filepreview 路由部署在 index 包)
|
|
76
|
+
getIndexHost() {
|
|
77
|
+
try {
|
|
78
|
+
const hostMap = JSON.parse(localStorage.getItem('hostMap') || '{}')
|
|
79
|
+
return hostMap['ganwei-iotcenter-index'] || window.location.origin
|
|
80
|
+
} catch (e) {
|
|
81
|
+
return window.location.origin
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
// CAD 文件预览:跳转到 index 的 filepreview 路由
|
|
85
|
+
openFilePreview() {
|
|
86
|
+
if (!this.storageFileId) {
|
|
87
|
+
console.error('[file-preview] storageFileId 不能为空')
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
const previewUrl = `${this.getIndexHost().replace(/\/+$/, '')}/#/filepreview?storageFileId=${encodeURIComponent(this.storageFileId)}`
|
|
91
|
+
window.open(previewUrl, '_blank')
|
|
92
|
+
},
|
|
64
93
|
// 预览:使用预览服务器打开文件
|
|
65
94
|
handlePreview() {
|
|
95
|
+
// CAD 文件(dwg/dxf):单独走 index 的 filepreview 路由(LibreDwg + MlightCadViewer 渲染)
|
|
96
|
+
if (this.fileExtension === 'dwg' || this.fileExtension === 'dxf') {
|
|
97
|
+
this.openFilePreview()
|
|
98
|
+
return
|
|
99
|
+
}
|
|
66
100
|
const domain = this.getPreviewDomain().replace(/\/+$/, '') || ''
|
|
67
101
|
if (!domain) {
|
|
68
102
|
console.warn('[file-preview] 未配置预览服务域名')
|
|
@@ -91,6 +125,7 @@ export default {
|
|
|
91
125
|
|
|
92
126
|
<style scoped>
|
|
93
127
|
.file-preview {
|
|
128
|
+
width: 100%;
|
|
94
129
|
display: inline-flex;
|
|
95
130
|
align-items: center;
|
|
96
131
|
gap: 4px;
|
|
@@ -100,7 +135,6 @@ export default {
|
|
|
100
135
|
overflow: hidden;
|
|
101
136
|
text-overflow: ellipsis;
|
|
102
137
|
white-space: nowrap;
|
|
103
|
-
max-width: 200px;
|
|
104
138
|
margin-right: 12px;
|
|
105
139
|
line-height: 16px;
|
|
106
140
|
}
|