uview-pro 0.1.1 → 0.2.1
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 +57 -0
- package/components/common/props.ts +22 -0
- package/components/u-calendar/types.ts +12 -2
- package/components/u-calendar/u-calendar.vue +52 -6
- package/components/u-collapse/types.ts +2 -0
- package/components/u-collapse/u-collapse.vue +14 -13
- package/components/u-collapse-item/types.ts +2 -0
- package/components/u-collapse-item/u-collapse-item.vue +35 -28
- package/components/u-icon/types.ts +2 -2
- package/components/u-icon/u-icon.vue +11 -4
- package/components/u-input/u-input.vue +1 -1
- package/components/u-text/types.ts +69 -0
- package/components/u-text/u-text.vue +326 -0
- package/index.scss +2 -0
- package/index.ts +3 -176
- package/libs/css/style.components.scss +9 -0
- package/libs/css/style.nvue.scss +12 -0
- package/libs/css/style.vue.scss +41 -30
- package/libs/function/test.ts +57 -1
- package/libs/hooks/index.ts +3 -0
- package/libs/hooks/useParent.ts +22 -20
- package/libs/hooks/useRect.ts +33 -0
- package/libs/index.ts +291 -0
- package/libs/util/area.ts +1 -3771
- package/libs/util/async-validator.js +1 -1368
- package/libs/util/calendar.d.ts +57 -0
- package/libs/util/calendar.js +1 -0
- package/libs/util/city.ts +1 -432
- package/libs/util/province.ts +1 -37
- package/package.json +1 -1
- package/types/components.d.ts +1 -0
- package/types/global.d.ts +40 -0
- package/types/index.d.ts +2 -73
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
v-if="props.show"
|
|
4
|
+
class="u-text"
|
|
5
|
+
:class="[
|
|
6
|
+
props.bold ? 'u-text--bold' : '',
|
|
7
|
+
props.block ? 'u-text--block' : 'u-text--inline',
|
|
8
|
+
props.lines ? 'u-text--ellipsis' : '',
|
|
9
|
+
`u-text--align-${props.align}`,
|
|
10
|
+
customClass
|
|
11
|
+
]"
|
|
12
|
+
:style="textStyle"
|
|
13
|
+
@click="onClick"
|
|
14
|
+
>
|
|
15
|
+
<!-- prefixIcon -->
|
|
16
|
+
<view class="u-text__icon u-text__prefix-icon" v-if="props.prefixIcon">
|
|
17
|
+
<u-icon :name="props.prefixIcon" :custom-style="$u.toStyle(props.iconStyle)"></u-icon>
|
|
18
|
+
</view>
|
|
19
|
+
<!-- 价格模式 -->
|
|
20
|
+
<text v-if="props.mode === 'price'" :class="['u-text__price', props.type && `u-text__value--${props.type}`]" :style="textValueStyle"> ¥{{ displayValue }} </text>
|
|
21
|
+
<!-- link 模式 -->
|
|
22
|
+
<u-link v-else-if="props.mode === 'link'" :href="props.href" underLine>{{ displayValue }}</u-link>
|
|
23
|
+
<template v-else-if="props.openType && isMp">
|
|
24
|
+
<button
|
|
25
|
+
class="u-reset-button u-text__value"
|
|
26
|
+
:class="props.type && `u-text__value--${props.type}`"
|
|
27
|
+
:style="textValueStyle"
|
|
28
|
+
:openType="props.openType"
|
|
29
|
+
@getuserinfo="onGetUserInfo"
|
|
30
|
+
@contact="onContact"
|
|
31
|
+
@getphonenumber="onGetPhoneNumber"
|
|
32
|
+
@error="onError"
|
|
33
|
+
@launchapp="onLaunchApp"
|
|
34
|
+
@opensetting="onOpenSetting"
|
|
35
|
+
:lang="props.lang"
|
|
36
|
+
:session-from="props.sessionFrom"
|
|
37
|
+
:send-message-title="props.sendMessageTitle"
|
|
38
|
+
:send-message-path="props.sendMessagePath"
|
|
39
|
+
:send-message-img="props.sendMessageImg"
|
|
40
|
+
:show-message-card="props.showMessageCard"
|
|
41
|
+
:app-parameter="props.appParameter"
|
|
42
|
+
>
|
|
43
|
+
{{ displayValue }}
|
|
44
|
+
</button>
|
|
45
|
+
</template>
|
|
46
|
+
<!-- 默认模式 -->
|
|
47
|
+
<text v-else class="u-text__value" :style="textValueStyle" :class="[props.type && `u-text__value--${props.type}`, props.lines ? `u-line-${props.lines}` : '']">
|
|
48
|
+
{{ displayValue }}
|
|
49
|
+
</text>
|
|
50
|
+
<!-- 后缀图标 -->
|
|
51
|
+
<view class="u-text__icon u-text__suffix-icon" v-if="props.suffixIcon">
|
|
52
|
+
<u-icon :name="props.suffixIcon" :custom-style="$u.toStyle(props.iconStyle)"></u-icon>
|
|
53
|
+
</view>
|
|
54
|
+
</view>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script lang="ts">
|
|
58
|
+
export default {
|
|
59
|
+
name: 'u-text',
|
|
60
|
+
options: {
|
|
61
|
+
addGlobalClass: true,
|
|
62
|
+
virtualHost: true,
|
|
63
|
+
styleIsolation: 'shared'
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<script setup lang="ts">
|
|
69
|
+
import { computed } from 'vue';
|
|
70
|
+
import { TextProps } from './types';
|
|
71
|
+
import { $u } from '../../';
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Text 文本
|
|
75
|
+
* @description 此组件集成了文本类在项目中的常用功能,包括状态,拨打电话,格式化日期,*替换,超链接...等功能。 您大可不必在使用特殊文本时自己定义,text组件几乎涵盖您能使用的大部分场景。
|
|
76
|
+
* @tutorial https://uviewpro.cn/zh/components/text.html
|
|
77
|
+
* @property {String} type 主题颜色
|
|
78
|
+
* @property {Boolean} show 是否显示(默认 true )
|
|
79
|
+
* @property {String | Number} text 显示的值
|
|
80
|
+
* @property {String} prefixIcon 前置图标
|
|
81
|
+
* @property {String} suffixIcon 后置图标
|
|
82
|
+
* @property {String} mode 文本处理的匹配模式 text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接
|
|
83
|
+
* @property {String} href mode=link下,配置的链接
|
|
84
|
+
* @property {String | Function} format 格式化规则
|
|
85
|
+
* @property {Boolean} call mode=phone时,点击文本是否拨打电话(默认 false )
|
|
86
|
+
* @property {String} openType 小程序的打开方式
|
|
87
|
+
* @property {Boolean} bold 是否粗体,默认normal(默认 false )
|
|
88
|
+
* @property {Boolean} block 是否块状(默认 false )
|
|
89
|
+
* @property {String | Number} lines 文本显示的行数,如果设置,超出此行数,将会显示省略号
|
|
90
|
+
* @property {String} color 文本颜色(默认 '#303133' )
|
|
91
|
+
* @property {String | Number} size 字体大小(默认 15 )
|
|
92
|
+
* @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '15px'} )
|
|
93
|
+
* @property {String} decoration 文字装饰,下划线,中划线等,可选值 none|underline|line-through(默认 'none' )
|
|
94
|
+
* @property {Object | String | Number} margin 外边距,对象、字符串,数值形式均可(默认 0 )
|
|
95
|
+
* @property {String | Number} lineHeight 文本行高
|
|
96
|
+
* @property {String} align 文本对齐方式,可选值left|center|right(默认 'left' )
|
|
97
|
+
* @property {String} wordWrap 文字换行,可选值break-word|normal|anywhere(默认 'normal' )
|
|
98
|
+
* @event {Function} click 点击触发事件
|
|
99
|
+
* @example <u-text text="我用十年青春,赴你最后之约"></u-text>
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
const props = defineProps(TextProps);
|
|
103
|
+
const emit = defineEmits(['click', 'getuserinfo', 'contact', 'getphonenumber', 'error', 'launchapp', 'opensetting']);
|
|
104
|
+
|
|
105
|
+
// 是否小程序环境
|
|
106
|
+
const isMp = computed(() => {
|
|
107
|
+
let mp = false;
|
|
108
|
+
// #ifdef MP
|
|
109
|
+
mp = true;
|
|
110
|
+
// #endif
|
|
111
|
+
return mp;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const isNvue = computed(() => {
|
|
115
|
+
let nvue = false;
|
|
116
|
+
// #ifdef APP-NVUE
|
|
117
|
+
nvue = true;
|
|
118
|
+
// #endif
|
|
119
|
+
return nvue;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// 处理显示的值(参考原value.js逻辑,简化实现)
|
|
123
|
+
const displayValue = computed(() => {
|
|
124
|
+
const { format, text, href, mode } = props;
|
|
125
|
+
let val = text;
|
|
126
|
+
if (typeof format === 'function') {
|
|
127
|
+
val = format(val);
|
|
128
|
+
} else if (typeof format === 'string' && format) {
|
|
129
|
+
// 可扩展字符串格式化
|
|
130
|
+
}
|
|
131
|
+
switch (mode) {
|
|
132
|
+
case 'price':
|
|
133
|
+
if (!/^\d+(\.\d+)?$/.test(String(val))) return val;
|
|
134
|
+
// 如果format非正则,非函数,则使用默认的金额格式化方法进行操作
|
|
135
|
+
val = $u.formatPrice(val, 2);
|
|
136
|
+
break;
|
|
137
|
+
case 'phone':
|
|
138
|
+
// 判断是否合法的手机号
|
|
139
|
+
if (format === 'encrypt') {
|
|
140
|
+
// 如果format为encrypt,则将手机号进行星号加密处理
|
|
141
|
+
val = String(val).replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case 'name':
|
|
145
|
+
// 判断是否合法的字符串
|
|
146
|
+
if (!$u.test.string(val)) return val;
|
|
147
|
+
if (format === 'encrypt') {
|
|
148
|
+
// 如果format为encrypt,则将姓名进行星号加密处理
|
|
149
|
+
return $u.formatName(val);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case 'date':
|
|
153
|
+
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
|
|
154
|
+
if ($u.test.string(format) && !$u.test.empty(format)) {
|
|
155
|
+
// 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
|
|
156
|
+
return $u.timeFormat(val, format);
|
|
157
|
+
}
|
|
158
|
+
// 如果没有设置format,则设置为默认的时间格式化形式
|
|
159
|
+
return $u.timeFormat(val, 'yyyy-mm-dd');
|
|
160
|
+
case 'link':
|
|
161
|
+
if (!$u.test.url(href)) return val;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
return val;
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 获取文本样式
|
|
169
|
+
*/
|
|
170
|
+
const textStyle = computed(() => {
|
|
171
|
+
const style: Record<string, any> = {
|
|
172
|
+
margin: typeof props.margin === 'number' ? `${props.margin}px` : props.margin,
|
|
173
|
+
justifyContent: props.align === 'left' ? 'flex-start' : props.align === 'center' ? 'center' : 'flex-end'
|
|
174
|
+
};
|
|
175
|
+
return $u.toStyle(style);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 获取文本值样式
|
|
180
|
+
*/
|
|
181
|
+
const textValueStyle = computed(() => {
|
|
182
|
+
const style: Record<string, any> = {
|
|
183
|
+
textDecoration: props.decoration,
|
|
184
|
+
fontWeight: props.bold ? 'bold' : 'normal',
|
|
185
|
+
wordWrap: props.wordWrap,
|
|
186
|
+
fontSize: $u.addUnit(props.size),
|
|
187
|
+
lineHeight: props.lineHeight ? (typeof props.lineHeight === 'number' ? `${props.lineHeight}px` : props.lineHeight) : undefined
|
|
188
|
+
};
|
|
189
|
+
if (props.lines) {
|
|
190
|
+
style['display'] = '-webkit-box';
|
|
191
|
+
style['-webkit-box-orient'] = 'vertical';
|
|
192
|
+
}
|
|
193
|
+
if (!props.type) style.color = props.color;
|
|
194
|
+
if (isNvue.value && props.lines) style.lines = props.lines;
|
|
195
|
+
if (props.lineHeight) style.lineHeight = $u.addUnit(props.lineHeight);
|
|
196
|
+
|
|
197
|
+
// 合并 textStyle,优先对象,其次字符串
|
|
198
|
+
if ($u.test.object(props.textStyle)) {
|
|
199
|
+
// 只合并对象类型,防止类型错误
|
|
200
|
+
return $u.toStyle($u.deepMerge(style, props.textStyle as Record<string, any>));
|
|
201
|
+
}
|
|
202
|
+
if ($u.test.string(props.textStyle)) {
|
|
203
|
+
return `${$u.toStyle(style)}${props.textStyle}`;
|
|
204
|
+
}
|
|
205
|
+
return $u.toStyle(style);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 点击事件
|
|
210
|
+
*/
|
|
211
|
+
function onClick() {
|
|
212
|
+
// 如果为手机号模式,拨打电话
|
|
213
|
+
if (props.call && props.mode === 'phone') {
|
|
214
|
+
uni.makePhoneCall({
|
|
215
|
+
phoneNumber: String(props.text)
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
emit('click');
|
|
219
|
+
}
|
|
220
|
+
function onGetUserInfo(event) {
|
|
221
|
+
emit('getuserinfo', event.detail);
|
|
222
|
+
}
|
|
223
|
+
function onContact(event) {
|
|
224
|
+
emit('contact', event.detail);
|
|
225
|
+
}
|
|
226
|
+
function onGetPhoneNumber(event) {
|
|
227
|
+
emit('getphonenumber', event.detail);
|
|
228
|
+
}
|
|
229
|
+
function onError(event) {
|
|
230
|
+
emit('error', event.detail);
|
|
231
|
+
}
|
|
232
|
+
function onLaunchApp(event) {
|
|
233
|
+
emit('launchapp', event.detail);
|
|
234
|
+
}
|
|
235
|
+
function onOpenSetting(event) {
|
|
236
|
+
emit('opensetting', event.detail);
|
|
237
|
+
}
|
|
238
|
+
</script>
|
|
239
|
+
<style lang="scss" scoped>
|
|
240
|
+
@import '../../libs/css/style.components.scss';
|
|
241
|
+
|
|
242
|
+
.u-text {
|
|
243
|
+
@include vue-flex;
|
|
244
|
+
align-items: center;
|
|
245
|
+
flex-wrap: nowrap;
|
|
246
|
+
flex: 1;
|
|
247
|
+
word-break: break-all;
|
|
248
|
+
|
|
249
|
+
&--bold {
|
|
250
|
+
font-weight: bold;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
&--inline {
|
|
254
|
+
display: inline-flex;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
&--inline &__value {
|
|
258
|
+
display: inline-flex;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
&--inline &__icon {
|
|
262
|
+
display: inline-flex;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&--block {
|
|
266
|
+
display: flex;
|
|
267
|
+
/* #ifndef APP-NVUE */
|
|
268
|
+
width: 100%;
|
|
269
|
+
/* #endif */
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
&--block &__value {
|
|
273
|
+
display: flex;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
&__price {
|
|
277
|
+
font-size: 14px;
|
|
278
|
+
color: $u-content-color;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
&__value {
|
|
282
|
+
font-size: 14px;
|
|
283
|
+
@include vue-flex;
|
|
284
|
+
color: $u-content-color;
|
|
285
|
+
flex-wrap: wrap;
|
|
286
|
+
text-overflow: ellipsis;
|
|
287
|
+
align-items: center;
|
|
288
|
+
|
|
289
|
+
&--primary {
|
|
290
|
+
color: $u-type-primary;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
&--warning {
|
|
294
|
+
color: $u-type-warning;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
&--success {
|
|
298
|
+
color: $u-type-success;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
&--info {
|
|
302
|
+
color: $u-type-info;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
&--error {
|
|
306
|
+
color: $u-type-error;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
&--main {
|
|
310
|
+
color: $u-main-color;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
&--content {
|
|
314
|
+
color: $u-content-color;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
&--tips {
|
|
318
|
+
color: $u-tips-color;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
&--light {
|
|
322
|
+
color: $u-light-color;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
</style>
|
package/index.scss
CHANGED
package/index.ts
CHANGED
|
@@ -1,61 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import queryParams from './libs/function/queryParams';
|
|
3
|
-
// 路由封装
|
|
4
|
-
import route from './libs/function/route';
|
|
5
|
-
// 时间格式化
|
|
6
|
-
import timeFormat from './libs/function/timeFormat';
|
|
7
|
-
// 时间戳格式化,返回多久之前
|
|
8
|
-
import timeFrom from './libs/function/timeFrom';
|
|
9
|
-
// 颜色渐变相关,colorGradient-颜色渐变,hexToRgb-十六进制颜色转rgb颜色,rgbToHex-rgb转十六进制
|
|
10
|
-
import colorGradients from './libs/function/colorGradient';
|
|
11
|
-
// 生成全局唯一guid字符串
|
|
12
|
-
import guid from './libs/function/guid';
|
|
13
|
-
// 主题相关颜色,info|success|warning|primary|default|error,此颜色已在uview.scss中定义,但是为js中也能使用,故也定义一份
|
|
14
|
-
import color from './libs/function/color';
|
|
1
|
+
import { $u, type RequestOptions } from './libs';
|
|
15
2
|
import type { UViewProOptions } from './types/global';
|
|
16
|
-
// 根据type获取图标名称
|
|
17
|
-
import type2icon from './libs/function/type2icon';
|
|
18
|
-
// 打乱数组的顺序
|
|
19
|
-
import randomArray from './libs/function/randomArray';
|
|
20
|
-
// 对象和数组的深度克隆
|
|
21
|
-
import deepClone from './libs/function/deepClone';
|
|
22
|
-
// 对象深度拷贝
|
|
23
|
-
import deepMerge from './libs/function/deepMerge';
|
|
24
|
-
// 添加单位
|
|
25
|
-
import addUnit from './libs/function/addUnit';
|
|
26
|
-
// 规则检验
|
|
27
|
-
import test from './libs/function/test';
|
|
28
|
-
// 随机数
|
|
29
|
-
import random from './libs/function/random';
|
|
30
|
-
// 去除空格
|
|
31
|
-
import trim from './libs/function/trim';
|
|
32
|
-
// toast提示,对uni.showToast的封装
|
|
33
|
-
import toast from './libs/function/toast';
|
|
34
|
-
// 获取父组件参数
|
|
35
|
-
import getParent from './libs/function/getParent';
|
|
36
|
-
// 获取整个父组件
|
|
37
|
-
import $parent from './libs/function/$parent';
|
|
38
|
-
// 获取sys()和os()工具方法
|
|
39
|
-
// 获取设备信息,挂载到$u的sys()(system的缩写)属性中,
|
|
40
|
-
// 同时把安卓和ios平台的名称"ios"和"android"挂到$u.os()中,方便取用
|
|
41
|
-
import { sys, os } from './libs/function/sys';
|
|
42
|
-
// 防抖方法
|
|
43
|
-
import debounce from './libs/function/debounce';
|
|
44
|
-
// 节流方法
|
|
45
|
-
import throttle from './libs/function/throttle';
|
|
46
|
-
// 获取元素的位置信息
|
|
47
|
-
import getRect from './libs/function/getRect';
|
|
48
|
-
// 获取父组件
|
|
49
|
-
import { parentData, parent } from './libs/function/parent';
|
|
50
|
-
|
|
51
|
-
// 配置信息
|
|
52
|
-
import config from './libs/config/config';
|
|
53
|
-
// 各个需要fixed的地方的z-index配置文件
|
|
54
|
-
import zIndex from './libs/config/zIndex';
|
|
55
|
-
import { dispatch, broadcast } from './libs/util/emitter';
|
|
56
|
-
import { mitt } from './libs/util/mitt';
|
|
57
|
-
// http相关
|
|
58
|
-
import httpPlugin, { Request, http, type RequestOptions, type RequestConfig, type RequestInterceptor, type RequestMeta } from './libs/request/index';
|
|
59
3
|
|
|
60
4
|
declare const uni: {
|
|
61
5
|
[key: string]: any;
|
|
@@ -66,92 +10,11 @@ declare const uni: {
|
|
|
66
10
|
request: (options: RequestOptions) => any;
|
|
67
11
|
};
|
|
68
12
|
|
|
69
|
-
/**
|
|
70
|
-
* $u 工具库类型声明
|
|
71
|
-
*/
|
|
72
|
-
export interface UViewUtils {
|
|
73
|
-
queryParams: typeof queryParams;
|
|
74
|
-
route: typeof route;
|
|
75
|
-
timeFormat: typeof timeFormat;
|
|
76
|
-
date: typeof timeFormat;
|
|
77
|
-
timeFrom: typeof timeFrom;
|
|
78
|
-
colorGradient: typeof colorGradients.colorGradient;
|
|
79
|
-
colorToRgba: typeof colorGradients.colorToRgba;
|
|
80
|
-
guid: typeof guid;
|
|
81
|
-
color: typeof color;
|
|
82
|
-
sys: typeof sys;
|
|
83
|
-
os: typeof os;
|
|
84
|
-
type2icon: typeof type2icon;
|
|
85
|
-
randomArray: typeof randomArray;
|
|
86
|
-
dispatch: typeof dispatch;
|
|
87
|
-
broadcast: typeof broadcast;
|
|
88
|
-
hexToRgb: typeof colorGradients.hexToRgb;
|
|
89
|
-
rgbToHex: typeof colorGradients.rgbToHex;
|
|
90
|
-
test: typeof test;
|
|
91
|
-
random: typeof random;
|
|
92
|
-
deepClone: typeof deepClone;
|
|
93
|
-
deepMerge: typeof deepMerge;
|
|
94
|
-
getParent: typeof getParent;
|
|
95
|
-
$parent: typeof $parent;
|
|
96
|
-
parent: typeof parent;
|
|
97
|
-
parentData: typeof parentData;
|
|
98
|
-
addUnit: typeof addUnit;
|
|
99
|
-
trim: typeof trim;
|
|
100
|
-
type: string[];
|
|
101
|
-
http: typeof http;
|
|
102
|
-
toast: typeof toast;
|
|
103
|
-
config: typeof config;
|
|
104
|
-
zIndex: typeof zIndex;
|
|
105
|
-
debounce: typeof debounce;
|
|
106
|
-
throttle: typeof throttle;
|
|
107
|
-
mitt: ReturnType<typeof mitt>;
|
|
108
|
-
getRect: typeof getRect;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export const $u: UViewUtils = {
|
|
112
|
-
queryParams: queryParams,
|
|
113
|
-
route: route,
|
|
114
|
-
timeFormat: timeFormat,
|
|
115
|
-
date: timeFormat, // 另名date
|
|
116
|
-
timeFrom,
|
|
117
|
-
colorGradient: colorGradients.colorGradient,
|
|
118
|
-
colorToRgba: colorGradients.colorToRgba,
|
|
119
|
-
guid,
|
|
120
|
-
color,
|
|
121
|
-
sys,
|
|
122
|
-
os,
|
|
123
|
-
type2icon,
|
|
124
|
-
randomArray,
|
|
125
|
-
dispatch,
|
|
126
|
-
broadcast,
|
|
127
|
-
hexToRgb: colorGradients.hexToRgb,
|
|
128
|
-
rgbToHex: colorGradients.rgbToHex,
|
|
129
|
-
test,
|
|
130
|
-
random,
|
|
131
|
-
deepClone,
|
|
132
|
-
deepMerge,
|
|
133
|
-
getParent,
|
|
134
|
-
$parent,
|
|
135
|
-
parent,
|
|
136
|
-
parentData,
|
|
137
|
-
addUnit,
|
|
138
|
-
trim,
|
|
139
|
-
type: ['primary', 'success', 'error', 'warning', 'info'],
|
|
140
|
-
http,
|
|
141
|
-
toast,
|
|
142
|
-
config, // uView配置信息相关,比如版本号
|
|
143
|
-
zIndex,
|
|
144
|
-
debounce,
|
|
145
|
-
throttle,
|
|
146
|
-
mitt: mitt(),
|
|
147
|
-
getRect
|
|
148
|
-
};
|
|
149
|
-
|
|
150
13
|
// $u挂载到uni对象上
|
|
151
14
|
const install = (app: any, options?: UViewProOptions): void => {
|
|
152
15
|
uni.$u = $u;
|
|
153
16
|
if (options && options.theme) {
|
|
154
|
-
$u.color = deepMerge($u.color, options.theme);
|
|
17
|
+
$u.color = $u.deepMerge($u.color, options.theme);
|
|
155
18
|
}
|
|
156
19
|
// 可扩展更多配置项
|
|
157
20
|
app.config.globalProperties.$u = $u;
|
|
@@ -161,42 +24,6 @@ export default {
|
|
|
161
24
|
install
|
|
162
25
|
};
|
|
163
26
|
|
|
164
|
-
|
|
165
|
-
export {
|
|
166
|
-
queryParams,
|
|
167
|
-
route,
|
|
168
|
-
timeFormat,
|
|
169
|
-
timeFrom,
|
|
170
|
-
guid,
|
|
171
|
-
color,
|
|
172
|
-
sys,
|
|
173
|
-
os,
|
|
174
|
-
type2icon,
|
|
175
|
-
randomArray,
|
|
176
|
-
deepClone,
|
|
177
|
-
deepMerge,
|
|
178
|
-
addUnit,
|
|
179
|
-
test,
|
|
180
|
-
random,
|
|
181
|
-
trim,
|
|
182
|
-
toast,
|
|
183
|
-
debounce,
|
|
184
|
-
throttle,
|
|
185
|
-
getRect,
|
|
186
|
-
getParent,
|
|
187
|
-
$parent,
|
|
188
|
-
parent,
|
|
189
|
-
parentData,
|
|
190
|
-
dispatch,
|
|
191
|
-
broadcast,
|
|
192
|
-
config,
|
|
193
|
-
zIndex
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
// 颜色相关方法单独导出
|
|
197
|
-
export const { colorGradient, colorToRgba, hexToRgb, rgbToHex } = colorGradients;
|
|
198
|
-
|
|
199
|
-
// http相关导出
|
|
200
|
-
export { Request, httpPlugin, http, type RequestOptions, type RequestConfig, type RequestInterceptor, type RequestMeta };
|
|
27
|
+
export * from './libs';
|
|
201
28
|
|
|
202
29
|
export type { UViewProOptions };
|
|
@@ -5,3 +5,12 @@
|
|
|
5
5
|
flex-direction: $direction;
|
|
6
6
|
/* #endif */
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
// 通过scss的mixin功能,把原来需要写4行的css,变成一行
|
|
10
|
+
// 目的是保持代码干净整洁,不至于在nvue下,到处都要写display:flex的条件编译
|
|
11
|
+
@mixin flex($direction: row) {
|
|
12
|
+
/* #ifndef APP-NVUE */
|
|
13
|
+
display: flex;
|
|
14
|
+
/* #endif */
|
|
15
|
+
flex-direction: $direction;
|
|
16
|
+
}
|
package/libs/css/style.nvue.scss
CHANGED
package/libs/css/style.vue.scss
CHANGED
|
@@ -38,37 +38,39 @@ page {
|
|
|
38
38
|
/* end--各种hover点击反馈相关的类名--end */
|
|
39
39
|
|
|
40
40
|
/* start--文本行数限制--start */
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
// 超出行数,自动显示行尾省略号,最多5行
|
|
42
|
+
// 来自uView的温馨提示:当您在控制台看到此报错,说明需要在App.vue的style标签加上【lang="scss"】
|
|
43
|
+
@for $i from 1 through 5 {
|
|
44
|
+
.u-line-#{$i} {
|
|
45
|
+
/* #ifdef APP-NVUE */
|
|
46
|
+
// nvue下,可以直接使用lines属性,这是weex特有样式
|
|
47
|
+
lines: $i;
|
|
48
|
+
text-overflow: ellipsis;
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
flex: 1;
|
|
51
|
+
/* #endif */
|
|
52
|
+
|
|
53
|
+
/* #ifndef APP-NVUE */
|
|
54
|
+
// vue下,单行和多行显示省略号需要单独处理
|
|
55
|
+
@if $i == '1' {
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
text-overflow: ellipsis;
|
|
59
|
+
} @else {
|
|
60
|
+
display: -webkit-box;
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
text-overflow: ellipsis;
|
|
63
|
+
word-break: break-all;
|
|
64
|
+
-webkit-line-clamp: $i;
|
|
65
|
+
-webkit-box-orient: vertical;
|
|
66
|
+
}
|
|
67
|
+
/* #endif */
|
|
68
|
+
}
|
|
61
69
|
}
|
|
62
70
|
|
|
63
|
-
.u-line-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
.u-line-5 {
|
|
67
|
-
overflow: hidden;
|
|
68
|
-
word-break: break-all;
|
|
69
|
-
text-overflow: ellipsis;
|
|
70
|
-
display: -webkit-box; // 弹性伸缩盒
|
|
71
|
-
-webkit-box-orient: vertical; // 设置伸缩盒子元素排列方式
|
|
71
|
+
.u-line-force {
|
|
72
|
+
display: -webkit-box !important;
|
|
73
|
+
-webkit-box-orient: vertical !important;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
/* end--文本行数限制--end */
|
|
@@ -163,15 +165,24 @@ uni-toast .uni-toast {
|
|
|
163
165
|
/* end--提升H5端uni.toast()的层级,避免被uView的modal等遮盖--end */
|
|
164
166
|
|
|
165
167
|
/* start--去除button的所有默认样式--start */
|
|
168
|
+
// 去除button的所有默认样式,让其表现跟普通的view、text元素一样
|
|
166
169
|
.u-reset-button {
|
|
167
170
|
padding: 0;
|
|
171
|
+
margin: 0;
|
|
172
|
+
background-color: transparent;
|
|
173
|
+
/* #ifndef APP-PLUS */
|
|
168
174
|
font-size: inherit;
|
|
169
175
|
line-height: inherit;
|
|
170
|
-
background-color: transparent;
|
|
171
176
|
color: inherit;
|
|
177
|
+
/* #endif */
|
|
178
|
+
/* #ifdef APP-NVUE */
|
|
179
|
+
border-width: 0;
|
|
180
|
+
/* #endif */
|
|
172
181
|
}
|
|
173
182
|
|
|
183
|
+
/* #ifndef APP-NVUE */
|
|
174
184
|
.u-reset-button::after {
|
|
175
185
|
border: none;
|
|
176
186
|
}
|
|
187
|
+
/* #endif */
|
|
177
188
|
/* end--去除button的所有默认样式--end */
|