web-component-gallery 2.3.10 → 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.
- package/dist/js.umd.js +1 -1
- package/lib/browse/index.jsx +5 -3
- package/lib/descriptions-list/index.jsx +16 -6
- package/lib/modal/index.jsx +11 -5
- package/lib/modal/style/index.less +10 -0
- package/package.json +1 -1
package/lib/browse/index.jsx
CHANGED
|
@@ -37,11 +37,13 @@ const getPreviewType = (url, contentType = '') => {
|
|
|
37
37
|
/**
|
|
38
38
|
* 渲染单个文件内容的函数
|
|
39
39
|
* @param {function} h - Vue 的渲染函数
|
|
40
|
-
* @param {object}
|
|
40
|
+
* @param {object} file - 文件对象
|
|
41
41
|
* @param {array} images - 图片列表,用于预览
|
|
42
42
|
* @returns {VNode} 返回渲染的虚拟 DOM 节点
|
|
43
43
|
*/
|
|
44
|
-
const renderContent = function (h,
|
|
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(
|
|
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
|
-
|
|
100
|
-
|
|
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
|
-
|
|
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/lib/modal/index.jsx
CHANGED
|
@@ -2,6 +2,9 @@ import PropTypes from 'ant-design-vue/es/_util/vue-types'
|
|
|
2
2
|
import { Modal } from 'ant-design-vue/es'
|
|
3
3
|
import IconFont from '../icon-font'
|
|
4
4
|
|
|
5
|
+
const MODAL_MODES = ['small', 'middle', 'large', 'max']
|
|
6
|
+
const HEADLESS_MODES = ['screen', 'headless-large']
|
|
7
|
+
|
|
5
8
|
const ModalProps = {
|
|
6
9
|
size: PropTypes.string.def('small'),
|
|
7
10
|
title: PropTypes.string.def('标题'),
|
|
@@ -14,7 +17,6 @@ const ModalComp = {
|
|
|
14
17
|
props: ModalProps,
|
|
15
18
|
data() {
|
|
16
19
|
return {
|
|
17
|
-
modalModes: ['small', 'middle', 'large', 'max'],
|
|
18
20
|
internalMode: this.size
|
|
19
21
|
}
|
|
20
22
|
},
|
|
@@ -28,9 +30,13 @@ const ModalComp = {
|
|
|
28
30
|
window.open(this.$attrs.externalLink, '_blank')
|
|
29
31
|
},
|
|
30
32
|
handleConvert() {
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
33
|
+
const normalizedMode = this.internalMode === 'headless-large' ? 'large' : this.internalMode
|
|
34
|
+
const currentIndex = MODAL_MODES.indexOf(normalizedMode)
|
|
35
|
+
const isLastMode = currentIndex === MODAL_MODES.length - 1
|
|
36
|
+
this.internalMode = isLastMode ? this.size : MODAL_MODES[currentIndex + 1]
|
|
37
|
+
},
|
|
38
|
+
hasTitleBar() {
|
|
39
|
+
return !HEADLESS_MODES.includes(this.size)
|
|
34
40
|
}
|
|
35
41
|
},
|
|
36
42
|
render() {
|
|
@@ -53,7 +59,7 @@ const ModalComp = {
|
|
|
53
59
|
...this.$listeners
|
|
54
60
|
}}
|
|
55
61
|
>
|
|
56
|
-
{this.
|
|
62
|
+
{this.hasTitleBar() && (
|
|
57
63
|
<div slot="title" class="AntModal__Title">
|
|
58
64
|
<span>{this.title}</span>
|
|
59
65
|
<div class="AntModal__Title__Blank">
|