v-uni-app-ui 1.0.4 → 1.0.7
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/README.md +62 -82
- package/dist/v-uni-app-ui.css +1 -0
- package/dist/v-uni-app-ui.es.js +6569 -0
- package/dist/v-uni-app-ui.umd.js +7 -0
- package/package.json +17 -5
- package/components/config/css/basic.scss +0 -19
- package/components/config/interface/basic-type.js +0 -16
- package/components/config/interface/components-interface.ts +0 -0
- package/components/config/interface/monitor/components/input-monitor.js +0 -0
- package/components/config/interface/monitor/property-monitor.ts +0 -136
- package/components/config/interface/props/basic-props.ts +0 -88
- package/components/config/interface/props/components/button-props.ts +0 -85
- package/components/config/interface/props/components/input-props.ts +0 -69
- package/components/config/interface/props/props-tools.ts +0 -64
- package/components/config/style/basic.js +0 -346
- package/components/config/style/component-registry.js +0 -142
- package/components/config/style/components/button-style.js +0 -160
- package/components/config/style/components/input-style.js +0 -98
- package/components/config/style/components-style.js +0 -622
- package/components/config/style/property-mapper.js +0 -377
- package/components/config/style/pseudo-processor.js +0 -213
- package/components/config.js +0 -123
- package/components/icon/iconfont.css +0 -87
- package/components/icon/iconfont.js +0 -1
- package/components/icon/iconfont.json +0 -135
- package/components/icon/iconfont.ttf +0 -0
- package/components/icon/iconfont.woff +0 -0
- package/components/icon/iconfont.woff2 +0 -0
- package/components/layout/v-card/v-card.vue +0 -108
- package/components/layout/v-grid/v-grid.vue +0 -162
- package/components/layout/v-icon-grid/v-icon-grid.vue +0 -195
- package/components/layout/v-infinite-scroll/v-infinite-scroll.vue +0 -172
- package/components/layout/v-list/v-list.vue +0 -43
- package/components/layout/v-row/v-row.vue +0 -142
- package/components/layout/v-waterfall/v-waterfall.vue +0 -79
- package/components/model/compound/v-checkbox-group/v-checkbox-group.vue +0 -96
- package/components/model/compound/v-console/v-console.js +0 -20
- package/components/model/compound/v-console/v-console.vue +0 -299
- package/components/model/compound/v-date-time/v-date-time.vue +0 -261
- package/components/model/compound/v-dialog/v-dialog.vue +0 -178
- package/components/model/compound/v-drum-select-picker/v-drum-select-picker.vue +0 -83
- package/components/model/compound/v-form/v-form.vue +0 -226
- package/components/model/compound/v-form-item/v-form-item.vue +0 -255
- package/components/model/compound/v-image/v-image.vue +0 -357
- package/components/model/compound/v-input-desensitize/v-input-desensitize.vue +0 -101
- package/components/model/compound/v-page/v-page.vue +0 -11
- package/components/model/compound/v-pages/v-pages.vue +0 -141
- package/components/model/compound/v-picker-list/v-picker-list.vue +0 -109
- package/components/model/compound/v-popup/v-popup.vue +0 -151
- package/components/model/compound/v-radio-group/v-radio-group.vue +0 -86
- package/components/model/compound/v-select-picker/v-select-picker.vue +0 -202
- package/components/model/compound/v-series-picker-list/v-series-picker-list.vue +0 -221
- package/components/model/compound/v-series-select-picker/v-series-select-picker.vue +0 -203
- package/components/model/compound/v-switch/v-switch.vue +0 -136
- package/components/model/compound/v-tabs-page/v-tabs-page.vue +0 -138
- package/components/model/native/v-badge/v-badge.vue +0 -143
- package/components/model/native/v-button/v-button.vue +0 -81
- package/components/model/native/v-carousel/v-carousel.vue +0 -138
- package/components/model/native/v-checkbox/v-checkbox.vue +0 -215
- package/components/model/native/v-collapse/v-collapse.vue +0 -190
- package/components/model/native/v-header-navigation-bar/v-header-navigation-bar.vue +0 -92
- package/components/model/native/v-input/v-input.vue +0 -163
- package/components/model/native/v-input-code/v-input-code.vue +0 -146
- package/components/model/native/v-loading/v-loading.vue +0 -206
- package/components/model/native/v-menu/v-menu.vue +0 -222
- package/components/model/native/v-menu-slide/v-menu-slide.vue +0 -364
- package/components/model/native/v-min-loading/v-min-loading.vue +0 -80
- package/components/model/native/v-null/v-null.vue +0 -97
- package/components/model/native/v-overlay/v-overlay.vue +0 -96
- package/components/model/native/v-pull-up-refresh/v-pull-up-refresh.vue +0 -157
- package/components/model/native/v-radio/v-radio.vue +0 -138
- package/components/model/native/v-scroll-list/v-scroll-list.vue +0 -169
- package/components/model/native/v-steps/v-steps.vue +0 -253
- package/components/model/native/v-table/v-table.vue +0 -203
- package/components/model/native/v-tabs/v-tabs.vue +0 -235
- package/components/model/native/v-tag/v-tag.vue +0 -206
- package/components/model/native/v-text/v-text.vue +0 -187
- package/components/model/native/v-textarea/v-textarea.vue +0 -178
- package/components/model/native/v-title/v-title.vue +0 -91
- package/components/model/native/v-toast/info.png +0 -0
- package/components/model/native/v-toast/success.png +0 -0
- package/components/model/native/v-toast/v-toast.vue +0 -198
- package/components/model/native/v-toast/warn.png +0 -0
- package/components/model/native/v-upload-file-button/v-upload-file-button.vue +0 -296
- package/components/model/native/v-video/v-video.vue +0 -175
- package/components/model/native/v-window/v-window.vue +0 -158
- package/components/utils/event-modifiers.ts +0 -139
- package/components/utils/validator.ts +0 -451
- package/index.js +0 -372
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="v-icon-grid">
|
|
3
|
-
<scroll-view class="scroll-container" :scroll-x="scrollable" :show-scrollbar="false" :scroll-with-animation="true">
|
|
4
|
-
<view class="icon-grid" :style="{ 'grid-template-columns': `repeat(${columns}, 1fr)` }">
|
|
5
|
-
<view
|
|
6
|
-
v-for="(icon, index) in icons"
|
|
7
|
-
:key="index"
|
|
8
|
-
class="icon-item"
|
|
9
|
-
:class="{ 'icon-item-active': activeIndex === index }"
|
|
10
|
-
@click="handleIconClick(index)"
|
|
11
|
-
:style="{
|
|
12
|
-
width: typeof itemWidth === 'string' ? itemWidth : `${itemWidth}px`,
|
|
13
|
-
margin: typeof gutter === 'string' ? `calc(${gutter} / 2)` : `${gutter / 2}px`
|
|
14
|
-
}"
|
|
15
|
-
>
|
|
16
|
-
<view class="icon-wrapper">
|
|
17
|
-
<view class="icon" :style="{ 'font-size': fontSize }">
|
|
18
|
-
<text v-if="useIcon" :class="icon.icon"></text>
|
|
19
|
-
<v-image v-else :src="icon.image" :style="{ width: iconSize, height: iconSize }" />
|
|
20
|
-
</view>
|
|
21
|
-
</view>
|
|
22
|
-
<view
|
|
23
|
-
class="icon-text"
|
|
24
|
-
:style="{
|
|
25
|
-
color: textColor,
|
|
26
|
-
...textStyle
|
|
27
|
-
}"
|
|
28
|
-
>
|
|
29
|
-
{{ icon.title }}
|
|
30
|
-
</view>
|
|
31
|
-
</view>
|
|
32
|
-
</view>
|
|
33
|
-
</scroll-view>
|
|
34
|
-
</view>
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<script lang="ts" setup>
|
|
38
|
-
import { ref, computed, inject } from 'vue';
|
|
39
|
-
|
|
40
|
-
interface IconItem {
|
|
41
|
-
title: string;
|
|
42
|
-
icon?: string;
|
|
43
|
-
image?: string;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* v-icon-grid 图标排版
|
|
47
|
-
* icons : 图标数组 title标题 icon图标类名 image图片路径
|
|
48
|
-
* iconSize 图标大小
|
|
49
|
-
* textColor 文本颜色
|
|
50
|
-
* activeColor 活动图标颜色
|
|
51
|
-
* itemWidth 每个图标项的宽度
|
|
52
|
-
* gutter 图标项之间的间距
|
|
53
|
-
* scrollable 是否可滚动 默认值:true滚动 可选值:true滚动 false不滚动
|
|
54
|
-
* useIcon 图标还是图片 默认值:true图标 可选值:true图标 false图片
|
|
55
|
-
* rows 图片排数 默认值:1
|
|
56
|
-
*/
|
|
57
|
-
const props = defineProps({
|
|
58
|
-
icons: {
|
|
59
|
-
type: Array as () => IconItem[],
|
|
60
|
-
default: () => []
|
|
61
|
-
},
|
|
62
|
-
iconSize: {
|
|
63
|
-
type: String,
|
|
64
|
-
default: '50rpx'
|
|
65
|
-
},
|
|
66
|
-
fontSize: {
|
|
67
|
-
type: String,
|
|
68
|
-
default: '25rpx'
|
|
69
|
-
},
|
|
70
|
-
textColor: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: '#333333'
|
|
73
|
-
},
|
|
74
|
-
activeColor: {
|
|
75
|
-
type: String,
|
|
76
|
-
default: 'transparent'
|
|
77
|
-
},
|
|
78
|
-
itemWidth: {
|
|
79
|
-
type: [Number, String],
|
|
80
|
-
default: 80
|
|
81
|
-
},
|
|
82
|
-
gutter: {
|
|
83
|
-
type: [Number, String],
|
|
84
|
-
default: 10
|
|
85
|
-
},
|
|
86
|
-
scrollable: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
default: true
|
|
89
|
-
},
|
|
90
|
-
useIcon: {
|
|
91
|
-
type: Boolean,
|
|
92
|
-
default: true
|
|
93
|
-
},
|
|
94
|
-
rows: {
|
|
95
|
-
type: Number,
|
|
96
|
-
default: 1
|
|
97
|
-
},
|
|
98
|
-
iconTextModel: {
|
|
99
|
-
type: String as () => 'normal' | 'wrap' | 'ellipsis',
|
|
100
|
-
default: 'normal'
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const emits = defineEmits(['select']);
|
|
105
|
-
const config = inject<any>('config');
|
|
106
|
-
|
|
107
|
-
const activeIndex = ref(0);
|
|
108
|
-
const columns = computed(() => {
|
|
109
|
-
const totalIcons = props.icons.length;
|
|
110
|
-
const maxIconsPerRow = Math.ceil(totalIcons / props.rows);
|
|
111
|
-
return maxIconsPerRow;
|
|
112
|
-
});
|
|
113
|
-
const textStyle = computed(() => {
|
|
114
|
-
switch (props.iconTextModel) {
|
|
115
|
-
case 'wrap':
|
|
116
|
-
return {
|
|
117
|
-
whiteSpace: 'normal',
|
|
118
|
-
overflow: 'visible',
|
|
119
|
-
textOverflow: 'clip'
|
|
120
|
-
};
|
|
121
|
-
case 'ellipsis':
|
|
122
|
-
return {
|
|
123
|
-
whiteSpace: 'nowrap',
|
|
124
|
-
overflow: 'hidden',
|
|
125
|
-
textOverflow: 'ellipsis'
|
|
126
|
-
};
|
|
127
|
-
default: // normal
|
|
128
|
-
return {
|
|
129
|
-
whiteSpace: 'normal',
|
|
130
|
-
overflow: 'visible',
|
|
131
|
-
textOverflow: 'clip'
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
const handleIconClick = (index: number) => {
|
|
137
|
-
activeIndex.value = index;
|
|
138
|
-
emits('select', index, props.icons[index]);
|
|
139
|
-
};
|
|
140
|
-
</script>
|
|
141
|
-
|
|
142
|
-
<style lang="scss" scoped>
|
|
143
|
-
.v-icon-grid {
|
|
144
|
-
width: 100%;
|
|
145
|
-
position: relative;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.scroll-container {
|
|
149
|
-
width: 100%;
|
|
150
|
-
white-space: nowrap;
|
|
151
|
-
overflow: hidden;
|
|
152
|
-
flex: 1;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.icon-grid {
|
|
156
|
-
display: grid;
|
|
157
|
-
gap: 10rpx;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.icon-item {
|
|
161
|
-
display: flex;
|
|
162
|
-
flex-direction: column;
|
|
163
|
-
align-items: center;
|
|
164
|
-
justify-content: center;
|
|
165
|
-
border-radius: 10rpx;
|
|
166
|
-
transition: all 0.3s ease;
|
|
167
|
-
box-sizing: border-box;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.icon-item-active {
|
|
171
|
-
background-color: v-bind('props.activeColor');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.icon-wrapper {
|
|
175
|
-
display: flex;
|
|
176
|
-
justify-content: center;
|
|
177
|
-
align-items: center;
|
|
178
|
-
width: v-bind('props.iconSize');
|
|
179
|
-
height: v-bind('props.iconSize');
|
|
180
|
-
margin-bottom: 5rpx;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
.icon {
|
|
184
|
-
display: flex;
|
|
185
|
-
justify-content: center;
|
|
186
|
-
align-items: center;
|
|
187
|
-
width: 100%;
|
|
188
|
-
height: 100%;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.icon-text {
|
|
192
|
-
font-size: v-bind('config.fontSize.mediumText');
|
|
193
|
-
text-align: center;
|
|
194
|
-
}
|
|
195
|
-
</style>
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<scroll-view
|
|
3
|
-
class="infinite-scroll-container"
|
|
4
|
-
:scroll-y="true"
|
|
5
|
-
:style="containerStyle"
|
|
6
|
-
@scroll="handleScroll"
|
|
7
|
-
:scroll-with-animation="false"
|
|
8
|
-
@scrolltolower="handleScrollToLower"
|
|
9
|
-
>
|
|
10
|
-
<slot />
|
|
11
|
-
<!-- 加载状态提示 -->
|
|
12
|
-
<template v-if="$slots.loading">
|
|
13
|
-
<slot name="loading" />
|
|
14
|
-
</template>
|
|
15
|
-
<template v-else-if="loading">
|
|
16
|
-
<view class="status-text">加载中...</view>
|
|
17
|
-
</template>
|
|
18
|
-
<template v-if="$slots.null">
|
|
19
|
-
<slot name="null" />
|
|
20
|
-
</template>
|
|
21
|
-
<template v-else-if="noMore">
|
|
22
|
-
<view class="status-text">没有更多了</view>
|
|
23
|
-
</template>
|
|
24
|
-
</scroll-view>
|
|
25
|
-
</template>
|
|
26
|
-
|
|
27
|
-
<script lang="ts" setup>
|
|
28
|
-
import { ref, onMounted, onUnmounted, nextTick,inject } from 'vue';
|
|
29
|
-
|
|
30
|
-
const props = defineProps({
|
|
31
|
-
load: {
|
|
32
|
-
type: Function,
|
|
33
|
-
required: true
|
|
34
|
-
},
|
|
35
|
-
disabled: {
|
|
36
|
-
type: Boolean,
|
|
37
|
-
default: false
|
|
38
|
-
},
|
|
39
|
-
immediate: {
|
|
40
|
-
type: Boolean,
|
|
41
|
-
default: true
|
|
42
|
-
},
|
|
43
|
-
distance: {
|
|
44
|
-
type: Number,
|
|
45
|
-
default: 200
|
|
46
|
-
},
|
|
47
|
-
throttle: {
|
|
48
|
-
type: Number,
|
|
49
|
-
default: 200
|
|
50
|
-
},
|
|
51
|
-
containerStyle: {
|
|
52
|
-
type: Object,
|
|
53
|
-
default: () => ({})
|
|
54
|
-
},
|
|
55
|
-
noMore: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: false
|
|
58
|
-
},
|
|
59
|
-
timeout: {
|
|
60
|
-
type: Number,
|
|
61
|
-
default: 5000
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const config = inject('config');
|
|
66
|
-
const loading = ref(false);
|
|
67
|
-
const lastCall = ref(0);
|
|
68
|
-
const isFirstLoad = ref(true);
|
|
69
|
-
const lastScrollHeight = ref(0);
|
|
70
|
-
let timeoutId: NodeJS.Timeout | null = null;
|
|
71
|
-
|
|
72
|
-
// 节流函数
|
|
73
|
-
const throttle = (fn: Function, delay: number) => {
|
|
74
|
-
let lastTime = 0;
|
|
75
|
-
return function (this: any, ...args: any[]) {
|
|
76
|
-
const now = Date.now();
|
|
77
|
-
if (now - lastTime >= delay) {
|
|
78
|
-
fn.apply(this, args);
|
|
79
|
-
lastTime = now;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// 处理滚动事件
|
|
85
|
-
const handleScroll = throttle((event: any) => {
|
|
86
|
-
const { scrollTop, scrollHeight } = event.detail;
|
|
87
|
-
lastScrollHeight.value = scrollHeight;
|
|
88
|
-
|
|
89
|
-
// 只有当内容高度变化时才处理
|
|
90
|
-
if (scrollHeight !== lastScrollHeight.value) {
|
|
91
|
-
checkLoadMore(scrollTop, scrollHeight);
|
|
92
|
-
}
|
|
93
|
-
}, props.throttle);
|
|
94
|
-
|
|
95
|
-
// 处理滚动到底部事件(作为兜底)
|
|
96
|
-
const handleScrollToLower = () => {
|
|
97
|
-
if (!loading.value && !props.noMore && !props.disabled) {
|
|
98
|
-
loadMore();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// 检查是否需要加载更多
|
|
103
|
-
const checkLoadMore = (scrollTop: number, scrollHeight: number) => {
|
|
104
|
-
const now = Date.now();
|
|
105
|
-
if (now - lastCall.value < props.throttle) return;
|
|
106
|
-
lastCall.value = now;
|
|
107
|
-
|
|
108
|
-
// 计算距离底部的距离
|
|
109
|
-
const triggerPosition = scrollTop + props.distance >= scrollHeight - props.distance;
|
|
110
|
-
|
|
111
|
-
if (triggerPosition) {
|
|
112
|
-
loadMore();
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// 加载更多数据
|
|
117
|
-
const loadMore = async () => {
|
|
118
|
-
if (props.disabled || loading.value || props.noMore) return;
|
|
119
|
-
|
|
120
|
-
loading.value = true;
|
|
121
|
-
|
|
122
|
-
try {
|
|
123
|
-
await props.load();
|
|
124
|
-
// 等待DOM更新
|
|
125
|
-
await nextTick();
|
|
126
|
-
} catch (e) {
|
|
127
|
-
console.error('加载失败:', e);
|
|
128
|
-
} finally {
|
|
129
|
-
loading.value = false;
|
|
130
|
-
isFirstLoad.value = false;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
// 初始化检查
|
|
135
|
-
const checkInitialLoad = () => {
|
|
136
|
-
// 不使用节点查询,改为延迟执行首次加载
|
|
137
|
-
if (props.immediate && isFirstLoad.value) {
|
|
138
|
-
setTimeout(() => {
|
|
139
|
-
loadMore();
|
|
140
|
-
}, 100);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
onMounted(() => {
|
|
145
|
-
checkInitialLoad();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
onUnmounted(() => {
|
|
149
|
-
if (timeoutId) {
|
|
150
|
-
clearTimeout(timeoutId);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
</script>
|
|
154
|
-
|
|
155
|
-
<style lang="scss">
|
|
156
|
-
.infinite-scroll-container {
|
|
157
|
-
box-sizing: border-box;
|
|
158
|
-
height: 100%;
|
|
159
|
-
position: relative;
|
|
160
|
-
|
|
161
|
-
.status-text {
|
|
162
|
-
padding: 20rpx;
|
|
163
|
-
text-align: center;
|
|
164
|
-
color: v-bind('config.fontColor.mainText');
|
|
165
|
-
font-size: v-bind('config.fontSize.mediumText');
|
|
166
|
-
|
|
167
|
-
&:last-child {
|
|
168
|
-
padding-bottom: 40rpx;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
</style>
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :class="['v-list', `v-list--border-${borderMode}`]">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { computed,inject } from 'vue';
|
|
9
|
-
|
|
10
|
-
const props = defineProps({
|
|
11
|
-
borderMode: {
|
|
12
|
-
type: String,
|
|
13
|
-
default: 'all',
|
|
14
|
-
validator: (value: any) => {
|
|
15
|
-
return ['all', 'none', 'item'].includes(value);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const config = inject<any>('config');
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<style lang="scss" scoped>
|
|
24
|
-
.v-list {
|
|
25
|
-
width: 100%;
|
|
26
|
-
background-color: v-bind("config.backgroundColor.reversal");
|
|
27
|
-
|
|
28
|
-
&--border-all {
|
|
29
|
-
border: 1rpx solid v-bind("config.border.color");
|
|
30
|
-
border-radius: 4rpx;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&--border-none {
|
|
34
|
-
border: none;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&--border-item {
|
|
38
|
-
::v-deep .v-list-item:not(:last-child) {
|
|
39
|
-
border-bottom: 1px solid v-bind("config.border.color");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
</style>
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :class="['v-row', `v-row--justify-${justify}`, `v-row--align-${align}`, `v-row--border-${borderMode}`]" :style="rowStyle">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { computed, inject } from 'vue';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* v-row 行
|
|
12
|
-
* gutter 子元素之间的间距 Number 0 -
|
|
13
|
-
* justify 水平排列方式 String 'start' 'start', 'end', 'center', 'space-between', 'space-around', 'space-evenly'
|
|
14
|
-
* align 垂直排列方式 String 'top' 'top', 'center', 'bottom', 'stretch', 'baseline'
|
|
15
|
-
* borderMode 边框模式 String 'all' 'all', 'none', 'bottom', 'top', 'left', 'right', 'ends', 'up-down'
|
|
16
|
-
*/
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
gutter: {
|
|
19
|
-
type: Number,
|
|
20
|
-
default: 0
|
|
21
|
-
},
|
|
22
|
-
justify: {
|
|
23
|
-
type: String,
|
|
24
|
-
default: 'start',
|
|
25
|
-
validator: (value: any) => {
|
|
26
|
-
return ['start', 'end', 'center', 'space-between', 'space-around', 'space-evenly'].includes(value);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
align: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: 'top',
|
|
32
|
-
validator: (value: string) => {
|
|
33
|
-
return ['top', 'center', 'bottom', 'stretch', 'baseline'].includes(value);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
borderMode: {
|
|
37
|
-
type: String,
|
|
38
|
-
default: 'none',
|
|
39
|
-
validator: (value: string) => {
|
|
40
|
-
return ['all', 'none', 'bottom', 'top', 'left', 'right', 'ends', 'up-down'].includes(value);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const config = inject<any>('config');
|
|
46
|
-
|
|
47
|
-
const rowStyle = computed(() => {
|
|
48
|
-
const style: Record<string, string | number> = {};
|
|
49
|
-
if (props.gutter) {
|
|
50
|
-
style.marginLeft = `-${props.gutter / 2}rpx`;
|
|
51
|
-
style.marginRight = `-${props.gutter / 2}rpx`;
|
|
52
|
-
}
|
|
53
|
-
return style;
|
|
54
|
-
});
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<style lang="scss" scoped>
|
|
58
|
-
.v-row {
|
|
59
|
-
display: flex;
|
|
60
|
-
flex-wrap: wrap;
|
|
61
|
-
box-sizing: border-box;
|
|
62
|
-
border: 1rpx solid v-bind('config.border.color');
|
|
63
|
-
border-radius: 4rpx;
|
|
64
|
-
|
|
65
|
-
// 边框模式
|
|
66
|
-
&--border-none {
|
|
67
|
-
border: none;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
&--border-bottom {
|
|
71
|
-
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&--border-top {
|
|
75
|
-
border-top: 1rpx solid v-bind('config.border.color');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
&--border-left {
|
|
79
|
-
border-left: 1rpx solid v-bind('config.border.color');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&--border-right {
|
|
83
|
-
border-right: 1rpx solid v-bind('config.border.color');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&--border-ends {
|
|
87
|
-
border-left: 1rpx solid v-bind('config.border.color');
|
|
88
|
-
border-right: 1rpx solid v-bind('config.border.color');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
&--border-up-down {
|
|
92
|
-
border-top: 1rpx solid v-bind('config.border.color');
|
|
93
|
-
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 对齐方式
|
|
97
|
-
&--justify-start {
|
|
98
|
-
justify-content: flex-start;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
&--justify-end {
|
|
102
|
-
justify-content: flex-end;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&--justify-center {
|
|
106
|
-
justify-content: center;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
&--justify-space-between {
|
|
110
|
-
justify-content: space-between;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
&--justify-space-around {
|
|
114
|
-
justify-content: space-around;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
&--justify-space-evenly {
|
|
118
|
-
justify-content: space-evenly;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 垂直对齐
|
|
122
|
-
&--align-top {
|
|
123
|
-
align-items: flex-start;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
&--align-center {
|
|
127
|
-
align-items: center;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
&--align-bottom {
|
|
131
|
-
align-items: flex-end;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
&--align-stretch {
|
|
135
|
-
align-items: stretch;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
&--align-baseline {
|
|
139
|
-
align-items: baseline;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
</style>
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="v-waterfall">
|
|
3
|
-
<view v-for="(column, columnIndex) in columnsList" :key="columnIndex" class="column">
|
|
4
|
-
<view v-for="(item, itemIndex) in column" :key="itemIndex" class="waterfall-item">
|
|
5
|
-
<slot name="item" :item="item" />
|
|
6
|
-
</view>
|
|
7
|
-
</view>
|
|
8
|
-
</view>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script lang="ts" setup>
|
|
12
|
-
import { ref, watch } from 'vue';
|
|
13
|
-
|
|
14
|
-
interface WaterfallItem {
|
|
15
|
-
height: number;
|
|
16
|
-
content: any;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const props = defineProps({
|
|
20
|
-
items: {
|
|
21
|
-
type: Array as () => WaterfallItem[],
|
|
22
|
-
default: () => []
|
|
23
|
-
},
|
|
24
|
-
columns: {
|
|
25
|
-
type: Number,
|
|
26
|
-
default: 2
|
|
27
|
-
},
|
|
28
|
-
columnWidth: {
|
|
29
|
-
type: String,
|
|
30
|
-
default: '50%'
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const columnsList = ref<WaterfallItem[][]>([]);
|
|
35
|
-
|
|
36
|
-
const splitIntoColumns = () => {
|
|
37
|
-
const cols = Array.from({ length: props.columns }, () => []);
|
|
38
|
-
props.items.forEach((item, index) => {
|
|
39
|
-
const columnIndex = index % props.columns;
|
|
40
|
-
cols[columnIndex].push(item);
|
|
41
|
-
});
|
|
42
|
-
columnsList.value = cols;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
splitIntoColumns();
|
|
46
|
-
|
|
47
|
-
watch(
|
|
48
|
-
() => props.items,
|
|
49
|
-
() => {
|
|
50
|
-
splitIntoColumns();
|
|
51
|
-
},
|
|
52
|
-
{ deep: true }
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
watch(
|
|
56
|
-
() => props.columns,
|
|
57
|
-
() => {
|
|
58
|
-
splitIntoColumns();
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
</script>
|
|
62
|
-
|
|
63
|
-
<style lang="scss" scoped>
|
|
64
|
-
.v-waterfall {
|
|
65
|
-
display: flex;
|
|
66
|
-
flex-wrap: wrap;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.column {
|
|
70
|
-
width: v-bind('100 / props.columns + "%"');
|
|
71
|
-
box-sizing: border-box;
|
|
72
|
-
padding: 0 5rpx;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.waterfall-item {
|
|
76
|
-
margin-bottom: 5rpx;
|
|
77
|
-
padding: 10rpx 0;
|
|
78
|
-
}
|
|
79
|
-
</style>
|