-
Notifications
You must be signed in to change notification settings - Fork 19
/
Example.vue
252 lines (245 loc) · 8.45 KB
/
Example.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<template>
<header>
<strong>Vue瀑布流</strong>
<small>
<span class="badge text-bg-success">v{{ pkg.version }}</span>
</small>
</header>
<VirtualWaterfall
:virtual="waterfallOption.virtual"
:gap="waterfallOption.gap"
:padding="waterfallOption.padding"
:preload-screen-count="[waterfallOption.topPreloadScreenCount, waterfallOption.bottomPreloadScreenCount]"
:item-min-width="waterfallOption.itemMinWidth"
:max-column-count="waterfallOption.maxColumnCount"
:min-column-count="waterfallOption.minColumnCount"
:calc-item-height="calcItemHeight"
:items="data.list"
>
<template #default="{ item }: { item: ItemOption }">
<Card
:item="item"
:onlyImage="waterfallOption.onlyImage"
>
</Card>
</template>
</VirtualWaterfall>
<aside v-if="asideShow">
<form>
<div class="form-group form-group-sm mb-2">
<label class="form-label fs-6">间隔 <code>[0:100]</code></label>
<div class="input-group input-group-sm">
<input
type="number"
class="form-control"
v-model="waterfallOption.gap"
min="0"
max="100"
step="1"
/>
<span
class="input-group-text"
id="basic-addon1"
>
px
</span>
</div>
</div>
<div class="form-group form-group-sm mb-2">
<label class="form-label fs-6">填充 <code>[0:100]</code></label>
<div class="input-group input-group-sm">
<input
type="number"
class="form-control"
v-model="waterfallOption.padding"
min="0"
max="100"
step="1"
/>
<span
class="input-group-text"
id="basic-addon1"
>
px
</span>
</div>
</div>
<div class="form-group form-group-sm mb-2">
<label class="form-label fs-6">每个元素的最小宽度 <code>[100:600]</code></label>
<div class="input-group input-group-sm">
<input
type="number"
class="form-control"
v-model="waterfallOption.itemMinWidth"
min="100"
max="600"
step="1"
/>
<span
class="input-group-text"
id="basic-addon1"
>px</span
>
</div>
</div>
<div class="form-group form-group-sm mb-2">
<label class="form-label fs-6">距离底部多少加载更多 <code>[0:10000]</code></label>
<div class="input-group input-group-sm">
<input
type="number"
class="form-control"
v-model="waterfallOption.bottomDistance"
min="0"
max="1000"
step="1"
/>
<span
class="input-group-text"
id="basic-addon1"
>px</span
>
</div>
</div>
<div class="form-group form-group-sm mb-2">
<label class="form-label fs-6"
>最小列数 <code>[0:{{ waterfallOption.maxColumnCount }}]</code>,最大列数 <code>[{{ waterfallOption.minColumnCount }}:10]</code></label
>
<div class="input-group input-group-sm">
<input
type="number"
class="form-control"
v-model="waterfallOption.minColumnCount"
min="0"
:max="waterfallOption.maxColumnCount"
step="1"
/>
<span
class="input-group-text"
id="basic-addon1"
>列</span
>
<input
type="number"
class="form-control"
v-model="waterfallOption.maxColumnCount"
:min="waterfallOption.minColumnCount"
max="10"
step="1"
/>
<span
class="input-group-text"
id="basic-addon1"
>列</span
>
</div>
</div>
<div class="form-group form-group-sm mb-2">
<label class="form-label fs-6">(顶部/底部)预加载屏 <code>[0:5]</code></label>
<div class="input-group input-group-sm">
<input
type="number"
class="form-control"
v-model="waterfallOption.topPreloadScreenCount"
min="0"
max="5"
step="1"
/>
<input
type="number"
class="form-control"
v-model="waterfallOption.bottomPreloadScreenCount"
min="0"
max="5"
step="1"
/>
</div>
</div>
<div class="form-group form-group-sm form-check form-switch mb-1">
<label class="form-label fs-6">开启虚拟列表</label>
<input
class="form-check-input"
type="checkbox"
v-model="waterfallOption.virtual"
/>
</div>
<div class="form-group form-group-sm form-check form-switch mb-2">
<label class="form-label fs-6">仅展示图片</label>
<input
class="form-check-input"
type="checkbox"
v-model="waterfallOption.onlyImage"
/>
</div>
<div class="form-group form-group-sm mb-2">
<label class="form-label fs-6">数据展示</label>
<p>每页条数: {{ data.size }}</p>
<p>当前页码: {{ data.page }} / {{ data.max }}</p>
<p>已加载量: {{ data.list.length }} / {{ data.total }}</p>
<p>等待加载: {{ waterfallOption.loading }}</p>
</div>
<button
type="button"
class="btn btn-primary btn-sm"
@click="backTop"
>
回到顶部
</button>
</form>
</aside>
</template>
<script setup lang="ts">
import pkg from '../../package.json'
import VirtualWaterfall from '../vue-virtual-waterfall/virtual-waterfall.vue'
import Card from './Card.vue'
import useApp from './useApp.ts'
import useWaterfall from './useWaterfall.ts'
const { asideShow } = useApp()
const { backTop, waterfallOption, data, calcItemHeight } = useWaterfall()
</script>
<style lang="scss">
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
padding-top: 72px;
background: #f1f2f6;
user-select: none;
}
header {
position: fixed;
top: 0;
left: 0;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 72px;
background-color: white;
border-bottom: 1px solid #f1f2f6;
strong {
font-size: 24px;
margin-right: 8px;
}
}
aside {
position: fixed;
top: 0;
right: 0;
width: 300px;
height: 100%;
padding-top: 72px;
background-color: white;
border-left: 1px solid #f1f2f6;
form {
width: 100%;
height: 100%;
padding: 20px;
p {
margin: 0;
}
}
}
</style>