@ganwei-web/gw-base-components-plus 1.0.59 → 1.0.61
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.
|
@@ -23,6 +23,11 @@ export default {
|
|
|
23
23
|
type: String,
|
|
24
24
|
default: ''
|
|
25
25
|
},
|
|
26
|
+
// 文件存储 ID(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
|
+
// 从文件名中截取扩展名(小写,不含点号)
|
|
59
|
+
fileExt() {
|
|
60
|
+
const name = this.filename
|
|
61
|
+
const idx = name.lastIndexOf('.')
|
|
62
|
+
return idx > -1 ? name.substring(idx + 1).toLowerCase() : ''
|
|
52
63
|
}
|
|
53
64
|
},
|
|
54
65
|
methods: {
|
|
@@ -61,8 +72,38 @@ export default {
|
|
|
61
72
|
return 'https://fileview.ganweicloud.com/'
|
|
62
73
|
}
|
|
63
74
|
},
|
|
75
|
+
// 获取 index 应用地址(CAD 预览页由 index 应用承载)
|
|
76
|
+
getIndexHost() {
|
|
77
|
+
try {
|
|
78
|
+
return window.top.location.origin + window.top.location.pathname
|
|
79
|
+
} catch (e) {
|
|
80
|
+
try {
|
|
81
|
+
const map = JSON.parse(localStorage.getItem('hostMap') || '{}')
|
|
82
|
+
if (map['ganwei-iotcenter-index']) return map['ganwei-iotcenter-index']
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.warn(err)
|
|
85
|
+
}
|
|
86
|
+
return window.location.origin
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
// 在新标签页中打开文件预览(dwg/dxf 走 index 应用的 filepreview 页面)
|
|
90
|
+
openFilePreview(storageFileId) {
|
|
91
|
+
if (!storageFileId) {
|
|
92
|
+
console.error('[file-preview] storageFileId 不能为空')
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
const indexHost = this.getIndexHost().replace(/\/+$/, '')
|
|
96
|
+
console.log('indexHost',indexHost)
|
|
97
|
+
const previewUrl = `${indexHost}/#/filepreview?storageFileId=${encodeURIComponent(storageFileId)}`
|
|
98
|
+
window.open(previewUrl, '_blank')
|
|
99
|
+
},
|
|
64
100
|
// 预览:使用预览服务器打开文件
|
|
65
101
|
handlePreview() {
|
|
102
|
+
// CAD 文件:走 filepreview 页预览(内部 token 下载 + MlightCadViewer 渲染)
|
|
103
|
+
if ((this.fileExt === 'dwg' || this.fileExt === 'dxf') && this.storageFileId) {
|
|
104
|
+
this.openFilePreview(this.storageFileId)
|
|
105
|
+
return
|
|
106
|
+
}
|
|
66
107
|
const domain = this.getPreviewDomain().replace(/\/+$/, '') || ''
|
|
67
108
|
if (!domain) {
|
|
68
109
|
console.warn('[file-preview] 未配置预览服务域名')
|