@fredwsw/frontend-rules 1.0.0
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 +302 -0
- package/bin/cli.js +155 -0
- package/package.json +22 -0
- package/template/docs/uv-ui-docs/action-sheet-cn.md +180 -0
- package/template/docs/uv-ui-docs/album-cn.md +104 -0
- package/template/docs/uv-ui-docs/alert-cn.md +71 -0
- package/template/docs/uv-ui-docs/avatar-cn.md +149 -0
- package/template/docs/uv-ui-docs/back-top-cn.md +121 -0
- package/template/docs/uv-ui-docs/badge-cn.md +100 -0
- package/template/docs/uv-ui-docs/button-cn.md +181 -0
- package/template/docs/uv-ui-docs/calendar-cn.md +179 -0
- package/template/docs/uv-ui-docs/calendars-cn.md +264 -0
- package/template/docs/uv-ui-docs/cell-cn.md +163 -0
- package/template/docs/uv-ui-docs/checkbox-cn.md +164 -0
- package/template/docs/uv-ui-docs/code-cn.md +122 -0
- package/template/docs/uv-ui-docs/code-input-cn.md +127 -0
- package/template/docs/uv-ui-docs/collapse-cn.md +206 -0
- package/template/docs/uv-ui-docs/color-cn.md +122 -0
- package/template/docs/uv-ui-docs/count-down-cn.md +169 -0
- package/template/docs/uv-ui-docs/count-to-cn.md +125 -0
- package/template/docs/uv-ui-docs/datetime-picker-cn.md +167 -0
- package/template/docs/uv-ui-docs/divider-cn.md +90 -0
- package/template/docs/uv-ui-docs/drop-down-cn.md +287 -0
- package/template/docs/uv-ui-docs/empty-cn.md +76 -0
- package/template/docs/uv-ui-docs/form-cn.md +220 -0
- package/template/docs/uv-ui-docs/gap-cn.md +63 -0
- package/template/docs/uv-ui-docs/grid-cn.md +187 -0
- package/template/docs/uv-ui-docs/icon-cn.md +255 -0
- package/template/docs/uv-ui-docs/image-cn.md +170 -0
- package/template/docs/uv-ui-docs/index-list-cn.md +132 -0
- package/template/docs/uv-ui-docs/input-cn.md +157 -0
- package/template/docs/uv-ui-docs/keyboard-cn.md +156 -0
- package/template/docs/uv-ui-docs/layout-cn.md +215 -0
- package/template/docs/uv-ui-docs/line-cn.md +77 -0
- package/template/docs/uv-ui-docs/line-progress-cn.md +132 -0
- package/template/docs/uv-ui-docs/link-cn.md +97 -0
- package/template/docs/uv-ui-docs/list-cn.md +185 -0
- package/template/docs/uv-ui-docs/load-more-cn.md +144 -0
- package/template/docs/uv-ui-docs/loading-icon-cn.md +125 -0
- package/template/docs/uv-ui-docs/loading-page-cn.md +85 -0
- package/template/docs/uv-ui-docs/modal-cn.md +212 -0
- package/template/docs/uv-ui-docs/navbar-cn.md +171 -0
- package/template/docs/uv-ui-docs/no-network-cn.md +112 -0
- package/template/docs/uv-ui-docs/notice-bar-cn.md +119 -0
- package/template/docs/uv-ui-docs/notify-cn.md +185 -0
- package/template/docs/uv-ui-docs/number-box-cn.md +131 -0
- package/template/docs/uv-ui-docs/overlay-cn.md +122 -0
- package/template/docs/uv-ui-docs/parse-cn.md +177 -0
- package/template/docs/uv-ui-docs/pick-color-cn.md +147 -0
- package/template/docs/uv-ui-docs/picker-cn.md +159 -0
- package/template/docs/uv-ui-docs/popup-cn.md +184 -0
- package/template/docs/uv-ui-docs/qrcode-cn.md +150 -0
- package/template/docs/uv-ui-docs/radio-cn.md +166 -0
- package/template/docs/uv-ui-docs/rate-cn.md +91 -0
- package/template/docs/uv-ui-docs/read-more-cn.md +191 -0
- package/template/docs/uv-ui-docs/scroll-list-cn.md +188 -0
- package/template/docs/uv-ui-docs/search-cn.md +107 -0
- package/template/docs/uv-ui-docs/skeleton-cn.md +101 -0
- package/template/docs/uv-ui-docs/skeletons-cn.md +312 -0
- package/template/docs/uv-ui-docs/slider-cn.md +98 -0
- package/template/docs/uv-ui-docs/steps-cn.md +158 -0
- package/template/docs/uv-ui-docs/sticky-cn.md +82 -0
- package/template/docs/uv-ui-docs/subsection-cn.md +161 -0
- package/template/docs/uv-ui-docs/swipe-action-cn.md +207 -0
- package/template/docs/uv-ui-docs/swiper-cn.md +247 -0
- package/template/docs/uv-ui-docs/switch-cn.md +136 -0
- package/template/docs/uv-ui-docs/tabbar-cn.md +224 -0
- package/template/docs/uv-ui-docs/tabs-cn.md +260 -0
- package/template/docs/uv-ui-docs/tags-cn.md +191 -0
- package/template/docs/uv-ui-docs/text-cn.md +178 -0
- package/template/docs/uv-ui-docs/textarea-cn.md +132 -0
- package/template/docs/uv-ui-docs/toast-cn.md +110 -0
- package/template/docs/uv-ui-docs/tooltip-cn.md +91 -0
- package/template/docs/uv-ui-docs/transition-cn.md +202 -0
- package/template/docs/uv-ui-docs/upload-cn.md +156 -0
- package/template/docs/uv-ui-docs/vtabs-cn.md +190 -0
- package/template/docs/uv-ui-docs/waterfall-cn.md +276 -0
- package/template/rules/common.mdc +90 -0
- package/template/rules/uv-ui-docs.mdc +111 -0
- package/template/skills/code-simplifier/SKILL.md +109 -0
- package/template/skills/frontend-design/SKILL.md +44 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
---
|
|
2
|
+
group: 导航
|
|
3
|
+
category: Components
|
|
4
|
+
title: Vtabs
|
|
5
|
+
subtitle: 垂直选项卡
|
|
6
|
+
description: 左侧分类选择、右侧内容展示,支持联动或非联动两种模式。
|
|
7
|
+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*BD2JSKm8I-kAAAAAAAAAAAAADrJ8AQ/original
|
|
8
|
+
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*r29rQ51bNdwAAAAAAAAAAAAADrJ8AQ/original
|
|
9
|
+
demo:
|
|
10
|
+
cols: 2
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 何时使用 {#when-to-use}
|
|
14
|
+
|
|
15
|
+
垂直选项卡用于左侧分类、右侧内容的布局,左右自动联动,无需自行计算位置。
|
|
16
|
+
|
|
17
|
+
- **联动模式**:右侧展示全部内容,滚动时左侧选项自动定位选中项
|
|
18
|
+
- **非联动模式**:右侧仅在选中时展示对应内容
|
|
19
|
+
|
|
20
|
+
开箱即用,简单配置即可。
|
|
21
|
+
|
|
22
|
+
> 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
23
|
+
|
|
24
|
+
## 平台兼容性 {#platform}
|
|
25
|
+
|
|
26
|
+
| App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
|
|
27
|
+
| --- | --- | --- | --- | --- | --- |
|
|
28
|
+
| √ | √ | √ | √ | √ | √ |
|
|
29
|
+
|
|
30
|
+
**组件名:** `uv-vtabs`、`uv-vtabs-item`
|
|
31
|
+
|
|
32
|
+
## 代码演示 {#examples}
|
|
33
|
+
|
|
34
|
+
### 联动模式 {#chain}
|
|
35
|
+
|
|
36
|
+
设置 `chain=true` 开启联动:右侧展示全部内容,滚动时左侧自动定位。
|
|
37
|
+
|
|
38
|
+
- 需配合 `uv-vtabs-item`,内容用 `v-for` 循环渲染
|
|
39
|
+
- 有头部内容时需传 `hdHeight`,否则联动计算不准确;无头部时可不传(默认 0)
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<template>
|
|
43
|
+
<view class="content">
|
|
44
|
+
<view style="height: 100rpx;background: #ecf5ff;color: #909193;display: flex;justify-content: center;text-align: center;">
|
|
45
|
+
<text style="font-size: 28rpx;">欢迎使用uv-vtabs,有头部内容必须传hdHeight参数</text>
|
|
46
|
+
</view>
|
|
47
|
+
<uv-vtabs
|
|
48
|
+
:chain="chain"
|
|
49
|
+
:list="list"
|
|
50
|
+
:height="height"
|
|
51
|
+
hdHeight="100rpx"
|
|
52
|
+
@change="change"
|
|
53
|
+
>
|
|
54
|
+
<!-- #ifdef VUE2 -->
|
|
55
|
+
<template v-for="(item,index) in list">
|
|
56
|
+
<uv-vtabs-item :index="index" :key="index">
|
|
57
|
+
<!-- #endif -->
|
|
58
|
+
<!-- #ifdef VUE3 -->
|
|
59
|
+
<template v-for="(item,index) in list" :key="index">
|
|
60
|
+
<uv-vtabs-item :index="index">
|
|
61
|
+
<!-- #endif -->
|
|
62
|
+
<view class="item" v-for="(item2,index2) in item.childrens" :key="index2">
|
|
63
|
+
<view class="item-title"><text class="text">{{ item2.name }}</text></view>
|
|
64
|
+
<view class="item-content"><text class="text">{{ item2.desc }}</text></view>
|
|
65
|
+
</view>
|
|
66
|
+
<view class="gap" v-if="index < list.length - 1">
|
|
67
|
+
<uv-gap bg-color="#f1f1f1" height="4"></uv-gap>
|
|
68
|
+
</view>
|
|
69
|
+
</uv-vtabs-item>
|
|
70
|
+
</template>
|
|
71
|
+
<uv-gap bg-color="#fff" height="600"></uv-gap>
|
|
72
|
+
</uv-vtabs>
|
|
73
|
+
</view>
|
|
74
|
+
</template>
|
|
75
|
+
<script>
|
|
76
|
+
const getList = [
|
|
77
|
+
{ name: 'uv-ui简介', childrens: [{ name: 'uv-ui简介', desc: '...' }] },
|
|
78
|
+
{ name: 'uv-ui特点', childrens: [{ name: '全端兼容', desc: '...' }, { name: '集成工具', desc: '...' }] },
|
|
79
|
+
{ name: '更新日志', badge: { show: true, value: 5 }, childrens: [{ name: '更新日志', desc: '...' }] },
|
|
80
|
+
{ name: '设计规范', childrens: [{ name: '设计规范', desc: '...' }] },
|
|
81
|
+
{ name: '交流反馈', childrens: [{ name: '交流反馈', desc: '...' }] }
|
|
82
|
+
]
|
|
83
|
+
export default {
|
|
84
|
+
data() {
|
|
85
|
+
return { list: [], chain: true }
|
|
86
|
+
},
|
|
87
|
+
computed: {
|
|
88
|
+
height() {
|
|
89
|
+
return uni.getSystemInfoSync().windowHeight - uni.upx2px(100)
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
onReady() {
|
|
93
|
+
setTimeout(() => { this.list = getList }, 500)
|
|
94
|
+
},
|
|
95
|
+
methods: {
|
|
96
|
+
change(index) { console.log('选项改变:', index) }
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
</script>
|
|
100
|
+
<style scoped lang="scss">
|
|
101
|
+
.item {
|
|
102
|
+
padding: 10rpx 20rpx;
|
|
103
|
+
&-title .text { font-weight: 700; font-size: 32rpx; color: #111; }
|
|
104
|
+
&-content .text { padding: 20rpx 0; line-height: 48rpx; font-size: 30rpx; color: #111; }
|
|
105
|
+
}
|
|
106
|
+
.gap { padding: 0 30rpx; }
|
|
107
|
+
</style>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 非联动模式 {#no-chain}
|
|
111
|
+
|
|
112
|
+
设置 `chain=false` 关闭联动:右侧仅展示当前选中分类的内容,需手动根据 `value` 渲染数据。
|
|
113
|
+
|
|
114
|
+
```vue
|
|
115
|
+
<template>
|
|
116
|
+
<view class="content">
|
|
117
|
+
<uv-vtabs
|
|
118
|
+
:chain="chain"
|
|
119
|
+
:list="list"
|
|
120
|
+
:barItemBadgeStyle="{right:'20px',top:'12px'}"
|
|
121
|
+
@change="change"
|
|
122
|
+
>
|
|
123
|
+
<uv-vtabs-item>
|
|
124
|
+
<view class="item" v-for="(item2,index2) in list2" :key="index2">
|
|
125
|
+
<view class="item-title"><text class="text">{{ item2.name }}</text></view>
|
|
126
|
+
<view class="item-content"><text class="text">{{ item2.desc }}</text></view>
|
|
127
|
+
</view>
|
|
128
|
+
</uv-vtabs-item>
|
|
129
|
+
</uv-vtabs>
|
|
130
|
+
</view>
|
|
131
|
+
</template>
|
|
132
|
+
<script>
|
|
133
|
+
const getList = [/* 同上 */]
|
|
134
|
+
export default {
|
|
135
|
+
data() {
|
|
136
|
+
return { list: [], chain: false, value: 0 }
|
|
137
|
+
},
|
|
138
|
+
computed: {
|
|
139
|
+
list2() {
|
|
140
|
+
const _list = this.list[this.value]?.childrens
|
|
141
|
+
return _list ? _list : []
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
onReady() {
|
|
145
|
+
setTimeout(() => { this.list = getList }, 200)
|
|
146
|
+
},
|
|
147
|
+
methods: {
|
|
148
|
+
change(index) {
|
|
149
|
+
console.log('选项改变:', index)
|
|
150
|
+
this.value = index
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## API {#api}
|
|
158
|
+
|
|
159
|
+
### Vtabs Props {#props}
|
|
160
|
+
|
|
161
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
162
|
+
| --- | --- | --- | --- |
|
|
163
|
+
| list | Array | [] | 选项数组,元素如 `{ name: 'xx', badge?: {...}, childrens?: [...] }`,badge 参考 uv-badge |
|
|
164
|
+
| keyName | String | name | 从 list 元素中读取的展示字段名 |
|
|
165
|
+
| current | Number | 0 | 当前选中项索引 |
|
|
166
|
+
| hdHeight | Number \| String | 0 | 头部高度,有头部时必传 (1.0.4) |
|
|
167
|
+
| chain | Boolean | true | 是否联动,chain=true 时 VtabsItem 的 index 必传 |
|
|
168
|
+
| height | Number \| String | 屏幕高度 | 整个列表高度 |
|
|
169
|
+
| barWidth | Number \| String | 180rpx | 左侧区域宽度 |
|
|
170
|
+
| barScrollable | Boolean | true | 左侧是否可滚动 |
|
|
171
|
+
| barBgColor | String | $uv-bg-color | 左侧背景色 |
|
|
172
|
+
| barStyle | Object | - | 左侧区域自定义样式 |
|
|
173
|
+
| barItemStyle | Object | - | 左侧每项样式 |
|
|
174
|
+
| barItemActiveStyle | Object | - | 左侧选中项样式 |
|
|
175
|
+
| barItemActiveLineStyle | Object | - | 选中项竖线条样式,如 `{ background: '#2878FF' }` |
|
|
176
|
+
| barItemBadgeStyle | Object | - | 徽标样式,用于调整位置 |
|
|
177
|
+
| contentStyle | Object | - | 右侧区域样式 |
|
|
178
|
+
|
|
179
|
+
### VtabsItem Props {#item-props}
|
|
180
|
+
|
|
181
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
182
|
+
| --- | --- | --- | --- |
|
|
183
|
+
| index | Number \| String | 0 | 内容区索引,chain=true 时必传 |
|
|
184
|
+
|
|
185
|
+
### Vtabs Events {#events}
|
|
186
|
+
|
|
187
|
+
| 事件名 | 说明 | 回调参数 |
|
|
188
|
+
| --- | --- | --- |
|
|
189
|
+
| @change | 选择改变时触发 | 选项索引 |
|
|
190
|
+
| @scrolltolower | 内容滚动到底部触发 (1.0.4) | 选项索引 |
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
group: 布局
|
|
3
|
+
category: Components
|
|
4
|
+
title: Waterfall
|
|
5
|
+
subtitle: 瀑布流
|
|
6
|
+
description: 参差不齐的多栏布局,支持滚动加载,常用于商品展示等场景。
|
|
7
|
+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*BD2JSKm8I-kAAAAAAAAAAAAADrJ8AQ/original
|
|
8
|
+
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*r29rQ51bNdwAAAAAAAAAAAAADrJ8AQ/original
|
|
9
|
+
demo:
|
|
10
|
+
cols: 2
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 何时使用 {#when-to-use}
|
|
14
|
+
|
|
15
|
+
瀑布流用于多栏参差不齐的布局,滚动到底部时可继续加载数据,常用于电商商品展示等。
|
|
16
|
+
|
|
17
|
+
> 完整示例下载地址:[uv-ui 插件市场](https://ext.dcloud.net.cn/plugin?name=uv-ui)
|
|
18
|
+
|
|
19
|
+
## 平台兼容性 {#platform}
|
|
20
|
+
|
|
21
|
+
| App(vue) | App(nvue) | H5 | 小程序 | VUE2 | VUE3 |
|
|
22
|
+
| --- | --- | --- | --- | --- | --- |
|
|
23
|
+
| √ | √ | √ | √ | √ | √ |
|
|
24
|
+
|
|
25
|
+
**组件名:** `uv-waterfall`
|
|
26
|
+
|
|
27
|
+
## 注意事项 {#notice}
|
|
28
|
+
|
|
29
|
+
- 集成了 uni-app 官方的 nvue 组件 [waterfall](https://uniapp.dcloud.net.cn/component/waterfall.html),vue 与 nvue 用法不同,见下方示例
|
|
30
|
+
- **APP-NVUE 中** 不能使用 uv-image 等组件,详见:[android 端 list 中为什么不能使用 uv-image 等组件](https://ask.dcloud.net.cn/article/1311)
|
|
31
|
+
|
|
32
|
+
## 代码演示 {#examples}
|
|
33
|
+
|
|
34
|
+
### 基本使用(vue) {#basic-vue}
|
|
35
|
+
|
|
36
|
+
- `column-count`:列数,默认 2,范围 1–5
|
|
37
|
+
- 列数为 2 需定义 `v-slot:list1`、`v-slot:list2`,列数为 3 则增加 `v-slot:list3`,以此类推
|
|
38
|
+
- `@changeList` 必须处理:`e.name` 为 `list1` / `list2`,需手动 `this[e.name].push(e.value)`
|
|
39
|
+
- 插槽内容需包一层 `view` 以磨平平台差异
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<template>
|
|
43
|
+
<view class="waterfall">
|
|
44
|
+
<uv-waterfall
|
|
45
|
+
ref="waterfall"
|
|
46
|
+
v-model="list"
|
|
47
|
+
:add-time="10"
|
|
48
|
+
:left-gap="leftGap"
|
|
49
|
+
:right-gap="rightGap"
|
|
50
|
+
:column-gap="columnGap"
|
|
51
|
+
@changeList="changeList"
|
|
52
|
+
>
|
|
53
|
+
<template v-slot:list1>
|
|
54
|
+
<view>
|
|
55
|
+
<view v-for="(item, index) in list1" :key="item.id" class="waterfall-item">
|
|
56
|
+
<view class="waterfall-item__image" :style="[imageStyle(item)]">
|
|
57
|
+
<image :src="item.image" mode="widthFix" :style="{width:item.width+'px'}"></image>
|
|
58
|
+
</view>
|
|
59
|
+
<view class="waterfall-item__ft">...</view>
|
|
60
|
+
</view>
|
|
61
|
+
</view>
|
|
62
|
+
</template>
|
|
63
|
+
<template v-slot:list2>
|
|
64
|
+
<view>
|
|
65
|
+
<view v-for="(item, index) in list2" :key="item.id" class="waterfall-item">...</view>
|
|
66
|
+
</view>
|
|
67
|
+
</template>
|
|
68
|
+
</uv-waterfall>
|
|
69
|
+
</view>
|
|
70
|
+
</template>
|
|
71
|
+
<script>
|
|
72
|
+
export default {
|
|
73
|
+
data() {
|
|
74
|
+
return {
|
|
75
|
+
list: [],
|
|
76
|
+
list1: [],
|
|
77
|
+
list2: [],
|
|
78
|
+
leftGap: 10,
|
|
79
|
+
rightGap: 10,
|
|
80
|
+
columnGap: 10
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
computed: {
|
|
84
|
+
imageStyle(item) {
|
|
85
|
+
return item => {
|
|
86
|
+
const v = uni.upx2px(750) - this.leftGap - this.rightGap - this.columnGap
|
|
87
|
+
const w = v / 2
|
|
88
|
+
const rate = w / item.w
|
|
89
|
+
const h = rate * item.h
|
|
90
|
+
return { width: w + 'px', height: h + 'px' }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
methods: {
|
|
95
|
+
changeList(e) {
|
|
96
|
+
this[e.name].push(e.value)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
</script>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 删除某项(vue) {#remove}
|
|
104
|
+
|
|
105
|
+
使用 `this.$refs.waterfall.remove(id)` 删除,删除后需在 `@remove` 中从 list1/list2 里移除对应项。
|
|
106
|
+
|
|
107
|
+
```vue
|
|
108
|
+
<uv-waterfall ref="waterfall" @remove="remove">...</uv-waterfall>
|
|
109
|
+
<script>
|
|
110
|
+
export default {
|
|
111
|
+
methods: {
|
|
112
|
+
longHandle(item) {
|
|
113
|
+
uni.showModal({
|
|
114
|
+
title: '提示',
|
|
115
|
+
content: '确定删除?',
|
|
116
|
+
success: (res) => {
|
|
117
|
+
if (res.confirm) this.$refs.waterfall.remove(item.id)
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
remove(id) {
|
|
122
|
+
[this.list1, this.list2].forEach(arr => {
|
|
123
|
+
const idx = arr.findIndex(item => item.id == id)
|
|
124
|
+
if (idx > -1) arr.splice(idx, 1)
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
</script>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 清空所有数据(vue) {#clear}
|
|
133
|
+
|
|
134
|
+
使用 `this.$refs.waterfall.clear()`,会触发 `@clear`。下拉刷新、tab 切换等场景可先清空再赋新数据。
|
|
135
|
+
|
|
136
|
+
```vue
|
|
137
|
+
<uv-waterfall ref="waterfall" @clear="clear">...</uv-waterfall>
|
|
138
|
+
<script>
|
|
139
|
+
export default {
|
|
140
|
+
async onPullDownRefresh() {
|
|
141
|
+
this.list = []
|
|
142
|
+
this.$refs.waterfall.clear()
|
|
143
|
+
this.list1 = []
|
|
144
|
+
this.list2 = []
|
|
145
|
+
const { data } = await this.getData()
|
|
146
|
+
this.list = data
|
|
147
|
+
uni.stopPullDownRefresh()
|
|
148
|
+
},
|
|
149
|
+
methods: { clear() {} }
|
|
150
|
+
}
|
|
151
|
+
</script>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 加载更多(vue) {#loadmore}
|
|
155
|
+
|
|
156
|
+
触底时追加数据到 `list`,可配合 uv-load-more。
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
async onReachBottom() {
|
|
160
|
+
if (this.loadStatus == 'loadmore') {
|
|
161
|
+
this.loadStatus = 'loading'
|
|
162
|
+
const { data } = await this.getData()
|
|
163
|
+
this.list.push.apply(this.list, data)
|
|
164
|
+
this.loadStatus = 'loadmore'
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Tab 切换(vue) {#tab}
|
|
170
|
+
|
|
171
|
+
tab 切换需先清空再赋新数据:
|
|
172
|
+
|
|
173
|
+
```javascript
|
|
174
|
+
async clickTab(e) {
|
|
175
|
+
this.list = []
|
|
176
|
+
this.$refs.waterfall.clear()
|
|
177
|
+
this.list1 = []
|
|
178
|
+
this.list2 = []
|
|
179
|
+
const { data } = await this.getData()
|
|
180
|
+
this.list = data
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### nvue 中使用 {#nvue}
|
|
185
|
+
|
|
186
|
+
nvue 下直接使用 `cell` 渲染列表,无需插槽,数据绑在 `list` 上,使用 `@scrolltolower` 触底加载。**APP-NVUE 中不能用 uv-image**。
|
|
187
|
+
|
|
188
|
+
```vue
|
|
189
|
+
<template>
|
|
190
|
+
<uv-waterfall
|
|
191
|
+
column-count="2"
|
|
192
|
+
left-gap="10"
|
|
193
|
+
right-gap="10"
|
|
194
|
+
column-gap="8"
|
|
195
|
+
@scrolltolower="init"
|
|
196
|
+
>
|
|
197
|
+
<cell v-for="(item, index) in list" :key="item.id" class="waterfall-item-cell">
|
|
198
|
+
<view class="waterfall-item">
|
|
199
|
+
<view class="waterfall-item__image">
|
|
200
|
+
<image :src="item.image" mode="widthFix"></image>
|
|
201
|
+
</view>
|
|
202
|
+
<view class="waterfall-item__ft">
|
|
203
|
+
<view class="waterfall-item__ft__title"><text>{{ item.title }}</text></view>
|
|
204
|
+
<view class="waterfall-item__ft__desc"><text>{{ item.desc }}</text></view>
|
|
205
|
+
</view>
|
|
206
|
+
</view>
|
|
207
|
+
</cell>
|
|
208
|
+
</uv-waterfall>
|
|
209
|
+
</template>
|
|
210
|
+
<script>
|
|
211
|
+
export default {
|
|
212
|
+
data() {
|
|
213
|
+
return { list: [] }
|
|
214
|
+
},
|
|
215
|
+
methods: {
|
|
216
|
+
async init() {
|
|
217
|
+
const { data } = await this.getData()
|
|
218
|
+
this.list.push.apply(this.list, data)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
</script>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 优化建议(vue) {#optimize}
|
|
226
|
+
|
|
227
|
+
1. 可用 uv-image 替代 image,支持加载中、失败反馈
|
|
228
|
+
2. `addTime` 越小体验越好,但两列高度差可能变大;可让后端返回宽高,前端提前算好每张图尺寸
|
|
229
|
+
3. 页面跳走前清空,避免 `@changeList` 继续触发导致异常:
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
onHide() {
|
|
233
|
+
this.$refs.waterfall.clear()
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## API {#api}
|
|
238
|
+
|
|
239
|
+
### Waterfall Props {#props}
|
|
240
|
+
|
|
241
|
+
| 参数 | 类型 | 默认值 | 说明 |
|
|
242
|
+
| --- | --- | --- | --- |
|
|
243
|
+
| v-model | Array | [] | 瀑布流数据(vue) |
|
|
244
|
+
| idKey | String | id | 数据 id 字段,用于删除(vue) |
|
|
245
|
+
| addTime | Number | 200 | 每次插入间隔 ms,影响两列高度(vue) |
|
|
246
|
+
| columnCount | Number \| String | 2 | 列数,1–5 |
|
|
247
|
+
| columnGap | Number \| String | 20 | 列间距 px |
|
|
248
|
+
| leftGap | Number \| String | 0 | 左侧与列表间距 |
|
|
249
|
+
| rightGap | Number \| String | 0 | 右侧与列表间距 |
|
|
250
|
+
| showScrollbar | Boolean | false | 是否显示滚动条(nvue) |
|
|
251
|
+
| columnWidth | Number \| String | auto | 列宽 px(nvue) |
|
|
252
|
+
| width | Number \| String | 屏幕宽度 | 组件宽度(nvue) |
|
|
253
|
+
| height | Number \| String | 屏幕高度 | 组件高度(nvue) |
|
|
254
|
+
|
|
255
|
+
### Waterfall Methods {#methods}
|
|
256
|
+
|
|
257
|
+
| 方法名 | 说明 | 适用 |
|
|
258
|
+
| --- | --- | --- |
|
|
259
|
+
| remove(id) | 根据 id 删除某条数据 | vue |
|
|
260
|
+
| clear() | 清空所有数据 | vue |
|
|
261
|
+
|
|
262
|
+
### Waterfall Events {#events}
|
|
263
|
+
|
|
264
|
+
| 事件名 | 说明 | 回调参数 | 适用 |
|
|
265
|
+
| --- | --- | --- | --- |
|
|
266
|
+
| @changeList | 数据分配时触发,必须手动 push 到 list1/list2 | `{ name, value }`,如 `{ list1, {...} }` | vue |
|
|
267
|
+
| @finish | 加载完成 | - | vue |
|
|
268
|
+
| @clear | 清空时 | - | vue |
|
|
269
|
+
| @remove | 删除某条时 | id | vue |
|
|
270
|
+
| @scrolltolower | 滚动到底部 | - | nvue |
|
|
271
|
+
|
|
272
|
+
### Waterfall Slots {#slots}
|
|
273
|
+
|
|
274
|
+
| 插槽名 | 说明 |
|
|
275
|
+
| --- | --- |
|
|
276
|
+
| list1, list2, list3... | 对应列内容,列数 N 需定义 list1~listN(vue) |
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
alwaysApply: true
|
|
3
|
+
---
|
|
4
|
+
# 回答规范
|
|
5
|
+
|
|
6
|
+
- 回答的时候必须要说:“项目规范已了解”。然后再回答xxxx
|
|
7
|
+
|
|
8
|
+
# 国际化规范
|
|
9
|
+
- 国际化统一使用中文key,并且放在国际化json对象的最外层,使用const { t } = useI18n()
|
|
10
|
+
- 简单的词,符号不参与国际化,采用拼接的方式,例如: `用户名称:`国际化出来应该是`${t('用户名称')}:`
|
|
11
|
+
|
|
12
|
+
# eslint规范
|
|
13
|
+
|
|
14
|
+
- eslint问题你都不需要修复。你只需要写代码。我的编辑器会自动修复。
|
|
15
|
+
|
|
16
|
+
# 编码规范
|
|
17
|
+
|
|
18
|
+
- 统一使用es6+语法,例如:禁止使用.then语法
|
|
19
|
+
- 方法命名统一使用动名词组合,语义清晰,例如:`loadRoleList`、`handleSubmit`
|
|
20
|
+
- 变量命名统一使用小驼峰,禁止中英文混合命名
|
|
21
|
+
- 常量命名统一使用全大写+下划线,例如:`API_TIMEOUT`
|
|
22
|
+
- 提倡提前 `return` 降低嵌套层级,非必要不超过3层嵌套
|
|
23
|
+
|
|
24
|
+
# Vue开发规范
|
|
25
|
+
|
|
26
|
+
- 新项目统一使用 Composition API + `<script setup>`
|
|
27
|
+
- 单文件组件内容顺序统一为:`script` > `template` > `style`
|
|
28
|
+
- 禁止在同一元素上同时使用 `v-for` 与 `v-if`
|
|
29
|
+
- `v-for` 必须绑定稳定且唯一的 `key`,禁止使用不稳定 key
|
|
30
|
+
|
|
31
|
+
# 页面与组件结构规范
|
|
32
|
+
|
|
33
|
+
- 页面目录统一使用短横线命名(xxx-xxx)
|
|
34
|
+
- 页面拆分出来的业务子组件,统一放在页面根目录下的 `components` 目录
|
|
35
|
+
- 组件目录与组件名使用大驼峰,且至少两个单词
|
|
36
|
+
|
|
37
|
+
# TypeScript规范
|
|
38
|
+
|
|
39
|
+
- 接口命名统一使用 `I` 前缀,例如:`IUserInfo`
|
|
40
|
+
- 所有跟请求相关的类型必须放到@types目录下
|
|
41
|
+
|
|
42
|
+
# 组件开发规范
|
|
43
|
+
|
|
44
|
+
- `defineProps` 中的每个字段需有业务注释
|
|
45
|
+
- `props` 的字段应明确 `required` 或 `default`(二选一,语义清晰)
|
|
46
|
+
- 严格遵循单向数据流:父传子用 `props`,子传父用 `emit`,禁止子组件直接修改父组件传入的 `props`
|
|
47
|
+
- 使用 `v-model` 时需显式声明对应的 `props` 与 `update:*` 事件
|
|
48
|
+
- 对于对象/数组类型 `props`,子组件禁止直接改引用内字段,应通过 `emit` 通知父组件更新
|
|
49
|
+
|
|
50
|
+
# 路由规范
|
|
51
|
+
|
|
52
|
+
- 路由跳转统一使用对象写法:`router.push({ path, query })`
|
|
53
|
+
- 禁止手写 URL 字符串拼接 query 参数
|
|
54
|
+
|
|
55
|
+
# CSS规范
|
|
56
|
+
|
|
57
|
+
- 优先查看项目中是否存在unocss,如果存在则优先使用unocss的语法,并且精确到单位,例如 mt-12px(uniapp项目中,则为mt-24rpx)
|
|
58
|
+
- 非必要情况下,尽量不使用行内样式
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# 设计规范
|
|
62
|
+
|
|
63
|
+
- 任何项目的新页面设计,**默认优先使用浅色风格**。只有在你特别说明需要深色、或者页面为了对比/安全感等需求必须深色时,才采用深色主题。
|
|
64
|
+
|
|
65
|
+
# 组件规范
|
|
66
|
+
|
|
67
|
+
- 优先使用@/components中的组件,否则查看package.json,常见的有element-ui,element-plus,uv-ui
|
|
68
|
+
- uv-ui组件使用方法参考rules: uv-ui-docs
|
|
69
|
+
|
|
70
|
+
# 请求规范
|
|
71
|
+
|
|
72
|
+
- 请求必须使用async await
|
|
73
|
+
- 请求定义名称需使用`req${动名词组合}`,例如reqGetUserInfo,reqGetUserListPage
|
|
74
|
+
- 请求入参不需要单独定义类型。返回结果需定义类型。如果不知道返回了什么类型,先定义类型文件,然后使用{[key: string]: any]},并写上注释待补充
|
|
75
|
+
|
|
76
|
+
# 错误处理规范
|
|
77
|
+
|
|
78
|
+
- 对于已经由请求拦截器统一处理错误提示的接口,请勿在业务代码中再次对 `res.err !== 0` 分支调用 `showToast`,只需在 `res.err !== 0` 时直接 `return`
|
|
79
|
+
- 只在 `res.err === 0` 时做成功提示和后续逻辑(如跳转、刷新),不要额外包一层无意义的 `try/catch` 和重复的错误提示文案
|
|
80
|
+
- 仅在需要做特殊兜底或非标准错误处理(例如:本地计算抛错、非接口错误、需要上报埋点等)时再使用 `try/catch`,并在注释中说明原因
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# 安全规范
|
|
84
|
+
|
|
85
|
+
- 禁止在任何用户可控内容渲染场景直接使用 `v-html`;确需渲染富文本时,必须先做白名单净化(如 `DOMPurify.sanitize`)
|
|
86
|
+
- 生产环境必须关闭 sourceMap,禁止暴露 `.map` 文件
|
|
87
|
+
- 禁止在前端硬编码任何云厂商长期密钥(如 OSS AccessKey);统一使用后端下发的临时凭证(STS/RamRole)
|
|
88
|
+
- 禁止使用高危动态执行 API:`eval`、`new Function`、`Function` 构造器、字符串形式 `setTimeout/setInterval`
|
|
89
|
+
- 禁止通过 `innerHTML` 拼接脚本内容执行动态代码,优先 `textContent`/`createElement`
|
|
90
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
alwaysApply: false
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# uv-ui - Vue / uni-app 组件库
|
|
6
|
+
|
|
7
|
+
uv-ui 是一款适用于 Vue 和 uni-app 的跨端 UI 组件库,提供丰富的移动端与多端组件,帮助开发者快速构建高质量应用界面。组件文档在项目根目录中的docs/uv-ui-docs文件夹中。
|
|
8
|
+
|
|
9
|
+
## Navigation
|
|
10
|
+
|
|
11
|
+
- [uv-ui 官网](https://www.uvui.cn/)
|
|
12
|
+
- [组件概览](docs/uv-ui-docs/components.md)
|
|
13
|
+
|
|
14
|
+
## 最新组件
|
|
15
|
+
|
|
16
|
+
- [Skeletons 骨架屏](docs/uv-ui-docs/skeletons.md)
|
|
17
|
+
- [Calendars 新版日历](docs/uv-ui-docs/calendars.md)
|
|
18
|
+
- [DropDown 下拉筛选](docs/uv-ui-docs/dropDown.md)
|
|
19
|
+
- [Vtabs 垂直选项卡](docs/uv-ui-docs/vtabs.md)
|
|
20
|
+
- [PickColor 颜色选择](docs/uv-ui-docs/pickColor.md)
|
|
21
|
+
- [QRCode 二维码](docs/uv-ui-docs/qrcode.md)
|
|
22
|
+
- [Waterfall 瀑布流](docs/uv-ui-docs/waterfall.md)
|
|
23
|
+
|
|
24
|
+
## 基础组件
|
|
25
|
+
|
|
26
|
+
- [Color 色彩](docs/uv-ui-docs/color.md)
|
|
27
|
+
- [Layout 布局](docs/uv-ui-docs/layout.md)
|
|
28
|
+
- [Icon 图标](docs/uv-ui-docs/icon.md)
|
|
29
|
+
- [Button 按钮](docs/uv-ui-docs/button.md)
|
|
30
|
+
- [Text 文本](docs/uv-ui-docs/text.md)
|
|
31
|
+
- [Link 超链接](docs/uv-ui-docs/link.md)
|
|
32
|
+
- [Image 图片](docs/uv-ui-docs/image.md)
|
|
33
|
+
- [Transition 动画](docs/uv-ui-docs/transition.md)
|
|
34
|
+
|
|
35
|
+
## 表单组件
|
|
36
|
+
|
|
37
|
+
- [Form 表单](docs/uv-ui-docs/form.md)
|
|
38
|
+
- [Input 输入框](docs/uv-ui-docs/input.md)
|
|
39
|
+
- [Textarea 文本域](docs/uv-ui-docs/textarea.md)
|
|
40
|
+
- [Checkbox 复选框](docs/uv-ui-docs/checkbox.md)
|
|
41
|
+
- [Radio 单选框](docs/uv-ui-docs/radio.md)
|
|
42
|
+
- [Switch 开关选择器](docs/uv-ui-docs/switch.md)
|
|
43
|
+
- [Calendar 日历](docs/uv-ui-docs/calendar.md)
|
|
44
|
+
- [Picker 选择器](docs/uv-ui-docs/picker.md)
|
|
45
|
+
- [DatetimePicker 时间选择器](docs/uv-ui-docs/datetimePicker.md)
|
|
46
|
+
- [Code 验证码倒计时](docs/uv-ui-docs/code.md)
|
|
47
|
+
- [Keyboard 键盘](docs/uv-ui-docs/keyboard.md)
|
|
48
|
+
- [Rate 评分](docs/uv-ui-docs/rate.md)
|
|
49
|
+
- [Search 搜索](docs/uv-ui-docs/search.md)
|
|
50
|
+
- [NumberBox 步进器](docs/uv-ui-docs/numberBox.md)
|
|
51
|
+
- [Upload 上传](docs/uv-ui-docs/upload.md)
|
|
52
|
+
- [Slider 滑动选择器](docs/uv-ui-docs/slider.md)
|
|
53
|
+
|
|
54
|
+
## 数据组件
|
|
55
|
+
|
|
56
|
+
- [List 列表](docs/uv-ui-docs/list.md)
|
|
57
|
+
- [IndexList 索引列表](docs/uv-ui-docs/indexList.md)
|
|
58
|
+
- [Tag 标签](docs/uv-ui-docs/tag.md)
|
|
59
|
+
- [LineProgress 线形进度条](docs/uv-ui-docs/lineProgress.md)
|
|
60
|
+
- [Badge 徽标数](docs/uv-ui-docs/badge.md)
|
|
61
|
+
- [CountDown 倒计时](docs/uv-ui-docs/countDown.md)
|
|
62
|
+
- [CountTo 数字滚动](docs/uv-ui-docs/countTo.md)
|
|
63
|
+
- [Avatar 头像](docs/uv-ui-docs/avatar.md)
|
|
64
|
+
- [Skeleton 骨架屏](docs/uv-ui-docs/skeleton.md)
|
|
65
|
+
- [LoadingIcon 加载动画](docs/uv-ui-docs/loadingIcon.md)
|
|
66
|
+
- [LoadingPage 加载页](docs/uv-ui-docs/loadingPage.md)
|
|
67
|
+
- [LoadMore 加载更多](docs/uv-ui-docs/loadMore.md)
|
|
68
|
+
- [Empty 内容为空](docs/uv-ui-docs/empty.md)
|
|
69
|
+
|
|
70
|
+
## 反馈组件
|
|
71
|
+
|
|
72
|
+
- [Tooltip 长按提示](docs/uv-ui-docs/tooltip.md)
|
|
73
|
+
- [Alert 警告提示](docs/uv-ui-docs/alert.md)
|
|
74
|
+
- [Toast 消息提示](docs/uv-ui-docs/toast.md)
|
|
75
|
+
- [NoticeBar 滚动通知](docs/uv-ui-docs/noticeBar.md)
|
|
76
|
+
- [Notify 消息提示](docs/uv-ui-docs/notify.md)
|
|
77
|
+
- [NoNetwork 无网络提示](docs/uv-ui-docs/noNetwork.md)
|
|
78
|
+
- [Popup 弹出层](docs/uv-ui-docs/popup.md)
|
|
79
|
+
- [Modal 模态框](docs/uv-ui-docs/modal.md)
|
|
80
|
+
|
|
81
|
+
## 布局组件
|
|
82
|
+
|
|
83
|
+
- [Cell 单元格](docs/uv-ui-docs/cell.md)
|
|
84
|
+
- [SwipeAction 滑动单元格](docs/uv-ui-docs/swipeAction.md)
|
|
85
|
+
- [ScrollList 横向滚动列表](docs/uv-ui-docs/scrollList.md)
|
|
86
|
+
- [Swiper 轮播图](docs/uv-ui-docs/swiper.md)
|
|
87
|
+
- [Collapse 折叠面板](docs/uv-ui-docs/collapse.md)
|
|
88
|
+
- [Grid 宫格布局](docs/uv-ui-docs/grid.md)
|
|
89
|
+
- [Album 相册](docs/uv-ui-docs/album.md)
|
|
90
|
+
|
|
91
|
+
## 导航组件
|
|
92
|
+
|
|
93
|
+
- [Tabbar 底部导航栏](docs/uv-ui-docs/tabbar.md)
|
|
94
|
+
- [BackTop 返回顶部](docs/uv-ui-docs/backTop.md)
|
|
95
|
+
- [Navbar 自定义导航栏](docs/uv-ui-docs/navbar.md)
|
|
96
|
+
- [ActionSheet 操作菜单](docs/uv-ui-docs/actionSheet.md)
|
|
97
|
+
- [Tabs 标签选项卡](docs/uv-ui-docs/tabs.md)
|
|
98
|
+
- [Steps 步骤条](docs/uv-ui-docs/steps.md)
|
|
99
|
+
- [Subsection 分段器](docs/uv-ui-docs/subsection.md)
|
|
100
|
+
- [Sticky 吸顶](docs/uv-ui-docs/sticky.md)
|
|
101
|
+
|
|
102
|
+
## 其他组件
|
|
103
|
+
|
|
104
|
+
- [Parse 富文本解析器](docs/uv-ui-docs/parse.md)
|
|
105
|
+
- [Overlay 遮罩层](docs/uv-ui-docs/overlay.md)
|
|
106
|
+
- [CodeInput 验证码输入](docs/uv-ui-docs/codeInput.md)
|
|
107
|
+
- [ReadMore 展开阅读更多](docs/uv-ui-docs/readMore.md)
|
|
108
|
+
- [Line 线条](docs/uv-ui-docs/line.md)
|
|
109
|
+
- [Gap 间隔槽](docs/uv-ui-docs/gap.md)
|
|
110
|
+
- [Divider 分割线](docs/uv-ui-docs/divider.md)
|
|
111
|
+
- [More 其他小组件](docs/uv-ui-docs/more.md)
|