web-component-gallery 2.3.11 → 2.3.12

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.
@@ -37,11 +37,13 @@ const getPreviewType = (url, contentType = '') => {
37
37
  /**
38
38
  * 渲染单个文件内容的函数
39
39
  * @param {function} h - Vue 的渲染函数
40
- * @param {object} param1 - 包含 url 和 name 的对象
40
+ * @param {object} file - 文件对象
41
41
  * @param {array} images - 图片列表,用于预览
42
42
  * @returns {VNode} 返回渲染的虚拟 DOM 节点
43
43
  */
44
- const renderContent = function (h, { url, name }, images) {
44
+ const renderContent = function (h, file, images) {
45
+ const { url, name } = file
46
+
45
47
  if (!url) return
46
48
 
47
49
  const { isThumb, astrictH } = this
@@ -51,7 +53,7 @@ const renderContent = function (h, { url, name }, images) {
51
53
 
52
54
  // 点击处理函数:如果是图片或缩略图模式,则触发预览
53
55
  const handleClick = () => {
54
- if (isImage || isThumb) previewFile(url, images, this)
56
+ if (isImage || isThumb) previewFile(file, images, this)
55
57
  }
56
58
 
57
59
  // 如果是非图片且处于缩略图模式,渲染带图标的占位符
@@ -96,9 +96,21 @@ const DescriptionsList = {
96
96
  if (this.isResponsive) {
97
97
  this.setDescContentWidth()
98
98
  this.bindResize()
99
- } else {
100
- this.responsiveColumn = this.getColumnValue()
99
+ return
100
+ }
101
+ this.responsiveColumn = this.getColumnValue()
102
+ },
103
+ initComponent() {
104
+ if (this.isResponsive) {
105
+ this.setDescContentWidth()
106
+ this.bindResize()
107
+ return
101
108
  }
109
+ this.responsiveColumn = this.getColumnValue()
110
+ this.$nextTick(() => {
111
+ const container = this.$refs.Descriptions
112
+ if (container) this.updateItemStyles(container, container.offsetWidth)
113
+ })
102
114
  },
103
115
 
104
116
  // 清理窗口大小监听和定时器
@@ -107,12 +119,11 @@ const DescriptionsList = {
107
119
  clearTimeout(this.resizeTimer)
108
120
  this.resizeTimer = null
109
121
  }
110
- window.removeEventListener('resize', this.handleResize)
111
122
  },
112
123
 
113
124
  // 绑定窗口大小变化事件
114
125
  bindResize() {
115
- window.addEventListener('resize', this.handleResize)
126
+ this.$bus.$onWindow(this, 'resize', this.handleResize)
116
127
  },
117
128
 
118
129
  // 处理窗口大小变化(带防抖)
@@ -157,8 +168,6 @@ const DescriptionsList = {
157
168
 
158
169
  // 更新每一项的标签和内容宽度样式
159
170
  updateItemStyles(container, totalWidth) {
160
- if (!this.isResponsive) return
161
-
162
171
  this.$nextTick(() => {
163
172
  const rows = container.querySelectorAll('.ant-descriptions-row')
164
173
  let itemCount = 0
@@ -170,6 +179,7 @@ const DescriptionsList = {
170
179
  labels.forEach((label, index) => {
171
180
  const itemConfig = this.descSettings[itemCount]
172
181
  const span = itemConfig?.span || 1
182
+
173
183
  // 计算每项总宽度和内容区域宽度
174
184
  const eachWidth = (totalWidth / this.responsiveColumn) * span
175
185
  const contentWidth = eachWidth - this.labelWidth
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-component-gallery",
3
- "version": "2.3.11",
3
+ "version": "2.3.12",
4
4
  "description": "基础vue、antdvue、less实现的私有组件库",
5
5
  "main": "dist/index.umd.js",
6
6
  "files": [