web-component-gallery 2.3.25 → 2.3.27

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.
@@ -40,7 +40,9 @@ export const AmapDrawProps = {
40
40
  // 是否为纯展示模式(不显示控制按钮)
41
41
  isExhibition: PropTypes.bool.def(false),
42
42
  // 自定义绘制操作按钮
43
- drawButtonOperate: PropTypes.array
43
+ drawButtonOperate: PropTypes.array,
44
+ // 绘制时是否清除地图上的覆盖物
45
+ clearOnDraw: PropTypes.bool.def(true)
44
46
  }
45
47
 
46
48
  export default {
@@ -90,8 +92,8 @@ export default {
90
92
  // 监听绘制信息变化,当变化时重新渲染对应类型的绘制图层
91
93
  drawInfo: {
92
94
  handler(newVal) {
93
- newVal && this.echoDrawLayers(this.drawType)
94
- },
95
+ newVal && this.echoDrawLayers(this.drawType)
96
+ },
95
97
  deep: true
96
98
  },
97
99
  // 监听所有绘制信息变化,重新渲染全部绘制图层
@@ -217,8 +219,11 @@ export default {
217
219
 
218
220
  // 清除当前绘制的所有图层
219
221
  handleDrawClear() {
220
- // 清理地图上的所有覆盖物
221
- this.cleanOverlays()
222
+ // 根据配置决定是否清除之前的绘制内容
223
+ if (this.clearOnDraw) {
224
+ this.cleanOverlays()
225
+ }
226
+
222
227
  // 重置绘制图层数组
223
228
  this.drawLayers = null
224
229
  // 重置绘制图层信息
@@ -233,12 +238,16 @@ export default {
233
238
  }
234
239
  // 分配绘制图层信息
235
240
  this.assignDrawLayers(this.drawType)
241
+ // 触发保存事件
242
+ this.$emit('drawSave')
236
243
  },
237
244
 
238
245
  // 取消绘制操作
239
246
  handleDrawReset() {
240
247
  // 直接调用清除方法
241
248
  this.handleDrawClear()
249
+ // 触发取消事件
250
+ this.$emit('drawCancel')
242
251
  },
243
252
 
244
253
  // 处理搜索结果选择
@@ -4,6 +4,17 @@ import { IconFont } from '../index'
4
4
  // 引入文件处理工具函数:格式化数据、获取文件类型、预览文件
5
5
  import { formatFileData, getFileType, previewFile } from '../../utils/File'
6
6
 
7
+ import { Spin, Icon } from 'ant-design-vue'
8
+
9
+ // 默认显示加载器
10
+ Spin.setDefaultIndicator({
11
+ indicator: {
12
+ render() {
13
+ return <Icon type="loading" />
14
+ }
15
+ }
16
+ })
17
+
7
18
  const BrowseProps = {
8
19
  // 数据源,支持字符串、数组或对象,默认为空数组
9
20
  data: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]).def([]),
@@ -46,10 +57,12 @@ const renderContent = function (h, file, images) {
46
57
 
47
58
  if (!url) return
48
59
 
49
- const { isThumb, astrictH } = this
60
+ const { isThumb, astrictH, iframeLoadingState } = this
50
61
  const tag = getPreviewType(url)
51
62
  const isImage = tag === 'img'
52
63
  const isMedia = ['audio', 'video'].includes(tag)
64
+ const isIframe = tag === 'iframe'
65
+ const fileId = file.id || url // 使用唯一标识作为 key
53
66
 
54
67
  // 点击处理函数:如果是图片或缩略图模式,则触发预览
55
68
  const handleClick = () => {
@@ -69,9 +82,7 @@ const renderContent = function (h, file, images) {
69
82
  // 构建基础标签属性
70
83
  const attrs = {
71
84
  src: url,
72
- // 音视频和 iframe 显示控制条
73
- ...((isMedia || tag === 'iframe') && { controls: true }),
74
- // 音视频自动播放配置
85
+ ...((isMedia || isIframe) && { controls: true }),
75
86
  ...(isMedia && { autoplay: true, muted: true, playsinline: true })
76
87
  }
77
88
 
@@ -80,6 +91,28 @@ const renderContent = function (h, file, images) {
80
91
  ...(astrictH && { width: 'auto', height: `${astrictH}px` })
81
92
  }
82
93
 
94
+ // iframe 类型添加加载遮罩
95
+ if (isIframe) {
96
+
97
+ // 初始化加载状态(仅当该文件未记录状态时)
98
+ if (!(fileId in iframeLoadingState)) {
99
+ this.$set(this.iframeLoadingState, fileId, true)
100
+
101
+ // 超时兜底:5秒后强制关闭加载状态
102
+ setTimeout(() => {
103
+ if (this.iframeLoadingState[fileId]) {
104
+ this.$set(this.iframeLoadingState, fileId, false)
105
+ }
106
+ }, 5000)
107
+ }
108
+
109
+ const updateState = () => this.$set(this.iframeLoadingState, fileId, false)
110
+
111
+ return <Spin spinning={iframeLoadingState[fileId]} tip="加载中...">
112
+ <tag {...{ attrs, style }} onLoad={updateState} onError={updateState} />
113
+ </Spin>
114
+ }
115
+
83
116
  // 渲染实际的媒体标签
84
117
  return <tag {...{ attrs, style }} onClick={handleClick} />
85
118
  }
@@ -88,6 +121,18 @@ const renderContent = function (h, file, images) {
88
121
  const Browse = {
89
122
  name: 'Browse',
90
123
  props: BrowseProps,
124
+ data() {
125
+ return {
126
+ iframeLoadingState: {}
127
+ }
128
+ },
129
+ watch: {
130
+ // 数据源变化时重置所有加载状态
131
+ data: {
132
+ handler() { this.iframeLoadingState = {} },
133
+ deep: true
134
+ }
135
+ },
91
136
  render(h) {
92
137
  const { data, $https, httpsUrl } = this
93
138
  // 格式化文件数据,合并 HTTPS 配置
@@ -9,4 +9,20 @@ img {
9
9
  max-height: 100%;
10
10
  object-fit: contain;
11
11
  .square(auto);
12
+ }
13
+
14
+ .ant-spin-nested-loading,
15
+ .ant-spin-container {
16
+ .layout();
17
+ }
18
+
19
+ .ant-spin-nested-loading > div > .ant-spin {
20
+ .ant-spin-dot {
21
+ font-size: 48px;
22
+ }
23
+ .ant-spin-text.ant-spin-text {
24
+ top: 60%;
25
+ padding-left: 36px;
26
+ font-size: @font-size-lg;
27
+ }
12
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-component-gallery",
3
- "version": "2.3.25",
3
+ "version": "2.3.27",
4
4
  "description": "基础vue、antdvue、less实现的私有组件库",
5
5
  "main": "dist/index.umd.js",
6
6
  "files": [