hy-app 0.6.2 → 0.6.3

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.
@@ -2,7 +2,7 @@
2
2
  <view :class="['hy-datetime-picker', customClass]" :style="customStyle">
3
3
  <view v-if="hasInput" class="hy-datetime-picker__has-input" @click="onShowByClickInput">
4
4
  <slot name="trigger" :value="inputValue">
5
- <HyInput
5
+ <hy-input
6
6
  v-model="inputValue"
7
7
  :disabled="input?.disabled"
8
8
  :disabledColor="input?.disabledColor"
@@ -17,11 +17,11 @@
17
17
  :placeholderStyle="input?.placeholderStyle"
18
18
  :placeholderClass="input?.placeholderClass"
19
19
  :customStyle="Object.assign({ 'pointer-events': 'none' }, input?.customStyle)"
20
- ></HyInput>
20
+ ></hy-input>
21
21
  <view class="input-cover"></view>
22
22
  </slot>
23
23
  </view>
24
- <HyPicker
24
+ <hy-picker
25
25
  :show="show || (hasInput && showByClickInput)"
26
26
  :popupMode="popupMode"
27
27
  :closeOnClickOverlay="closeOnClickOverlay"
@@ -49,7 +49,7 @@
49
49
  <template #toolbar-bottom>
50
50
  <slot name="toolbar-bottom"></slot>
51
51
  </template>
52
- </HyPicker>
52
+ </hy-picker>
53
53
  </view>
54
54
  </template>
55
55
 
@@ -99,7 +99,7 @@ const validModes = new Set([
99
99
  ])
100
100
 
101
101
  /**
102
- * @description 更新各列的值
102
+ * 更新各列的值
103
103
  * */
104
104
  const updateColumns = () => {
105
105
  const formatterFn = props.formatter || innerFormatter
@@ -110,7 +110,7 @@ const updateColumns = () => {
110
110
  }
111
111
 
112
112
  /**
113
- * @description 更新各列的值,进行补0、格式化等操作
113
+ * 更新各列的值,进行补0、格式化等操作
114
114
  * */
115
115
  const updateColumnValue = (value: string | number) => {
116
116
  innerValue.value = value
@@ -215,7 +215,7 @@ const times = (n: number, iteratee: Function) => {
215
215
  }
216
216
 
217
217
  /**
218
- * @description 关闭选择器
218
+ * 关闭选择器
219
219
  * */
220
220
  const close = () => {
221
221
  if (props.closeOnClickOverlay) {
@@ -227,7 +227,7 @@ const close = () => {
227
227
  }
228
228
 
229
229
  /**
230
- * @description 点击工具栏的取消按钮
230
+ * 点击工具栏的取消按钮
231
231
  * */
232
232
  const cancel = () => {
233
233
  if (props.hasInput) {
@@ -237,9 +237,25 @@ const cancel = () => {
237
237
  }
238
238
 
239
239
  /**
240
- * @description 点击工具栏的确定按钮
240
+ * 点击工具栏的确定按钮
241
241
  * */
242
242
  const confirm = () => {
243
+ //如果用户还没有触发过change
244
+ if (!innerValue.value) {
245
+ let arr = [0]
246
+ //如果有默认值&&默认值的数组长度是正确的,就用默认值
247
+ if (
248
+ Array.isArray(props.defaultIndex) &&
249
+ props.defaultIndex.length === columns.value.length
250
+ ) {
251
+ arr = [...props.defaultIndex]
252
+ } else {
253
+ //否则默认都选中第一个
254
+ arr = Array(columns.value.length).fill(0)
255
+ }
256
+ console.log(arr)
257
+ getInputValue(arr)
258
+ }
243
259
  emit('update:modelValue', innerValue.value)
244
260
  if (props.hasInput) {
245
261
  getInputValue(innerValue.value)
@@ -252,7 +268,7 @@ const confirm = () => {
252
268
  }
253
269
 
254
270
  /**
255
- * @description 用正则截取输出值,当出现多组数字时,抛出错误
271
+ * 用正则截取输出值,当出现多组数字时,抛出错误
256
272
  * */
257
273
  const intercept = (e: any, type?: string) => {
258
274
  let judge = e.match(/\d+/g)
@@ -272,7 +288,7 @@ const intercept = (e: any, type?: string) => {
272
288
  }
273
289
 
274
290
  /**
275
- * @description 列发生变化时触发
291
+ * 列发生变化时触发
276
292
  * */
277
293
  const change = (e: any) => {
278
294
  const { indexs, values } = e
@@ -315,7 +331,7 @@ const change = (e: any) => {
315
331
  }
316
332
 
317
333
  /**
318
- * @description 更新索引
334
+ * 更新索引
319
335
  * */
320
336
  const updateIndexes = (value: number | string) => {
321
337
  let values: string[] = []
@@ -375,7 +391,7 @@ const updateIndexes = (value: number | string) => {
375
391
  }
376
392
 
377
393
  /**
378
- * @description 获取每列数据
394
+ * 获取每列数据
379
395
  * */
380
396
  const getOriginColumns = () => {
381
397
  // 生成各列的值
@@ -397,7 +413,7 @@ const getOriginColumns = () => {
397
413
  }
398
414
 
399
415
  /**
400
- * @description 得出合法的时间
416
+ * 得出合法的时间
401
417
  * */
402
418
  const correctValue = (value: number | string | Date): string | number => {
403
419
  const isDateMode = props.mode !== DateModeEnum.TIME
@@ -417,7 +433,7 @@ const correctValue = (value: number | string | Date): string | number => {
417
433
  }
418
434
  }
419
435
  /**
420
- * @description 获取每列的最大和最小值
436
+ * 获取每列的最大和最小值
421
437
  * */
422
438
  const getRanges = () => {
423
439
  if (props.mode === DateModeEnum.TIME) {
@@ -470,7 +486,7 @@ const getRanges = () => {
470
486
  return arr
471
487
  }
472
488
  /**
473
- * @description 根据minDate、maxDate、minHour、maxHour等边界值,判断各列的开始和结束边界值
489
+ * 根据minDate、maxDate、minHour、maxHour等边界值,判断各列的开始和结束边界值
474
490
  * */
475
491
  const getBoundary = (type: string, innerVal: string | number) => {
476
492
  const value = new Date(innerVal)
@@ -7,7 +7,7 @@
7
7
  :mode="imgMode"
8
8
  :style="[imgStyle, customStyle]"
9
9
  ></image>
10
- <text v-else :class="uClasses" :style="[iconStyle, customStyle]"></text>
10
+ <text v-else :class="iconClass" :style="[iconStyle, customStyle]"></text>
11
11
  <!-- 这里进行空字符串判断,如果仅仅是v-if="label",可能会出现传递0的时候,结果也无法显示 -->
12
12
  <text
13
13
  v-if="label"
@@ -41,7 +41,6 @@ import type { CSSProperties } from 'vue'
41
41
  import { addUnit } from '../../libs'
42
42
  import type { IIconEmits } from './typing'
43
43
  import iconProps from './props'
44
- import { onPageScroll } from '@dcloudio/uni-app'
45
44
 
46
45
  /**
47
46
  * 基于字体的图标集,包含了大多数常见场景的图标,使用简单,开箱即用,无需自己再写每个图标的样式,直接简单配置即可。支持自定义图标。
@@ -52,10 +51,10 @@ defineOptions({})
52
51
  const props = defineProps(iconProps)
53
52
  const emit = defineEmits<IIconEmits>()
54
53
 
55
- const uClasses = computed(() => {
54
+ const iconClass = computed(() => {
56
55
  let classes: string | string[] = [
57
56
  'hy-icon__icon',
58
- 'iconfont',
57
+ props.customPrefix,
59
58
  `${props.customPrefix}-${props.name}`
60
59
  ]
61
60
  if (props.isRotate) classes.push('hy-rotate')
@@ -84,7 +83,7 @@ const iconStyle = computed<CSSProperties>(() => {
84
83
  })
85
84
 
86
85
  /**
87
- * @description 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式
86
+ * 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式
88
87
  * */
89
88
  const isImg = computed(() => {
90
89
  return props.name?.indexOf('/') !== -1
@@ -99,7 +98,7 @@ const imgStyle = computed((): CSSProperties => {
99
98
  })
100
99
 
101
100
  /**
102
- * @description 点击
101
+ * 点击icon图标执行
103
102
  * */
104
103
  const clickHandler = (e: Event) => {
105
104
  emit('click', props.index, e)
@@ -18,7 +18,9 @@
18
18
  <text
19
19
  :class="[
20
20
  'hy-toast__content--test',
21
- !tmpConfig.icon ? `hy-toast__content--text__${tmpConfig.type}` : ''
21
+ !tmpConfig.icon && !tmpConfig.loading
22
+ ? `hy-toast__content--text__${tmpConfig.type}`
23
+ : ''
22
24
  ]"
23
25
  >
24
26
  {{ tmpConfig.message }}
@@ -42,7 +44,7 @@ export default {
42
44
  import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
43
45
  import type { CSSProperties } from 'vue'
44
46
  import type ToastOptions from './typing'
45
- import { ColorConfig, iconName, getWindowInfo, hexToRgb } from '../../libs'
47
+ import { ColorConfig, iconName, getWindowInfo, hexToRgb, deepMerge } from '../../libs'
46
48
  // 组件
47
49
  import HyOverlay from '../hy-overlay/hy-overlay.vue'
48
50
  import HyIcon from '../hy-icon/hy-icon.vue'
@@ -99,7 +101,7 @@ const iconNameCom = computed(() => {
99
101
  })
100
102
 
101
103
  /**
102
- * @description 内容盒子的样式
104
+ * 内容盒子的样式
103
105
  * */
104
106
  const contentStyle = computed(() => {
105
107
  const windowHeight = getWindowInfo().windowHeight,
@@ -145,13 +147,12 @@ onUnmounted(() => {
145
147
  })
146
148
 
147
149
  /**
148
- * @description 显示toast组件,由父组件通过xxx.show(options)形式调用
150
+ * 显示toast组件,由父组件通过xxx.show(options)形式调用
149
151
  * */
150
152
  const show = (options: ToastOptions) => {
151
- // 不将结果合并到this.config变量,避免多次调用u-toast,前后的配置造成混乱
152
- tmpConfig.value = Object.assign(config, options)
153
153
  // 清除定时器
154
154
  clearTimer()
155
+ tmpConfig.value = { ...config, ...options }
155
156
  isShow.value = true
156
157
  // -1时不自动关闭
157
158
  if (tmpConfig.value.duration !== -1 && !tmpConfig.value.loading) {
@@ -164,19 +165,22 @@ const show = (options: ToastOptions) => {
164
165
  }
165
166
  }
166
167
 
167
- // 隐藏toast组件,由父组件通过this.$refs.xxx.hide()形式调用
168
+ /**
169
+ * 隐藏toast组件,由父组件通过ref形式调用
170
+ * */
168
171
  const hide = () => {
169
- config.loading = false
170
172
  clearTimer()
171
173
  }
172
174
  /**
173
- * @description 清除定时任务
175
+ * 清除定时任务
174
176
  * */
175
177
  const clearTimer = () => {
176
178
  isShow.value = false
177
179
  // 清除定时器
178
180
  clearTimeout(timer)
179
181
  timer = null
182
+ // 防止后面请求还是loading状态
183
+ // config.loading = false
180
184
  }
181
185
 
182
186
  defineExpose({
@@ -1,45 +1,45 @@
1
- /**
2
- * 消息提示hooks
3
- * */
4
-
5
- import type ToastOptions from "../../components/hy-toast/typing";
6
- import { error } from "../../libs";
7
-
8
- // 用于缓存全局唯一实例
9
- let toastInstance: any = null;
10
-
11
- /**
12
- * useToast 适用于任意页面直接调用 toast
13
- * 兼容 H5 + 微信小程序 + App
14
- */
15
- export const useToast = () => {
16
- const show = (msg: string, opt?: ToastOptions) =>
17
- openToast({ message: msg, icon: false, type: "", ...opt });
18
- const info = (msg: string, opt?: ToastOptions) =>
19
- openToast({ message: msg, type: "info", icon: true, ...opt });
20
- const success = (msg: string, opt?: ToastOptions) =>
21
- openToast({ message: msg, type: "success", icon: true, ...opt });
22
- const error = (msg: string, opt?: ToastOptions) =>
23
- openToast({ message: msg, type: "error", icon: true, ...opt });
24
- const warning = (msg: string, opt?: ToastOptions) =>
25
- openToast({ message: msg, type: "warning", icon: true, ...opt });
26
- const primary = (msg: string, opt?: ToastOptions) =>
27
- openToast({ message: msg, type: "primary", icon: true, ...opt });
28
- const loading = (msg: string = "加载中...", opt?: ToastOptions) =>
29
- openToast({ message: msg, loading: true, ...opt });
30
- const close = (all?: boolean) => closeToast();
31
-
32
- return { show, info, success, error, warning, primary, loading, close };
33
- };
34
-
35
- /**
36
- * ✅ 实现
37
- * 页面创建总事件,调用方法实现
38
- */
39
- const openToast = (opt: ToastOptions) => {
40
- uni.$emit("__hy_toast_open__", opt);
41
- };
42
-
43
- const closeToast = () => {
44
- uni.$emit("__hy_toast_close__");
45
- };
1
+ /**
2
+ * 消息提示hooks
3
+ * */
4
+
5
+ import type ToastOptions from '../../components/hy-toast/typing'
6
+ import { error } from '../../libs'
7
+
8
+ // 用于缓存全局唯一实例
9
+ let toastInstance: any = null
10
+
11
+ /**
12
+ * useToast 适用于任意页面直接调用 toast
13
+ * 兼容 H5 + 微信小程序 + App
14
+ */
15
+ export const useToast = () => {
16
+ const show = (msg: string, opt?: ToastOptions) =>
17
+ openToast({ message: msg, icon: false, type: '', ...opt })
18
+ const info = (msg: string, opt?: ToastOptions) =>
19
+ openToast({ message: msg, type: 'info', icon: true, ...opt })
20
+ const success = (msg: string, opt?: ToastOptions) =>
21
+ openToast({ message: msg, type: 'success', icon: true, ...opt })
22
+ const error = (msg: string, opt?: ToastOptions) =>
23
+ openToast({ message: msg, type: 'error', icon: true, ...opt })
24
+ const warning = (msg: string, opt?: ToastOptions) =>
25
+ openToast({ message: msg, type: 'warning', icon: true, ...opt })
26
+ const primary = (msg: string, opt?: ToastOptions) =>
27
+ openToast({ message: msg, type: 'primary', icon: true, ...opt })
28
+ const loading = (msg: string = '加载中...', opt?: ToastOptions) =>
29
+ openToast({ message: msg, type: 'primary', loading: true, ...opt })
30
+ const close = (all?: boolean) => closeToast()
31
+
32
+ return { show, info, success, error, warning, primary, loading, close }
33
+ }
34
+
35
+ /**
36
+ * ✅ 实现
37
+ * 页面创建总事件,调用方法实现
38
+ */
39
+ const openToast = (opt: ToastOptions) => {
40
+ uni.$emit('__hy_toast_open__', opt)
41
+ }
42
+
43
+ const closeToast = () => {
44
+ uni.$emit('__hy_toast_close__')
45
+ }
@@ -7,8 +7,8 @@
7
7
  font-style: normal;
8
8
  }
9
9
 
10
- .iconfont {
11
- font-family: "hy-icon" !important;
10
+ .hy-icon {
11
+ font-family: "hy-icon";
12
12
  font-size: 16px;
13
13
  font-style: normal;
14
14
  -webkit-font-smoothing: antialiased;
package/package.json CHANGED
@@ -1,81 +1,81 @@
1
- {
2
- "name": "hy-app",
3
- "version": "0.6.2",
4
- "description": "📱一个基于vue3+ts构建的uni-app组件库,拥有八十多个精美组件,适配多端,支持自定义主题",
5
- "main": "./index.ts",
6
- "private": false,
7
- "scripts": {},
8
- "keywords": [
9
- "华玥组件库",
10
- "精美ui库",
11
- "移动端组件库",
12
- "适配多端小程序",
13
- "暗黑模式"
14
- ],
15
- "vetur":{
16
- "tags":"./tags.json",
17
- "attributes":"./attributes.json"
18
- },
19
- "web-types": "./web-types.json",
20
- "author": "华玥作者",
21
- "license": "MIT",
22
- "uni_modules": {
23
- "dependencies": [],
24
- "encrypt": [],
25
- "platforms": {
26
- "cloud": {
27
- "tcb": "√",
28
- "aliyun": "√",
29
- "alipay": "√"
30
- },
31
- "client": {
32
- "uni-app": {
33
- "vue": {
34
- "vue2": "x",
35
- "vue3": "√"
36
- },
37
- "web": {
38
- "safari": "√",
39
- "chrome": "√"
40
- },
41
- "app": {
42
- "vue": "√",
43
- "nvue": "-",
44
- "android": "√",
45
- "ios": "√",
46
- "harmony": "√"
47
- },
48
- "mp": {
49
- "weixin": "√",
50
- "alipay": "√",
51
- "toutiao": "√",
52
- "baidu": "-",
53
- "kuaishou": "-",
54
- "jd": "-",
55
- "harmony": "√",
56
- "qq": "√",
57
- "lark": "-"
58
- },
59
- "quickapp": {
60
- "huawei": "-",
61
- "union": "-"
62
- }
63
- },
64
- "uni-app-x": {
65
- "web": {
66
- "safari": "-",
67
- "chrome": "-"
68
- },
69
- "app": {
70
- "android": "-",
71
- "ios": "-",
72
- "harmony": "-"
73
- },
74
- "mp": {
75
- "weixin": "-"
76
- }
77
- }
78
- }
79
- }
80
- }
81
- }
1
+ {
2
+ "name": "hy-app",
3
+ "version": "0.6.3",
4
+ "description": "📱一个基于vue3+ts构建的uni-app组件库,拥有八十多个精美组件,适配多端,支持自定义主题",
5
+ "main": "./index.ts",
6
+ "private": false,
7
+ "scripts": {},
8
+ "keywords": [
9
+ "华玥组件库",
10
+ "精美ui库",
11
+ "移动端组件库",
12
+ "适配多端小程序",
13
+ "暗黑模式"
14
+ ],
15
+ "vetur": {
16
+ "tags": "./tags.json",
17
+ "attributes": "./attributes.json"
18
+ },
19
+ "web-types": "./web-types.json",
20
+ "author": "华玥作者",
21
+ "license": "MIT",
22
+ "uni_modules": {
23
+ "dependencies": [],
24
+ "encrypt": [],
25
+ "platforms": {
26
+ "cloud": {
27
+ "tcb": "√",
28
+ "aliyun": "√",
29
+ "alipay": "√"
30
+ },
31
+ "client": {
32
+ "uni-app": {
33
+ "vue": {
34
+ "vue2": "x",
35
+ "vue3": "√"
36
+ },
37
+ "web": {
38
+ "safari": "√",
39
+ "chrome": "√"
40
+ },
41
+ "app": {
42
+ "vue": "√",
43
+ "nvue": "-",
44
+ "android": "√",
45
+ "ios": "√",
46
+ "harmony": "√"
47
+ },
48
+ "mp": {
49
+ "weixin": "√",
50
+ "alipay": "√",
51
+ "toutiao": "√",
52
+ "baidu": "-",
53
+ "kuaishou": "-",
54
+ "jd": "-",
55
+ "harmony": "√",
56
+ "qq": "√",
57
+ "lark": "-"
58
+ },
59
+ "quickapp": {
60
+ "huawei": "-",
61
+ "union": "-"
62
+ }
63
+ },
64
+ "uni-app-x": {
65
+ "web": {
66
+ "safari": "-",
67
+ "chrome": "-"
68
+ },
69
+ "app": {
70
+ "android": "-",
71
+ "ios": "-",
72
+ "harmony": "-"
73
+ },
74
+ "mp": {
75
+ "weixin": "-"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }