@ganwei-web/gw-base-components-plus 1.0.60 → 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,7 +23,7 @@ export default {
|
|
|
23
23
|
type: String,
|
|
24
24
|
default: ''
|
|
25
25
|
},
|
|
26
|
-
// 文件存储 ID(
|
|
26
|
+
// 文件存储 ID(dwg/dxf 走 filepreview 页预览时使用)
|
|
27
27
|
storageFileId: {
|
|
28
28
|
type: String,
|
|
29
29
|
default: ''
|
|
@@ -55,11 +55,11 @@ export default {
|
|
|
55
55
|
return raw
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
-
//
|
|
59
|
-
|
|
58
|
+
// 从文件名中截取扩展名(小写,不含点号)
|
|
59
|
+
fileExt() {
|
|
60
60
|
const name = this.filename
|
|
61
|
-
|
|
62
|
-
return name.substring(
|
|
61
|
+
const idx = name.lastIndexOf('.')
|
|
62
|
+
return idx > -1 ? name.substring(idx + 1).toLowerCase() : ''
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
methods: {
|
|
@@ -72,29 +72,36 @@ export default {
|
|
|
72
72
|
return 'https://fileview.ganweicloud.com/'
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
-
// 获取 index
|
|
75
|
+
// 获取 index 应用地址(CAD 预览页由 index 应用承载)
|
|
76
76
|
getIndexHost() {
|
|
77
77
|
try {
|
|
78
|
-
|
|
79
|
-
return hostMap['ganwei-iotcenter-index'] || window.location.origin
|
|
78
|
+
return window.top.location.origin + window.top.location.pathname
|
|
80
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
|
+
}
|
|
81
86
|
return window.location.origin
|
|
82
87
|
}
|
|
83
88
|
},
|
|
84
|
-
//
|
|
85
|
-
openFilePreview() {
|
|
86
|
-
if (!
|
|
89
|
+
// 在新标签页中打开文件预览(dwg/dxf 走 index 应用的 filepreview 页面)
|
|
90
|
+
openFilePreview(storageFileId) {
|
|
91
|
+
if (!storageFileId) {
|
|
87
92
|
console.error('[file-preview] storageFileId 不能为空')
|
|
88
93
|
return
|
|
89
94
|
}
|
|
90
|
-
const
|
|
95
|
+
const indexHost = this.getIndexHost().replace(/\/+$/, '')
|
|
96
|
+
console.log('indexHost',indexHost)
|
|
97
|
+
const previewUrl = `${indexHost}/#/filepreview?storageFileId=${encodeURIComponent(storageFileId)}`
|
|
91
98
|
window.open(previewUrl, '_blank')
|
|
92
99
|
},
|
|
93
100
|
// 预览:使用预览服务器打开文件
|
|
94
101
|
handlePreview() {
|
|
95
|
-
// CAD
|
|
96
|
-
if (this.
|
|
97
|
-
this.openFilePreview()
|
|
102
|
+
// CAD 文件:走 filepreview 页预览(内部 token 下载 + MlightCadViewer 渲染)
|
|
103
|
+
if ((this.fileExt === 'dwg' || this.fileExt === 'dxf') && this.storageFileId) {
|
|
104
|
+
this.openFilePreview(this.storageFileId)
|
|
98
105
|
return
|
|
99
106
|
}
|
|
100
107
|
const domain = this.getPreviewDomain().replace(/\/+$/, '') || ''
|
|
@@ -125,7 +132,6 @@ export default {
|
|
|
125
132
|
|
|
126
133
|
<style scoped>
|
|
127
134
|
.file-preview {
|
|
128
|
-
width: 100%;
|
|
129
135
|
display: inline-flex;
|
|
130
136
|
align-items: center;
|
|
131
137
|
gap: 4px;
|
|
@@ -135,6 +141,7 @@ export default {
|
|
|
135
141
|
overflow: hidden;
|
|
136
142
|
text-overflow: ellipsis;
|
|
137
143
|
white-space: nowrap;
|
|
144
|
+
max-width: 200px;
|
|
138
145
|
margin-right: 12px;
|
|
139
146
|
line-height: 16px;
|
|
140
147
|
}
|