@gmcb/uv-ui 0.3.4 → 0.3.6
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/CHANGELOG.md +35 -17
- package/README.md +10 -64
- package/components/uv-alert/props.js +10 -0
- package/components/uv-alert/uv-alert.vue +4 -2
- package/components/uv-image/uv-image.vue +296 -296
- package/components/uv-overlay/props.js +29 -29
- package/components/uv-overlay/uv-overlay.vue +87 -87
- package/libs/function/http.js +4 -4
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,23 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [0.3.
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @gmcb/uv-ui
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## [0.3.3](http://10.10.10.16/caoben/front-end/compare/@gmcb/uv-ui@0.3.2...@gmcb/uv-ui@0.3.3) (2026-06-23)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @gmcb/uv-ui
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [0.3.2](http://10.10.10.16/caoben/front-end/compare/@gmcb/uv-ui@0.3.1...@gmcb/uv-ui@0.3.2) (2026-06-15)
|
|
6
|
+
## [0.3.6](http://10.10.10.16/caoben/front-end-tools/compare/@gmcb/uv-ui@0.3.5...@gmcb/uv-ui@0.3.6) (2026-11-09)
|
|
23
7
|
|
|
24
8
|
**Note:** Version bump only for package @gmcb/uv-ui
|
|
25
9
|
|
|
@@ -28,6 +12,40 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
28
12
|
|
|
29
13
|
|
|
30
14
|
|
|
15
|
+
## [0.3.5](http://10.10.10.16/caoben/front-end/compare/@gmcb/uv-ui@0.3.4...@gmcb/uv-ui@0.3.5) (2026-07-02)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package @gmcb/uv-ui
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [0.3.4](http://10.10.10.16/caoben/front-end/compare/@gmcb/uv-ui@0.3.3...@gmcb/uv-ui@0.3.4) (2026-07-02)
|
|
25
|
+
|
|
26
|
+
**Note:** Version bump only for package @gmcb/uv-ui
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## [0.3.3](http://10.10.10.16/caoben/front-end/compare/@gmcb/uv-ui@0.3.2...@gmcb/uv-ui@0.3.3) (2026-06-23)
|
|
33
|
+
|
|
34
|
+
**Note:** Version bump only for package @gmcb/uv-ui
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [0.3.2](http://10.10.10.16/caoben/front-end/compare/@gmcb/uv-ui@0.3.1...@gmcb/uv-ui@0.3.2) (2026-06-15)
|
|
41
|
+
|
|
42
|
+
**Note:** Version bump only for package @gmcb/uv-ui
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
31
49
|
## [0.3.1](http://10.10.10.16/caoben/front-end/compare/@gmcb/uv-ui@0.2.27...@gmcb/uv-ui@0.3.1) (2026-05-31)
|
|
32
50
|
|
|
33
51
|
**Note:** Version bump only for package @gmcb/uv-ui
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @gmcb/uv-ui
|
|
2
2
|
|
|
3
|
-
基于 uv-ui 的 uni-app 多端 UI
|
|
3
|
+
基于 uv-ui 的 uni-app 多端 UI 组件包,包含 `uv-*` 组件、主题样式、工具函数、请求实例和 `$uv` 全局能力。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -35,7 +35,7 @@ export function createApp() {
|
|
|
35
35
|
|
|
36
36
|
## easycom 配置
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
在 `pages.json` 中配置 easycom 后,组件可在页面中直接使用:
|
|
39
39
|
|
|
40
40
|
```json
|
|
41
41
|
{
|
|
@@ -48,71 +48,17 @@ export function createApp() {
|
|
|
48
48
|
}
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
<template>
|
|
55
|
-
<uv-button type="primary">提交</uv-button>
|
|
56
|
-
<uv-icon name="search" size="24"></uv-icon>
|
|
57
|
-
</template>
|
|
51
|
+
```vue
|
|
52
|
+
<uv-button type="primary">提交</uv-button>
|
|
53
|
+
<uv-icon name="search" size="24" />
|
|
58
54
|
```
|
|
59
55
|
|
|
60
56
|
## 全局能力
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
| 能力 | 说明 |
|
|
65
|
-
| --- | --- |
|
|
66
|
-
| `uni.$uv.http` | 基于 `luch-request` 的请求实例。 |
|
|
67
|
-
| `uni.$uv.route` | 路由跳转封装。 |
|
|
68
|
-
| `uni.$uv.config` | uv-ui 配置。 |
|
|
69
|
-
| `uni.$uv.debounce` / `uni.$uv.throttle` | 防抖与节流。 |
|
|
70
|
-
| `uni.$uv.test` | 常用校验方法。 |
|
|
71
|
-
| `uni.$uv.colorGradient`、`hexToRgb`、`rgbToHex` | 颜色工具。 |
|
|
72
|
-
| `uni.$uv.platform` | 平台判断工具。 |
|
|
73
|
-
| `uni.$uv.compress` | 压缩工具。 |
|
|
74
|
-
|
|
75
|
-
Vue 3 项目中也可通过组件实例访问 `$uv`。
|
|
76
|
-
|
|
77
|
-
## 组件目录
|
|
78
|
-
|
|
79
|
-
组件位于 `components/uv-*`,常用组件包括:
|
|
80
|
-
|
|
81
|
-
- `uv-button`
|
|
82
|
-
- `uv-icon`
|
|
83
|
-
- `uv-form`
|
|
84
|
-
- `uv-input`
|
|
85
|
-
- `uv-popup`
|
|
86
|
-
- `uv-modal`
|
|
87
|
-
- `uv-tabs`
|
|
88
|
-
- `uv-navbar`
|
|
89
|
-
- `uv-upload`
|
|
90
|
-
- `uv-calendar`
|
|
91
|
-
- `uv-datetime-picker`
|
|
92
|
-
- `uv-swiper`
|
|
93
|
-
- `uv-list`
|
|
94
|
-
- `uv-cell`
|
|
95
|
-
- `uv-toast`
|
|
96
|
-
|
|
97
|
-
更多组件可查看 `components` 目录或 uv-ui 官方文档。
|
|
98
|
-
|
|
99
|
-
## 参考链接
|
|
100
|
-
|
|
101
|
-
- [本包文档入口](./docs/index.md)
|
|
102
|
-
- [uv-ui 官方文档](https://www.uvui.cn)
|
|
103
|
-
- [uv-ui 演示地址](https://h5.uvui.cn)
|
|
104
|
-
- [uv-ui 更新日志](https://www.uvui.cn/components/changelog.html)
|
|
105
|
-
|
|
106
|
-
## 本地文档
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
pnpm -C packages/uv-ui run docs:dev
|
|
110
|
-
pnpm -C packages/uv-ui run docs:build
|
|
111
|
-
pnpm -C packages/uv-ui run docs:preview
|
|
112
|
-
```
|
|
58
|
+
注册后可通过 `uni.$uv` 使用请求、路由、配置、防抖/节流、校验、颜色、平台判断、压缩等工具;Vue 3 项目中也可通过组件实例访问 `$uv`。完整 API 见 [docs/api/index.md](docs/api/index.md)。
|
|
113
59
|
|
|
114
|
-
##
|
|
60
|
+
## 文档
|
|
115
61
|
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
62
|
+
- 本包完整文档入口:[docs/index.md](docs/index.md)
|
|
63
|
+
- [uv-ui 官方文档](https://www.uvui.cn)、[演示地址](https://h5.uvui.cn)、[更新日志](https://www.uvui.cn/components/changelog.html)
|
|
64
|
+
- 开发与验证约定:[AGENTS.md](AGENTS.md)
|
|
@@ -40,6 +40,16 @@ export default {
|
|
|
40
40
|
type: [String, Number],
|
|
41
41
|
default: 14
|
|
42
42
|
},
|
|
43
|
+
// 图标大小
|
|
44
|
+
iconSize: {
|
|
45
|
+
type: [String, Number],
|
|
46
|
+
default: 18
|
|
47
|
+
},
|
|
48
|
+
// 关闭按钮图标大小
|
|
49
|
+
closeSize: {
|
|
50
|
+
type: [String, Number],
|
|
51
|
+
default: 15
|
|
52
|
+
},
|
|
43
53
|
...uni.$uv?.props?.alert
|
|
44
54
|
}
|
|
45
55
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
>
|
|
16
16
|
<uv-icon
|
|
17
17
|
:name="iconName"
|
|
18
|
-
size="
|
|
18
|
+
:size="$uv.addUnit(iconSize)"
|
|
19
19
|
:color="iconColor"
|
|
20
20
|
></uv-icon>
|
|
21
21
|
</view>
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
<uv-icon
|
|
53
53
|
name="close"
|
|
54
54
|
:color="iconColor"
|
|
55
|
-
size="
|
|
55
|
+
:size="$uv.addUnit(closeSize)"
|
|
56
56
|
></uv-icon>
|
|
57
57
|
</view>
|
|
58
58
|
</view>
|
|
@@ -76,6 +76,8 @@
|
|
|
76
76
|
* @property {String} effect 多图时,图片缩放裁剪的模式 (默认 'light' )
|
|
77
77
|
* @property {Boolean} center 文字是否居中 (默认 false )
|
|
78
78
|
* @property {String | Number} fontSize 字体大小 (默认 14 )
|
|
79
|
+
* @property {String | Number} iconSize 图标大小 (默认 18 )
|
|
80
|
+
* @property {String | Number} closeSize 关闭按钮图标大小 (默认 15 )
|
|
79
81
|
* @property {Object} customStyle 定义需要用到的外部样式
|
|
80
82
|
* @event {Function} click 点击组件时触发
|
|
81
83
|
* @event {Function} close 关闭组件时触发
|
|
@@ -1,296 +1,296 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :style="viewStyle">
|
|
3
|
-
<uv-transition
|
|
4
|
-
:show="show"
|
|
5
|
-
mode="fade"
|
|
6
|
-
:duration="fade ? duration : 0"
|
|
7
|
-
:cell-child="cellChild"
|
|
8
|
-
:custom-style="wrapStyle"
|
|
9
|
-
>
|
|
10
|
-
<view
|
|
11
|
-
class="uv-image"
|
|
12
|
-
:class="[`uv-image--${elIndex}`]"
|
|
13
|
-
@tap="onClick"
|
|
14
|
-
:style="[wrapStyle, backgroundStyle]"
|
|
15
|
-
>
|
|
16
|
-
<image
|
|
17
|
-
v-if="!isError && observeShow"
|
|
18
|
-
:src="imageUrl"
|
|
19
|
-
:mode="mode"
|
|
20
|
-
@error="onErrorHandler"
|
|
21
|
-
@load="onLoadHandler"
|
|
22
|
-
:show-menu-by-longpress="showMenuByLongpress"
|
|
23
|
-
:lazy-load="lazyLoad"
|
|
24
|
-
class="uv-image__image"
|
|
25
|
-
:style="[imageStyle]"
|
|
26
|
-
:webp="webp"
|
|
27
|
-
></image>
|
|
28
|
-
<view
|
|
29
|
-
v-if="showLoading && loading"
|
|
30
|
-
class="uv-image__loading"
|
|
31
|
-
:style="{
|
|
32
|
-
borderRadius: shape == 'circle' ? '50%' : $uv.addUnit(radius),
|
|
33
|
-
backgroundColor: bgColor,
|
|
34
|
-
width: $uv.addUnit(width),
|
|
35
|
-
height: $uv.addUnit(height)
|
|
36
|
-
}"
|
|
37
|
-
>
|
|
38
|
-
<slot name="loading">
|
|
39
|
-
<uv-icon
|
|
40
|
-
:name="loadingIcon"
|
|
41
|
-
:width="width"
|
|
42
|
-
:height="height"
|
|
43
|
-
></uv-icon>
|
|
44
|
-
</slot>
|
|
45
|
-
</view>
|
|
46
|
-
<view
|
|
47
|
-
v-if="showError && isError && !loading"
|
|
48
|
-
class="uv-image__error"
|
|
49
|
-
:style="{
|
|
50
|
-
borderRadius: shape == 'circle' ? '50%' : $uv.addUnit(radius),
|
|
51
|
-
width: $uv.addUnit(width),
|
|
52
|
-
height: $uv.addUnit(height)
|
|
53
|
-
}"
|
|
54
|
-
>
|
|
55
|
-
<slot name="error">
|
|
56
|
-
<uv-icon
|
|
57
|
-
:name="errorIcon"
|
|
58
|
-
:width="width"
|
|
59
|
-
:height="height"
|
|
60
|
-
></uv-icon>
|
|
61
|
-
</slot>
|
|
62
|
-
</view>
|
|
63
|
-
</view>
|
|
64
|
-
</uv-transition>
|
|
65
|
-
</view>
|
|
66
|
-
</template>
|
|
67
|
-
|
|
68
|
-
<script>
|
|
69
|
-
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
70
|
-
import mixin from '../../libs/mixin/mixin.js'
|
|
71
|
-
import props from './props.js';
|
|
72
|
-
/**
|
|
73
|
-
* Image 图片
|
|
74
|
-
* @description 此组件为uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
|
|
75
|
-
* @tutorial https://www.uvui.cn/components/image.html
|
|
76
|
-
* @property {String} src 图片地址
|
|
77
|
-
* @property {String} mode 裁剪模式,见官网说明 (默认 'aspectFill' )
|
|
78
|
-
* @property {String | Number} width 宽度,单位任意,如果为数值,则为px单位 (默认 '300' )
|
|
79
|
-
* @property {String | Number} height 高度,单位任意,如果为数值,则为px单位 (默认 '225' )
|
|
80
|
-
* @property {String} shape 图片形状,circle-圆形,square-方形 (默认 'square' )
|
|
81
|
-
* @property {String | Number} radius 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
|
|
82
|
-
* @property {Boolean} lazyLoad 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 (默认 true )
|
|
83
|
-
* @property {Boolean} showMenuByLongpress 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 (默认 true )
|
|
84
|
-
* @property {String} loadingIcon 加载中的图标,或者小图片 (默认 'photo' )
|
|
85
|
-
* @property {String} errorIcon 加载失败的图标,或者小图片 (默认 'error-circle' )
|
|
86
|
-
* @property {Boolean} showLoading 是否显示加载中的图标或者自定义的slot (默认 true )
|
|
87
|
-
* @property {Boolean} showError 是否显示加载错误的图标或者自定义的slot (默认 true )
|
|
88
|
-
* @property {Boolean} fade 是否需要淡入效果 (默认 true )
|
|
89
|
-
* @property {Boolean} webp 只支持网络资源,只对微信小程序有效 (默认 false )
|
|
90
|
-
* @property {String | Number} duration 搭配fade参数的过渡时间,单位ms (默认 500 )
|
|
91
|
-
* @property {String} bgColor 背景颜色,用于深色页面加载图片时,为了和背景色融合 (默认 '#f3f4f6' )
|
|
92
|
-
* @property {Object} customStyle 定义需要用到的外部样式
|
|
93
|
-
* @property {Boolean} compress 是否压缩图片,默认true
|
|
94
|
-
* @event {Function} click 点击图片时触发
|
|
95
|
-
* @event {Function} error 图片加载失败时触发
|
|
96
|
-
* @event {Function} load 图片加载成功时触发
|
|
97
|
-
* @example <uv-image width="100%" height="300px" :src="src"></uv-image>
|
|
98
|
-
*/
|
|
99
|
-
export default {
|
|
100
|
-
name: 'uv-image',
|
|
101
|
-
emits: ['click','load','error'],
|
|
102
|
-
mixins: [mpMixin, mixin, props],
|
|
103
|
-
data() {
|
|
104
|
-
return {
|
|
105
|
-
// 图片是否加载错误,如果是,则显示错误占位图
|
|
106
|
-
isError: false,
|
|
107
|
-
// 初始化组件时,默认为加载中状态
|
|
108
|
-
loading: true,
|
|
109
|
-
// 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
|
|
110
|
-
backgroundStyle: {},
|
|
111
|
-
// 用于fade模式的控制组件显示与否
|
|
112
|
-
show: false,
|
|
113
|
-
// 是否开启图片出现在可视范围进行加载(另一种懒加载)
|
|
114
|
-
observeShow: !this.observeLazyLoad,
|
|
115
|
-
elIndex: '',
|
|
116
|
-
// 因为props的值无法修改,故需要一个中间值
|
|
117
|
-
imgWidth: this.width,
|
|
118
|
-
// 因为props的值无法修改,故需要一个中间值
|
|
119
|
-
imgHeight: this.height,
|
|
120
|
-
thresholdValue: 50
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
watch: {
|
|
124
|
-
src: {
|
|
125
|
-
immediate: true,
|
|
126
|
-
handler(n) {
|
|
127
|
-
if (!n) {
|
|
128
|
-
// 如果传入null或者'',或者false,或者undefined,标记为错误状态
|
|
129
|
-
this.isError = true
|
|
130
|
-
} else {
|
|
131
|
-
this.isError = false;
|
|
132
|
-
this.loading = true;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
width(newVal){
|
|
137
|
-
// 这样做的目的是避免在更新时候,某些平台动画会恢复关闭状态
|
|
138
|
-
this.show = false;
|
|
139
|
-
this.$uv.sleep(2).then(res=>{
|
|
140
|
-
this.show = true;
|
|
141
|
-
});
|
|
142
|
-
this.imgWidth = newVal;
|
|
143
|
-
},
|
|
144
|
-
height(newVal){
|
|
145
|
-
// 这样做的目的是避免在更新时候,某些平台动画会恢复关闭状态
|
|
146
|
-
this.show = false;
|
|
147
|
-
this.$uv.sleep(2).then(res=>{
|
|
148
|
-
this.show = true;
|
|
149
|
-
});
|
|
150
|
-
this.imgHeight = newVal;
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
computed: {
|
|
154
|
-
wrapStyle() {
|
|
155
|
-
const style = {};
|
|
156
|
-
// 通过调用addUnit()方法,如果有单位,如百分比,px单位等,直接返回,如果是纯粹的数值,则加上rpx单位
|
|
157
|
-
if(this.mode !== 'heightFix') {
|
|
158
|
-
style.width = this.$uv.addUnit(this.imgWidth);
|
|
159
|
-
}
|
|
160
|
-
if(this.mode !== 'widthFix') {
|
|
161
|
-
style.height = this.$uv.addUnit(this.imgHeight);
|
|
162
|
-
}
|
|
163
|
-
// 如果是显示圆形,设置一个很多的半径值即可
|
|
164
|
-
style.borderRadius = this.shape == 'circle' ? '10000px' : this.$uv.addUnit(this.radius)
|
|
165
|
-
// 如果设置圆角,必须要有hidden,否则可能圆角无效
|
|
166
|
-
style.overflow = 'hidden';
|
|
167
|
-
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle));
|
|
168
|
-
},
|
|
169
|
-
viewStyle({ wrapStyle }) {
|
|
170
|
-
const { width, height } = wrapStyle;
|
|
171
|
-
return {
|
|
172
|
-
width,
|
|
173
|
-
height,
|
|
174
|
-
};
|
|
175
|
-
},
|
|
176
|
-
imageStyle({ imgWidth, imgHeight }) {
|
|
177
|
-
return {
|
|
178
|
-
width: this.$uv.addUnit(imgWidth),
|
|
179
|
-
height: this.$uv.addUnit(imgHeight),
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
imageUrl({ src, imageStyle, compress }) {
|
|
183
|
-
return compress && uni.$uv.compress ? uni.$uv.compress.image(src, imageStyle) : src;
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
created() {
|
|
187
|
-
this.elIndex = this.$uv.guid();
|
|
188
|
-
this.observer = {}
|
|
189
|
-
this.observerName = 'lazyLoadContentObserver'
|
|
190
|
-
},
|
|
191
|
-
mounted() {
|
|
192
|
-
this.show = true;
|
|
193
|
-
this.$nextTick(()=>{
|
|
194
|
-
if(this.observeLazyLoad) this.observerFn();
|
|
195
|
-
})
|
|
196
|
-
},
|
|
197
|
-
methods: {
|
|
198
|
-
// 点击图片
|
|
199
|
-
onClick() {
|
|
200
|
-
this.$emit('click')
|
|
201
|
-
},
|
|
202
|
-
// 图片加载失败
|
|
203
|
-
onErrorHandler(err) {
|
|
204
|
-
this.loading = false
|
|
205
|
-
this.isError = true
|
|
206
|
-
this.$emit('error', err)
|
|
207
|
-
},
|
|
208
|
-
// 图片加载完成,标记loading结束
|
|
209
|
-
onLoadHandler(event) {
|
|
210
|
-
if(this.mode == 'widthFix') this.imgHeight = 'auto'
|
|
211
|
-
if(this.mode == 'heightFix') this.imgWidth = 'auto'
|
|
212
|
-
this.loading = false
|
|
213
|
-
this.isError = false
|
|
214
|
-
this.$emit('load', event)
|
|
215
|
-
this.removeBgColor()
|
|
216
|
-
},
|
|
217
|
-
// 移除图片的背景色
|
|
218
|
-
removeBgColor() {
|
|
219
|
-
// 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
|
|
220
|
-
this.backgroundStyle = {
|
|
221
|
-
backgroundColor: 'transparent'
|
|
222
|
-
};
|
|
223
|
-
},
|
|
224
|
-
// 观察图片是否在可见视口
|
|
225
|
-
observerFn(){
|
|
226
|
-
// 在需要用到懒加载的页面,在触发底部的时候触发tOnLazyLoadReachBottom事件,保证所有图片进行加载
|
|
227
|
-
this.$nextTick(() => {
|
|
228
|
-
uni.$once('onLazyLoadReachBottom', () => {
|
|
229
|
-
if (!this.observeShow) this.observeShow = true
|
|
230
|
-
})
|
|
231
|
-
})
|
|
232
|
-
setTimeout(() => {
|
|
233
|
-
// #ifndef APP-NVUE
|
|
234
|
-
this.disconnectObserver(this.observerName)
|
|
235
|
-
const contentObserver = uni.createIntersectionObserver(this)
|
|
236
|
-
contentObserver.relativeToViewport({
|
|
237
|
-
bottom: this.thresholdValue
|
|
238
|
-
}).observe(`.uv-image--${this.elIndex}`, (res) => {
|
|
239
|
-
if (res.intersectionRatio > 0) {
|
|
240
|
-
// 懒加载状态改变
|
|
241
|
-
this.observeShow = true
|
|
242
|
-
// 如果图片已经加载,去掉监听,减少性能消耗
|
|
243
|
-
this.disconnectObserver(this.observerName)
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
|
-
this[this.observerName] = contentObserver
|
|
247
|
-
// #endif
|
|
248
|
-
// #ifdef APP-NVUE
|
|
249
|
-
this.observeShow = true;
|
|
250
|
-
// #endif
|
|
251
|
-
}, 50)
|
|
252
|
-
},
|
|
253
|
-
disconnectObserver(observerName) {
|
|
254
|
-
const observer = this[observerName]
|
|
255
|
-
observer && observer.disconnect()
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
</script>
|
|
260
|
-
|
|
261
|
-
<style lang="scss" scoped>
|
|
262
|
-
@import '../../libs/css/components.scss';
|
|
263
|
-
@import '../../libs/css/color.scss';
|
|
264
|
-
$uv-image-error-top:0px !default;
|
|
265
|
-
$uv-image-error-left:0px !default;
|
|
266
|
-
$uv-image-error-width:100% !default;
|
|
267
|
-
$uv-image-error-hight:100% !default;
|
|
268
|
-
$uv-image-error-background-color:$uv-bg-color !default;
|
|
269
|
-
$uv-image-error-color:$uv-tips-color !default;
|
|
270
|
-
$uv-image-error-font-size: 46rpx !default;
|
|
271
|
-
|
|
272
|
-
.uv-image {
|
|
273
|
-
position: relative;
|
|
274
|
-
transition: opacity 0.5s ease-in-out;
|
|
275
|
-
|
|
276
|
-
&__image {
|
|
277
|
-
width: 100%;
|
|
278
|
-
height: 100%;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
&__loading,
|
|
282
|
-
&__error {
|
|
283
|
-
position: absolute;
|
|
284
|
-
top: $uv-image-error-top;
|
|
285
|
-
left: $uv-image-error-left;
|
|
286
|
-
width: $uv-image-error-width;
|
|
287
|
-
height: $uv-image-error-hight;
|
|
288
|
-
@include flex;
|
|
289
|
-
align-items: center;
|
|
290
|
-
justify-content: center;
|
|
291
|
-
background-color: $uv-image-error-background-color;
|
|
292
|
-
color: $uv-image-error-color;
|
|
293
|
-
font-size: $uv-image-error-font-size;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view :style="viewStyle">
|
|
3
|
+
<uv-transition
|
|
4
|
+
:show="show"
|
|
5
|
+
mode="fade"
|
|
6
|
+
:duration="fade ? duration : 0"
|
|
7
|
+
:cell-child="cellChild"
|
|
8
|
+
:custom-style="wrapStyle"
|
|
9
|
+
>
|
|
10
|
+
<view
|
|
11
|
+
class="uv-image"
|
|
12
|
+
:class="[`uv-image--${elIndex}`]"
|
|
13
|
+
@tap="onClick"
|
|
14
|
+
:style="[wrapStyle, backgroundStyle]"
|
|
15
|
+
>
|
|
16
|
+
<image
|
|
17
|
+
v-if="!isError && observeShow"
|
|
18
|
+
:src="imageUrl"
|
|
19
|
+
:mode="mode"
|
|
20
|
+
@error="onErrorHandler"
|
|
21
|
+
@load="onLoadHandler"
|
|
22
|
+
:show-menu-by-longpress="showMenuByLongpress"
|
|
23
|
+
:lazy-load="lazyLoad"
|
|
24
|
+
class="uv-image__image"
|
|
25
|
+
:style="[imageStyle]"
|
|
26
|
+
:webp="webp"
|
|
27
|
+
></image>
|
|
28
|
+
<view
|
|
29
|
+
v-if="showLoading && loading"
|
|
30
|
+
class="uv-image__loading"
|
|
31
|
+
:style="{
|
|
32
|
+
borderRadius: shape == 'circle' ? '50%' : $uv.addUnit(radius),
|
|
33
|
+
backgroundColor: bgColor,
|
|
34
|
+
width: $uv.addUnit(width),
|
|
35
|
+
height: $uv.addUnit(height)
|
|
36
|
+
}"
|
|
37
|
+
>
|
|
38
|
+
<slot name="loading">
|
|
39
|
+
<uv-icon
|
|
40
|
+
:name="loadingIcon"
|
|
41
|
+
:width="width"
|
|
42
|
+
:height="height"
|
|
43
|
+
></uv-icon>
|
|
44
|
+
</slot>
|
|
45
|
+
</view>
|
|
46
|
+
<view
|
|
47
|
+
v-if="showError && isError && !loading"
|
|
48
|
+
class="uv-image__error"
|
|
49
|
+
:style="{
|
|
50
|
+
borderRadius: shape == 'circle' ? '50%' : $uv.addUnit(radius),
|
|
51
|
+
width: $uv.addUnit(width),
|
|
52
|
+
height: $uv.addUnit(height)
|
|
53
|
+
}"
|
|
54
|
+
>
|
|
55
|
+
<slot name="error">
|
|
56
|
+
<uv-icon
|
|
57
|
+
:name="errorIcon"
|
|
58
|
+
:width="width"
|
|
59
|
+
:height="height"
|
|
60
|
+
></uv-icon>
|
|
61
|
+
</slot>
|
|
62
|
+
</view>
|
|
63
|
+
</view>
|
|
64
|
+
</uv-transition>
|
|
65
|
+
</view>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script>
|
|
69
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
70
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
71
|
+
import props from './props.js';
|
|
72
|
+
/**
|
|
73
|
+
* Image 图片
|
|
74
|
+
* @description 此组件为uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
|
|
75
|
+
* @tutorial https://www.uvui.cn/components/image.html
|
|
76
|
+
* @property {String} src 图片地址
|
|
77
|
+
* @property {String} mode 裁剪模式,见官网说明 (默认 'aspectFill' )
|
|
78
|
+
* @property {String | Number} width 宽度,单位任意,如果为数值,则为px单位 (默认 '300' )
|
|
79
|
+
* @property {String | Number} height 高度,单位任意,如果为数值,则为px单位 (默认 '225' )
|
|
80
|
+
* @property {String} shape 图片形状,circle-圆形,square-方形 (默认 'square' )
|
|
81
|
+
* @property {String | Number} radius 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
|
|
82
|
+
* @property {Boolean} lazyLoad 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 (默认 true )
|
|
83
|
+
* @property {Boolean} showMenuByLongpress 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 (默认 true )
|
|
84
|
+
* @property {String} loadingIcon 加载中的图标,或者小图片 (默认 'photo' )
|
|
85
|
+
* @property {String} errorIcon 加载失败的图标,或者小图片 (默认 'error-circle' )
|
|
86
|
+
* @property {Boolean} showLoading 是否显示加载中的图标或者自定义的slot (默认 true )
|
|
87
|
+
* @property {Boolean} showError 是否显示加载错误的图标或者自定义的slot (默认 true )
|
|
88
|
+
* @property {Boolean} fade 是否需要淡入效果 (默认 true )
|
|
89
|
+
* @property {Boolean} webp 只支持网络资源,只对微信小程序有效 (默认 false )
|
|
90
|
+
* @property {String | Number} duration 搭配fade参数的过渡时间,单位ms (默认 500 )
|
|
91
|
+
* @property {String} bgColor 背景颜色,用于深色页面加载图片时,为了和背景色融合 (默认 '#f3f4f6' )
|
|
92
|
+
* @property {Object} customStyle 定义需要用到的外部样式
|
|
93
|
+
* @property {Boolean} compress 是否压缩图片,默认true
|
|
94
|
+
* @event {Function} click 点击图片时触发
|
|
95
|
+
* @event {Function} error 图片加载失败时触发
|
|
96
|
+
* @event {Function} load 图片加载成功时触发
|
|
97
|
+
* @example <uv-image width="100%" height="300px" :src="src"></uv-image>
|
|
98
|
+
*/
|
|
99
|
+
export default {
|
|
100
|
+
name: 'uv-image',
|
|
101
|
+
emits: ['click','load','error'],
|
|
102
|
+
mixins: [mpMixin, mixin, props],
|
|
103
|
+
data() {
|
|
104
|
+
return {
|
|
105
|
+
// 图片是否加载错误,如果是,则显示错误占位图
|
|
106
|
+
isError: false,
|
|
107
|
+
// 初始化组件时,默认为加载中状态
|
|
108
|
+
loading: true,
|
|
109
|
+
// 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
|
|
110
|
+
backgroundStyle: {},
|
|
111
|
+
// 用于fade模式的控制组件显示与否
|
|
112
|
+
show: false,
|
|
113
|
+
// 是否开启图片出现在可视范围进行加载(另一种懒加载)
|
|
114
|
+
observeShow: !this.observeLazyLoad,
|
|
115
|
+
elIndex: '',
|
|
116
|
+
// 因为props的值无法修改,故需要一个中间值
|
|
117
|
+
imgWidth: this.width,
|
|
118
|
+
// 因为props的值无法修改,故需要一个中间值
|
|
119
|
+
imgHeight: this.height,
|
|
120
|
+
thresholdValue: 50
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
watch: {
|
|
124
|
+
src: {
|
|
125
|
+
immediate: true,
|
|
126
|
+
handler(n) {
|
|
127
|
+
if (!n) {
|
|
128
|
+
// 如果传入null或者'',或者false,或者undefined,标记为错误状态
|
|
129
|
+
this.isError = true
|
|
130
|
+
} else {
|
|
131
|
+
this.isError = false;
|
|
132
|
+
this.loading = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
width(newVal){
|
|
137
|
+
// 这样做的目的是避免在更新时候,某些平台动画会恢复关闭状态
|
|
138
|
+
this.show = false;
|
|
139
|
+
this.$uv.sleep(2).then(res=>{
|
|
140
|
+
this.show = true;
|
|
141
|
+
});
|
|
142
|
+
this.imgWidth = newVal;
|
|
143
|
+
},
|
|
144
|
+
height(newVal){
|
|
145
|
+
// 这样做的目的是避免在更新时候,某些平台动画会恢复关闭状态
|
|
146
|
+
this.show = false;
|
|
147
|
+
this.$uv.sleep(2).then(res=>{
|
|
148
|
+
this.show = true;
|
|
149
|
+
});
|
|
150
|
+
this.imgHeight = newVal;
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
computed: {
|
|
154
|
+
wrapStyle() {
|
|
155
|
+
const style = {};
|
|
156
|
+
// 通过调用addUnit()方法,如果有单位,如百分比,px单位等,直接返回,如果是纯粹的数值,则加上rpx单位
|
|
157
|
+
if(this.mode !== 'heightFix') {
|
|
158
|
+
style.width = this.$uv.addUnit(this.imgWidth);
|
|
159
|
+
}
|
|
160
|
+
if(this.mode !== 'widthFix') {
|
|
161
|
+
style.height = this.$uv.addUnit(this.imgHeight);
|
|
162
|
+
}
|
|
163
|
+
// 如果是显示圆形,设置一个很多的半径值即可
|
|
164
|
+
style.borderRadius = this.shape == 'circle' ? '10000px' : this.$uv.addUnit(this.radius)
|
|
165
|
+
// 如果设置圆角,必须要有hidden,否则可能圆角无效
|
|
166
|
+
style.overflow = 'hidden';
|
|
167
|
+
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle));
|
|
168
|
+
},
|
|
169
|
+
viewStyle({ wrapStyle }) {
|
|
170
|
+
const { width, height } = wrapStyle;
|
|
171
|
+
return {
|
|
172
|
+
width,
|
|
173
|
+
height,
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
imageStyle({ imgWidth, imgHeight }) {
|
|
177
|
+
return {
|
|
178
|
+
width: this.$uv.addUnit(imgWidth),
|
|
179
|
+
height: this.$uv.addUnit(imgHeight),
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
imageUrl({ src, imageStyle, compress }) {
|
|
183
|
+
return compress && uni.$uv.compress ? uni.$uv.compress.image(src, imageStyle) : src;
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
created() {
|
|
187
|
+
this.elIndex = this.$uv.guid();
|
|
188
|
+
this.observer = {}
|
|
189
|
+
this.observerName = 'lazyLoadContentObserver'
|
|
190
|
+
},
|
|
191
|
+
mounted() {
|
|
192
|
+
this.show = true;
|
|
193
|
+
this.$nextTick(()=>{
|
|
194
|
+
if(this.observeLazyLoad) this.observerFn();
|
|
195
|
+
})
|
|
196
|
+
},
|
|
197
|
+
methods: {
|
|
198
|
+
// 点击图片
|
|
199
|
+
onClick() {
|
|
200
|
+
this.$emit('click')
|
|
201
|
+
},
|
|
202
|
+
// 图片加载失败
|
|
203
|
+
onErrorHandler(err) {
|
|
204
|
+
this.loading = false
|
|
205
|
+
this.isError = true
|
|
206
|
+
this.$emit('error', err)
|
|
207
|
+
},
|
|
208
|
+
// 图片加载完成,标记loading结束
|
|
209
|
+
onLoadHandler(event) {
|
|
210
|
+
if(this.mode == 'widthFix') this.imgHeight = 'auto'
|
|
211
|
+
if(this.mode == 'heightFix') this.imgWidth = 'auto'
|
|
212
|
+
this.loading = false
|
|
213
|
+
this.isError = false
|
|
214
|
+
this.$emit('load', event)
|
|
215
|
+
this.removeBgColor()
|
|
216
|
+
},
|
|
217
|
+
// 移除图片的背景色
|
|
218
|
+
removeBgColor() {
|
|
219
|
+
// 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
|
|
220
|
+
this.backgroundStyle = {
|
|
221
|
+
backgroundColor: 'transparent'
|
|
222
|
+
};
|
|
223
|
+
},
|
|
224
|
+
// 观察图片是否在可见视口
|
|
225
|
+
observerFn(){
|
|
226
|
+
// 在需要用到懒加载的页面,在触发底部的时候触发tOnLazyLoadReachBottom事件,保证所有图片进行加载
|
|
227
|
+
this.$nextTick(() => {
|
|
228
|
+
uni.$once('onLazyLoadReachBottom', () => {
|
|
229
|
+
if (!this.observeShow) this.observeShow = true
|
|
230
|
+
})
|
|
231
|
+
})
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
// #ifndef APP-NVUE
|
|
234
|
+
this.disconnectObserver(this.observerName)
|
|
235
|
+
const contentObserver = uni.createIntersectionObserver(this)
|
|
236
|
+
contentObserver.relativeToViewport({
|
|
237
|
+
bottom: this.thresholdValue
|
|
238
|
+
}).observe(`.uv-image--${this.elIndex}`, (res) => {
|
|
239
|
+
if (res.intersectionRatio > 0) {
|
|
240
|
+
// 懒加载状态改变
|
|
241
|
+
this.observeShow = true
|
|
242
|
+
// 如果图片已经加载,去掉监听,减少性能消耗
|
|
243
|
+
this.disconnectObserver(this.observerName)
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
this[this.observerName] = contentObserver
|
|
247
|
+
// #endif
|
|
248
|
+
// #ifdef APP-NVUE
|
|
249
|
+
this.observeShow = true;
|
|
250
|
+
// #endif
|
|
251
|
+
}, 50)
|
|
252
|
+
},
|
|
253
|
+
disconnectObserver(observerName) {
|
|
254
|
+
const observer = this[observerName]
|
|
255
|
+
observer && observer.disconnect()
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
</script>
|
|
260
|
+
|
|
261
|
+
<style lang="scss" scoped>
|
|
262
|
+
@import '../../libs/css/components.scss';
|
|
263
|
+
@import '../../libs/css/color.scss';
|
|
264
|
+
$uv-image-error-top:0px !default;
|
|
265
|
+
$uv-image-error-left:0px !default;
|
|
266
|
+
$uv-image-error-width:100% !default;
|
|
267
|
+
$uv-image-error-hight:100% !default;
|
|
268
|
+
$uv-image-error-background-color:$uv-bg-color !default;
|
|
269
|
+
$uv-image-error-color:$uv-tips-color !default;
|
|
270
|
+
$uv-image-error-font-size: 46rpx !default;
|
|
271
|
+
|
|
272
|
+
.uv-image {
|
|
273
|
+
position: relative;
|
|
274
|
+
transition: opacity 0.5s ease-in-out;
|
|
275
|
+
|
|
276
|
+
&__image {
|
|
277
|
+
width: 100%;
|
|
278
|
+
height: 100%;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
&__loading,
|
|
282
|
+
&__error {
|
|
283
|
+
position: absolute;
|
|
284
|
+
top: $uv-image-error-top;
|
|
285
|
+
left: $uv-image-error-left;
|
|
286
|
+
width: $uv-image-error-width;
|
|
287
|
+
height: $uv-image-error-hight;
|
|
288
|
+
@include flex;
|
|
289
|
+
align-items: center;
|
|
290
|
+
justify-content: center;
|
|
291
|
+
background-color: $uv-image-error-background-color;
|
|
292
|
+
color: $uv-image-error-color;
|
|
293
|
+
font-size: $uv-image-error-font-size;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
</style>
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
props: {
|
|
3
|
-
// 是否显示遮罩
|
|
4
|
-
show: {
|
|
5
|
-
type: Boolean,
|
|
6
|
-
default: false
|
|
7
|
-
},
|
|
8
|
-
// 层级z-index
|
|
9
|
-
zIndex: {
|
|
10
|
-
type: [String, Number],
|
|
11
|
-
default: 10070
|
|
12
|
-
},
|
|
13
|
-
// 遮罩的过渡时间,单位为ms
|
|
14
|
-
duration: {
|
|
15
|
-
type: [String, Number],
|
|
16
|
-
default: 300
|
|
17
|
-
},
|
|
18
|
-
// 不透明度值,当做rgba的第四个参数
|
|
19
|
-
opacity: {
|
|
20
|
-
type: [String, Number],
|
|
21
|
-
default: 0.5
|
|
22
|
-
},
|
|
23
|
-
// 显示时body是否添加overflow: hidden
|
|
24
|
-
hidden: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
default: true
|
|
27
|
-
},
|
|
28
|
-
...uni.$uv?.props?.overlay
|
|
29
|
-
}
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 是否显示遮罩
|
|
4
|
+
show: {
|
|
5
|
+
type: Boolean,
|
|
6
|
+
default: false
|
|
7
|
+
},
|
|
8
|
+
// 层级z-index
|
|
9
|
+
zIndex: {
|
|
10
|
+
type: [String, Number],
|
|
11
|
+
default: 10070
|
|
12
|
+
},
|
|
13
|
+
// 遮罩的过渡时间,单位为ms
|
|
14
|
+
duration: {
|
|
15
|
+
type: [String, Number],
|
|
16
|
+
default: 300
|
|
17
|
+
},
|
|
18
|
+
// 不透明度值,当做rgba的第四个参数
|
|
19
|
+
opacity: {
|
|
20
|
+
type: [String, Number],
|
|
21
|
+
default: 0.5
|
|
22
|
+
},
|
|
23
|
+
// 显示时body是否添加overflow: hidden
|
|
24
|
+
hidden: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
28
|
+
...uni.$uv?.props?.overlay
|
|
29
|
+
}
|
|
30
30
|
}
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<uv-transition
|
|
3
|
-
:show="show"
|
|
4
|
-
mode="fade"
|
|
5
|
-
custom-class="uv-overlay"
|
|
6
|
-
:duration="duration"
|
|
7
|
-
:custom-style="overlayStyle"
|
|
8
|
-
@click="clickHandler"
|
|
9
|
-
@touchmove.stop.prevent="clear"
|
|
10
|
-
>
|
|
11
|
-
<slot />
|
|
12
|
-
</uv-transition>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
17
|
-
import mixin from '../../libs/mixin/mixin.js'
|
|
18
|
-
import props from './props.js';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* overlay 遮罩
|
|
22
|
-
* @description 创建一个遮罩层,用于强调特定的页面元素,并阻止用户对遮罩下层的内容进行操作,一般用于弹窗场景
|
|
23
|
-
* @tutorial https://www.uvui.cn/components/overlay.html
|
|
24
|
-
* @property {Boolean} show 是否显示遮罩(默认 false )
|
|
25
|
-
* @property {String | Number} zIndex zIndex 层级(默认 10070 )
|
|
26
|
-
* @property {String | Number} duration 动画时长,单位毫秒(默认 300 )
|
|
27
|
-
* @property {String | Number} opacity 不透明度值,当做rgba的第四个参数 (默认 0.5 )
|
|
28
|
-
* @property {Object} customStyle 定义需要用到的外部样式
|
|
29
|
-
* @event {Function} click 点击遮罩发送事件
|
|
30
|
-
* @example <uv-overlay :show="show" @click="show = false"></uv-overlay>
|
|
31
|
-
*/
|
|
32
|
-
export default {
|
|
33
|
-
name: "uv-overlay",
|
|
34
|
-
emits: ['click'],
|
|
35
|
-
mixins: [mpMixin, mixin, props],
|
|
36
|
-
watch: {
|
|
37
|
-
show(newVal){
|
|
38
|
-
// #ifdef H5
|
|
39
|
-
if (this.hidden) {
|
|
40
|
-
if(newVal){
|
|
41
|
-
document.querySelector('body').style.overflow = 'hidden';
|
|
42
|
-
}else{
|
|
43
|
-
document.querySelector('body').style.overflow = '';
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// #endif
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
computed: {
|
|
50
|
-
overlayStyle() {
|
|
51
|
-
const style = {
|
|
52
|
-
position: 'fixed',
|
|
53
|
-
top: 0,
|
|
54
|
-
left: 0,
|
|
55
|
-
right: 0,
|
|
56
|
-
zIndex: this.zIndex,
|
|
57
|
-
bottom: 0,
|
|
58
|
-
'background-color': `rgba(0, 0, 0, ${this.opacity})`
|
|
59
|
-
}
|
|
60
|
-
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle))
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
methods: {
|
|
64
|
-
clickHandler() {
|
|
65
|
-
this.$emit('click')
|
|
66
|
-
},
|
|
67
|
-
clear() {}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
</script>
|
|
71
|
-
<style lang="scss" scoped>
|
|
72
|
-
/* #ifndef APP-NVUE */
|
|
73
|
-
$uv-overlay-top:0 !default;
|
|
74
|
-
$uv-overlay-left:0 !default;
|
|
75
|
-
$uv-overlay-width:100% !default;
|
|
76
|
-
$uv-overlay-height:100% !default;
|
|
77
|
-
$uv-overlay-background-color:rgba(0, 0, 0, .7) !default;
|
|
78
|
-
.uv-overlay {
|
|
79
|
-
position: fixed;
|
|
80
|
-
top:$uv-overlay-top;
|
|
81
|
-
left:$uv-overlay-left;
|
|
82
|
-
width: $uv-overlay-width;
|
|
83
|
-
height:$uv-overlay-height;
|
|
84
|
-
background-color:$uv-overlay-background-color;
|
|
85
|
-
}
|
|
86
|
-
/* #endif */
|
|
87
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<uv-transition
|
|
3
|
+
:show="show"
|
|
4
|
+
mode="fade"
|
|
5
|
+
custom-class="uv-overlay"
|
|
6
|
+
:duration="duration"
|
|
7
|
+
:custom-style="overlayStyle"
|
|
8
|
+
@click="clickHandler"
|
|
9
|
+
@touchmove.stop.prevent="clear"
|
|
10
|
+
>
|
|
11
|
+
<slot />
|
|
12
|
+
</uv-transition>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
17
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
18
|
+
import props from './props.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* overlay 遮罩
|
|
22
|
+
* @description 创建一个遮罩层,用于强调特定的页面元素,并阻止用户对遮罩下层的内容进行操作,一般用于弹窗场景
|
|
23
|
+
* @tutorial https://www.uvui.cn/components/overlay.html
|
|
24
|
+
* @property {Boolean} show 是否显示遮罩(默认 false )
|
|
25
|
+
* @property {String | Number} zIndex zIndex 层级(默认 10070 )
|
|
26
|
+
* @property {String | Number} duration 动画时长,单位毫秒(默认 300 )
|
|
27
|
+
* @property {String | Number} opacity 不透明度值,当做rgba的第四个参数 (默认 0.5 )
|
|
28
|
+
* @property {Object} customStyle 定义需要用到的外部样式
|
|
29
|
+
* @event {Function} click 点击遮罩发送事件
|
|
30
|
+
* @example <uv-overlay :show="show" @click="show = false"></uv-overlay>
|
|
31
|
+
*/
|
|
32
|
+
export default {
|
|
33
|
+
name: "uv-overlay",
|
|
34
|
+
emits: ['click'],
|
|
35
|
+
mixins: [mpMixin, mixin, props],
|
|
36
|
+
watch: {
|
|
37
|
+
show(newVal){
|
|
38
|
+
// #ifdef H5
|
|
39
|
+
if (this.hidden) {
|
|
40
|
+
if(newVal){
|
|
41
|
+
document.querySelector('body').style.overflow = 'hidden';
|
|
42
|
+
}else{
|
|
43
|
+
document.querySelector('body').style.overflow = '';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// #endif
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
computed: {
|
|
50
|
+
overlayStyle() {
|
|
51
|
+
const style = {
|
|
52
|
+
position: 'fixed',
|
|
53
|
+
top: 0,
|
|
54
|
+
left: 0,
|
|
55
|
+
right: 0,
|
|
56
|
+
zIndex: this.zIndex,
|
|
57
|
+
bottom: 0,
|
|
58
|
+
'background-color': `rgba(0, 0, 0, ${this.opacity})`
|
|
59
|
+
}
|
|
60
|
+
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle))
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
methods: {
|
|
64
|
+
clickHandler() {
|
|
65
|
+
this.$emit('click')
|
|
66
|
+
},
|
|
67
|
+
clear() {}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
</script>
|
|
71
|
+
<style lang="scss" scoped>
|
|
72
|
+
/* #ifndef APP-NVUE */
|
|
73
|
+
$uv-overlay-top:0 !default;
|
|
74
|
+
$uv-overlay-left:0 !default;
|
|
75
|
+
$uv-overlay-width:100% !default;
|
|
76
|
+
$uv-overlay-height:100% !default;
|
|
77
|
+
$uv-overlay-background-color:rgba(0, 0, 0, .7) !default;
|
|
78
|
+
.uv-overlay {
|
|
79
|
+
position: fixed;
|
|
80
|
+
top:$uv-overlay-top;
|
|
81
|
+
left:$uv-overlay-left;
|
|
82
|
+
width: $uv-overlay-width;
|
|
83
|
+
height:$uv-overlay-height;
|
|
84
|
+
background-color:$uv-overlay-background-color;
|
|
85
|
+
}
|
|
86
|
+
/* #endif */
|
|
87
|
+
</style>
|
package/libs/function/http.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Request from '../luch-request';
|
|
2
|
-
|
|
3
|
-
const http = new Request();
|
|
4
|
-
|
|
1
|
+
import Request from '../luch-request';
|
|
2
|
+
|
|
3
|
+
const http = new Request();
|
|
4
|
+
|
|
5
5
|
export default http;
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmcb/uv-ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "uv-ui 破釜沉舟之兼容vue3+2、nvue、app、h5、小程序等多端基于uni-app和uView2.x的生态框架,支持单独导入,开箱即用,利剑出击。",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"homepage": "https://git.keeprisk.cn/gmcb/front-end/tree/master/packages/uv-ui",
|
|
7
6
|
"scripts": {
|
|
8
7
|
"docs:dev": "vitepress dev . --config .vitepress/config.mts",
|
|
9
8
|
"docs:build": "vitepress build . --config .vitepress/config.mts"
|
|
@@ -29,5 +28,5 @@
|
|
|
29
28
|
"index.scss",
|
|
30
29
|
"theme.scss"
|
|
31
30
|
],
|
|
32
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "6ffb8b8188f29e8d4af167895737c9cb7bc0997f"
|
|
33
32
|
}
|