hy-app 0.4.5 → 0.4.7

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.
@@ -384,7 +384,7 @@ export default {
384
384
  // 获取月份数据区域的宽度,因为nvue不支持百分比,所以无法通过css设置每个日期item的宽度
385
385
  getWrapperWidth() {
386
386
  // #ifndef APP-NVUE
387
- getRect(".hy-calendar--month__wrapper").then((size) => {
387
+ getRect(".hy-calendar--month__wrapper", false, this).then((size) => {
388
388
  this.width = size.width;
389
389
  });
390
390
  // #endif
@@ -413,7 +413,7 @@ export default {
413
413
  // $uGetRect为uView自带的节点查询简化方法,详见文档介绍:https://ijry.github.io/uview-plus/js/getRect.html
414
414
  // 组件内部一般用this.$uGetRect,对外的为uni.$u.getRect,二者功能一致,名称不同
415
415
  return new Promise((resolve) => {
416
- getRect(`.${el}`).then((size) => {
416
+ getRect(`.${el}`, false, this).then((size) => {
417
417
  resolve(size);
418
418
  });
419
419
  });
@@ -3,7 +3,7 @@
3
3
  ref="hyVirtualContainer"
4
4
  @scroll="onScroll"
5
5
  @scrolltolower="scrollToLower"
6
- :lower-threshold="showDivider ? 40 : 10"
6
+ :lower-threshold="showDivider ? 100 : 50"
7
7
  :scroll-y="true"
8
8
  scroll-with-animation
9
9
  class="hy-virtual-container"
@@ -60,7 +60,8 @@
60
60
  </template>
61
61
  <!--加载更多样式-->
62
62
  </view>
63
- <!-- <HyDivider :text="load" v-if="showDivider"></HyDivider>-->
63
+ <slot v-if="$slots.footer" name="footer"></slot>
64
+ <hy-divider :text="load" v-else-if="showDivider"></hy-divider>
64
65
  </scroll-view>
65
66
  </template>
66
67
 
@@ -81,15 +82,16 @@ import {
81
82
  getCurrentInstance,
82
83
  nextTick,
83
84
  onMounted,
84
- type PropType,
85
85
  reactive,
86
86
  ref,
87
87
  useSlots,
88
88
  watch,
89
89
  } from "vue";
90
- import type { CSSProperties } from "vue";
90
+ import type { CSSProperties, PropType } from "vue";
91
91
  import { addUnit, getPx, getRect } from "../../libs";
92
92
  import type { IListEmits } from "./typing";
93
+ // 组件
94
+ import HyDivider from "@/package/components/hy-divider/hy-divider.vue";
93
95
 
94
96
  /**
95
97
  * 实现只展示可视内容的dom,减少dom创建,优化滚动性能
@@ -1,9 +1,8 @@
1
1
  <template>
2
2
  <view
3
- class="hy-loading-icon"
4
- :style="customStyle"
5
- :class="[vertical && 'hy-loading-icon__vertical']"
6
3
  v-if="show"
4
+ :style="customStyle"
5
+ :class="['hy-loading-icon', `hy-loading-icon__${direction}`]"
7
6
  >
8
7
  <view
9
8
  v-if="!webviewHide"
@@ -34,7 +33,7 @@
34
33
  </view>
35
34
  <text
36
35
  v-if="text"
37
- class="hy-loading-icon__text"
36
+ :class="['hy-loading-icon__text', `hy-loading-icon__${direction}--text`]"
38
37
  :style="{
39
38
  fontSize: addUnit(textSize),
40
39
  color: textColor,
@@ -84,10 +83,13 @@ const props = defineProps({
84
83
  type: String,
85
84
  default: "#909399",
86
85
  },
87
- /** 文字和图标是否垂直排列 */
88
- vertical: {
89
- type: Boolean,
90
- default: false,
86
+ /**
87
+ * 文字和图标是否垂直排列
88
+ * @values row,column
89
+ * */
90
+ direction: {
91
+ type: String as PropType<HyApp.DirectionType>,
92
+ default: "row",
91
93
  },
92
94
  /** 模式选择,见官网说明 */
93
95
  mode: {
@@ -3,13 +3,11 @@
3
3
 
4
4
 
5
5
  @include b(loading-icon) {
6
- @include flex(row);
7
6
  align-items: center;
8
7
  justify-content: center;
9
8
  color: #c8c9cc;
10
9
 
11
10
  @include e(text) {
12
- margin-left: 4px;
13
11
  color: $hy-text-color--grey;
14
12
  font-size: 14px;
15
13
  line-height: 20px;
@@ -37,8 +35,20 @@
37
35
  }
38
36
  }
39
37
 
40
- @include m(vertical) {
41
- flex-direction: column;
38
+ @include e(row) {
39
+ @include flex(row);
40
+
41
+ @include m(text) {
42
+ margin-left: $hy-border-margin-padding-base;
43
+ }
44
+ }
45
+
46
+ @include e(column) {
47
+ @include flex(column);
48
+
49
+ @include m(text) {
50
+ margin-top: $hy-border-margin-padding-base;
51
+ }
42
52
  }
43
53
  }
44
54
 
@@ -60,7 +70,6 @@
60
70
  }
61
71
 
62
72
  @include e(vertical, text) {
63
- margin: 6px 0 0;
64
73
  color: $hy-text-color--grey;
65
74
  }
66
75
 
@@ -7,79 +7,83 @@
7
7
  height: addUnit(getPx(height) + statusBarHeight),
8
8
  }"
9
9
  ></view>
10
- <view :class="[fixed && 'hy-navbar__fixed']">
10
+ <view
11
+ :class="[fixed && 'hy-navbar__fixed']"
12
+ :style="{ backgroundColor: bgColor }"
13
+ >
11
14
  <HyStatusBar v-if="safeAreaInsetTop" :bgColor="bgColor"></HyStatusBar>
12
15
  <view
13
16
  :class="[border && 'hy-border__bottom', 'hy-navbar__content']"
14
17
  :style="{
15
18
  height: addUnit(height),
16
- backgroundColor: bgColor,
17
19
  }"
18
20
  >
21
+ <!-- 左边 -->
22
+ <slot v-if="$slots.left" name="left"></slot>
19
23
  <view
24
+ v-else
20
25
  class="hy-navbar__content__left"
21
26
  hover-class="hy-navbar__content__left--hover"
22
27
  hover-start-time="150"
23
28
  @tap="leftClick"
24
29
  >
25
- <slot name="left">
26
- <HyIcon
27
- v-if="leftIcon"
28
- :name="leftIcon"
29
- :size="leftIconSize"
30
- :color="leftIconColor"
31
- ></HyIcon>
32
- <text
33
- v-if="leftText"
34
- :style="{
35
- color: leftIconColor,
36
- }"
37
- class="hy-navbar__content__left--text"
38
- >
39
- {{ leftText }}
40
- </text>
41
- </slot>
30
+ <HyIcon
31
+ v-if="leftIcon"
32
+ :name="leftIcon"
33
+ :size="leftIconSize"
34
+ :color="leftIconColor"
35
+ ></HyIcon>
36
+ <text
37
+ v-if="leftText"
38
+ :style="{
39
+ color: leftIconColor,
40
+ }"
41
+ class="hy-navbar__content__left--text"
42
+ >
43
+ {{ leftText }}
44
+ </text>
42
45
  </view>
43
- <slot name="center">
44
- <view class="hy-navbar__content__center">
45
- <text
46
- class="hy-navbar__content__center--title"
47
- :style="[
48
- {
49
- width: addUnit(titleWidth),
50
- color: titleColor,
51
- },
52
- titleStyle,
53
- ]"
54
- >
55
- {{ title }}
56
- </text>
57
- <text
58
- class="hy-navbar__content__center--sub"
59
- :style="[
60
- {
61
- width: addUnit(titleWidth),
62
- color: titleColor,
63
- },
64
- titleStyle,
65
- ]"
66
- >
67
- {{ sub }}
68
- </text>
69
- </view>
70
- </slot>
71
- <view
72
- class="hy-navbar__content__right"
73
- v-if="$slots.right || rightIcon || rightText"
74
- @tap="rightClick"
75
- >
76
- <slot name="right">
77
- <HyIcon v-if="rightIcon" :name="rightIcon" size="20"></HyIcon>
78
- <text v-if="rightText" class="hy-navbar__content__right--text">{{
79
- rightText
80
- }}</text>
81
- </slot>
46
+ <!-- 左边 -->
47
+
48
+ <!-- 中间 -->
49
+ <slot v-if="$slots.center" name="center"></slot>
50
+ <view v-else class="hy-navbar__content__center">
51
+ <text
52
+ class="hy-navbar__content__center--title"
53
+ :style="[
54
+ {
55
+ width: addUnit(titleWidth),
56
+ color: titleColor,
57
+ },
58
+ titleStyle,
59
+ ]"
60
+ >
61
+ {{ title }}
62
+ </text>
63
+ <text
64
+ class="hy-navbar__content__center--sub"
65
+ :style="[
66
+ {
67
+ width: addUnit(titleWidth),
68
+ color: titleColor,
69
+ },
70
+ titleStyle,
71
+ ]"
72
+ >
73
+ {{ sub }}
74
+ </text>
75
+ </view>
76
+ <!-- 中间 -->
77
+
78
+ <!-- 右边 -->
79
+ <slot v-if="$slots.right" name="right"></slot>
80
+ <view class="hy-navbar__content__right" v-else @tap="rightClick">
81
+ <HyIcon v-if="rightIcon" :name="rightIcon" size="20"></HyIcon>
82
+ <text v-if="rightText" class="hy-navbar__content__right--text">{{
83
+ rightText
84
+ }}</text>
82
85
  </view>
86
+ <!-- 右边 -->
83
87
  </view>
84
88
  </view>
85
89
  </view>
@@ -252,6 +252,7 @@ const clickHandler = (e: TouchEvent) => {
252
252
  // return;
253
253
  // }
254
254
  e.stopPropagation();
255
+ console.log(e, "微信");
255
256
  let x = 0;
256
257
  // #ifndef APP-NVUE || MP-ALIPAY
257
258
  x = e.detail.x;
@@ -210,7 +210,7 @@ const props = defineProps({
210
210
  /** placeholder的颜色 */
211
211
  placeholderColor: {
212
212
  type: String,
213
- default: "#909399",
213
+ default: "",
214
214
  },
215
215
  /** 输入框左边的图标属性集合,可以为图标名称或图片路径 */
216
216
  searchIcon: [Boolean, Object] as PropType<HyIconProps | boolean>,
@@ -62,6 +62,7 @@ $hy-search-close-size: 20px !default;
62
62
  @include m(placeholder) {
63
63
  font-size: 25rpx;
64
64
  color: $hy-text-color--placeholder;
65
+ line-height: 30rpx;
65
66
  }
66
67
  }
67
68
  }
@@ -4,38 +4,39 @@
4
4
  :style="submitBarStyle"
5
5
  >
6
6
  <view class="hy-submit-bar__left">
7
- <slot name="left">
8
- <view
9
- class="hy-submit-bar__left--item"
10
- v-for="(item, i) in menus"
11
- :key="i"
12
- @tap="clickMenuFn(i)"
13
- >
14
- <HyIcon
15
- :name="item.icon"
16
- :label="item.text"
17
- :color="iconColor"
18
- :label-color="iconLabelColor"
19
- labelPos="bottom"
20
- space="7"
21
- :size="20"
22
- ></HyIcon>
23
- <HyBadge
24
- :value="item?.badge?.value"
25
- :absolute="true"
26
- :offset="item?.badge?.offset || [-5, 20]"
27
- :isDot="item?.badge?.isDot"
28
- :type="item?.badge?.type"
29
- :color="item?.badge?.color"
30
- :shape="item?.badge?.shape"
31
- :numberType="item?.badge?.numberType"
32
- :inverted="item?.badge?.inverted"
33
- ></HyBadge>
34
- </view>
35
- </slot>
7
+ <slot v-if="$slots.left" name="left"></slot>
8
+ <view
9
+ v-else-if="menus.length"
10
+ class="hy-submit-bar__left--item"
11
+ v-for="(item, i) in menus"
12
+ :key="i"
13
+ @tap="clickMenuFn(i)"
14
+ >
15
+ <HyIcon
16
+ :name="item.icon"
17
+ :label="item.text"
18
+ :color="iconColor"
19
+ :label-color="iconLabelColor"
20
+ labelPos="bottom"
21
+ space="7"
22
+ :size="20"
23
+ ></HyIcon>
24
+ <HyBadge
25
+ :value="item?.badge?.value"
26
+ :absolute="true"
27
+ :offset="item?.badge?.offset || [-5, 20]"
28
+ :isDot="item?.badge?.isDot"
29
+ :type="item?.badge?.type"
30
+ :color="item?.badge?.color"
31
+ :shape="item?.badge?.shape"
32
+ :numberType="item?.badge?.numberType"
33
+ :inverted="item?.badge?.inverted"
34
+ ></HyBadge>
35
+ </view>
36
36
  </view>
37
37
  <view class="hy-submit-bar__right">
38
- <slot name="right">
38
+ <slot v-if="$slots.right" name="right"></slot>
39
+ <template v-else>
39
40
  <view
40
41
  class="hy-submit-bar__right--button"
41
42
  v-if="showLeftBtn"
@@ -64,7 +65,7 @@
64
65
  ></HyLoading>
65
66
  {{ rightBtnText }}
66
67
  </view>
67
- </slot>
68
+ </template>
68
69
  </view>
69
70
  </view>
70
71
  </template>
@@ -169,6 +170,11 @@ const props = defineProps({
169
170
  type: String,
170
171
  default: "circle",
171
172
  },
173
+ /** 层级 */
174
+ zIndex: {
175
+ type: [Number, String],
176
+ default: 999,
177
+ },
172
178
  /** 定义需要用到的外部样式 */
173
179
  customStyle: {
174
180
  type: Object as PropType<CSSProperties>,
@@ -186,6 +192,7 @@ const submitBarStyle = computed(() => {
186
192
  const style: CSSProperties = {
187
193
  bottom: 0,
188
194
  left: 0,
195
+ zIndex: props.zIndex,
189
196
  };
190
197
  if (props.fixed) style.position = "fixed";
191
198
  return Object.assign(style, props.customStyle);
@@ -174,6 +174,7 @@ const show = (options: ToastOptions) => {
174
174
 
175
175
  // 隐藏toast组件,由父组件通过this.$refs.xxx.hide()形式调用
176
176
  const hide = () => {
177
+ config.loading = false;
177
178
  clearTimer();
178
179
  };
179
180
  /**
@@ -1,9 +1,5 @@
1
1
  <template>
2
- <view
3
- :class="['hy-tooltip', customClass]"
4
- :style="customStyle"
5
- @click.stop="closeHandler"
6
- >
2
+ <view :class="['hy-tooltip', customClass]" :style="customStyle">
7
3
  <HyOverlay
8
4
  :show="showTooltip && tooltipTop !== -10000 && overlay"
9
5
  :customStyle="{ backgroundColor: 'rgba(0, 0, 0, 0)' }"
@@ -35,7 +31,7 @@
35
31
  v-if="showCopy"
36
32
  class="hy-tooltip__container--list__btn"
37
33
  hover-class="hy-tooltip__container--list__btn--hover"
38
- @tap="setClipboardData"
34
+ @tap.stop="setClipboardData"
39
35
  >
40
36
  <text class="hy-tooltip__container--list__btn--text">复制</text>
41
37
  </view>
@@ -16,7 +16,7 @@ $hy-tooltip--background-color: rgb(50, 50, 51);
16
16
  background-clip: padding-box;
17
17
  text-align: center;
18
18
  min-height: 36px;
19
- z-index: $hy-tooltip--z-index;
19
+ z-index: 99999;
20
20
  transition: opacity 0.2s;
21
21
  box-shadow: $hy-box-shadow;
22
22
  border-radius: $hy-border-radius-sm;
@@ -67,7 +67,6 @@ $hy-tooltip--background-color: rgb(50, 50, 51);
67
67
  padding: 0;
68
68
  @include flex(row);
69
69
  align-items: center;
70
- z-index: 999;
71
70
 
72
71
  @include e(btn) {
73
72
  padding: $hy-border-margin-padding-base;
@@ -532,11 +532,12 @@ function drawTextOffScreen(
532
532
  color: string,
533
533
  canvas: HTMLCanvasElement,
534
534
  ) {
535
+ console.log(fontSize, "离屏");
535
536
  ctx.textBaseline = "middle";
536
537
  ctx.textAlign = "center";
537
538
  ctx.translate(contentWidth / 2, contentWidth / 2);
538
539
  ctx.rotate((Math.PI / 180) * rotate);
539
- ctx.font = `${fontStyle} normal ${fontWeight} ${fontSize}px ${fontFamily}`;
540
+ ctx.font = `${fontStyle} normal ${fontWeight} ${fontSize}px/${contentHeight}px ${fontFamily}`;
540
541
  ctx.fillStyle = color;
541
542
  ctx.fillText(content, 0, 0);
542
543
  ctx.restore();
package/libs/api/http.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { HttpRequestConfig } from "../../libs/typing";
2
2
  import { objectToUrlParams } from "../../libs";
3
3
 
4
- export default class Http {
4
+ export class Http {
5
5
  /**
6
6
  * 默认请求配置
7
7
  */
@@ -14,17 +14,17 @@ let toastInstance: any = null;
14
14
  */
15
15
  export const useToast = () => {
16
16
  const show = (msg: string, opt?: ToastOptions) =>
17
- openToast({ message: msg, icon: false, ...opt });
17
+ openToast({ message: msg, icon: false, type: "", ...opt });
18
18
  const info = (msg: string, opt?: ToastOptions) =>
19
- openToast({ message: msg, type: "info", ...opt });
19
+ openToast({ message: msg, type: "info", icon: true, ...opt });
20
20
  const success = (msg: string, opt?: ToastOptions) =>
21
- openToast({ message: msg, type: "success", ...opt });
21
+ openToast({ message: msg, type: "success", icon: true, ...opt });
22
22
  const error = (msg: string, opt?: ToastOptions) =>
23
- openToast({ message: msg, type: "error", ...opt });
23
+ openToast({ message: msg, type: "error", icon: true, ...opt });
24
24
  const warning = (msg: string, opt?: ToastOptions) =>
25
- openToast({ message: msg, type: "warning", ...opt });
25
+ openToast({ message: msg, type: "warning", icon: true, ...opt });
26
26
  const primary = (msg: string, opt?: ToastOptions) =>
27
- openToast({ message: msg, type: "primary", ...opt });
27
+ openToast({ message: msg, type: "primary", icon: true, ...opt });
28
28
  const loading = (msg: string = "加载中...", opt?: ToastOptions) =>
29
29
  openToast({ message: msg, loading: true, ...opt });
30
30
  const close = (all?: boolean) => closeToast();
@@ -32,7 +32,7 @@ $hy-text-color--3: var(--hy-text-color--3, #929295) !default; // 一般用于浅
32
32
  $hy-text-color--4: var(--hy-text-color--4, rgba(0, 0, 0, 0.1)) !default; // 一般用于浅色
33
33
  $hy-icon-color: var(--hy-icon-color, #606266) !default; // 一般用于icon
34
34
  $hy-text-color--grey: var(--hy-text-color--grey, #999) !default; // 辅助灰色,如加载更多的提示信息
35
- $hy-text-color--placeholder: var(--hy-text-color--placeholder, #808080) !default; // 输入框提示颜色
35
+ $hy-text-color--placeholder: var(--hy-text-color--placeholder, #909399) !default; // 输入框提示颜色
36
36
  $hy-text-color--disabled: var(--hy-text-color--disabled, #c0c0c0) !default; // 禁用文字颜色
37
37
  $hy-border-color: var(--hy-border-color, #c0c0c0) !default; // 边框颜色
38
38
  $hy-text-color--hover: var(--hy-text-color--hover, #58595b)!default; // 点击状态文字颜色
@@ -7,7 +7,7 @@
7
7
  --hy-text-color--4: rgba(0, 0, 0, 0.1);
8
8
  --hy-icon-color: #999;
9
9
  --hy-text-color--grey: #67676c;
10
- --hy-text-color--placeholder: rgba(0, 0, 0, 0.25);
10
+ --hy-text-color--placeholder: #909399;
11
11
  --hy-text-color--disabled: rgba(0, 0, 0, 0.25);
12
12
 
13
13
  --hy-background: #f8f8f8;
@@ -40,7 +40,7 @@
40
40
  --hy-text-color--4: rgba(255, 255, 255, 0.1);
41
41
  --hy-icon-color: #FFFFFF;
42
42
  --hy-text-color--grey: #98989f;
43
- --hy-text-color--placeholder: rgba(255, 255, 255, 0.25);
43
+ --hy-text-color--placeholder: #909399;
44
44
  --hy-text-color--disabled: rgba(255, 255, 255, 0.25);
45
45
 
46
46
  --hy-background: #1b1b1f;
@@ -372,6 +372,32 @@ const objectToUrlParams = (params: Record<string, any>): string => {
372
372
  .join("&"); // 使用 & 拼接所有参数
373
373
  };
374
374
 
375
+ /**
376
+ * @description 地址栏参数转换对象
377
+ * @param paramStr - 字符串参数
378
+ * @returns 返回转换对象
379
+ */
380
+ const urlParamsToObject = (paramStr: string): AnyObject => {
381
+ const params: AnyObject = {};
382
+ // 去掉字符串两端的可能的空格
383
+ paramStr = paramStr.trim();
384
+ // 如果字符串以?开头,去掉它
385
+ if (paramStr.startsWith("?")) {
386
+ paramStr = paramStr.substring(1);
387
+ }
388
+ // 按&分割字符串,得到键值对数组
389
+ const pairs = paramStr.split("&");
390
+ for (let i = 0; i < pairs.length; i++) {
391
+ const pair = pairs[i];
392
+ // 按=分割键值对
393
+ const [key, ...valueParts] = pair.split("=");
394
+ const value = valueParts.join("=");
395
+ // 将键值对存入对象
396
+ params[decodeURIComponent(key)] = decodeURIComponent(value);
397
+ }
398
+ return params;
399
+ };
400
+
375
401
  /**
376
402
  * 获取 [min,max]的随机数
377
403
  * Math.floor(Math.random()*10) 可均衡获取 0 到 9 的随机整数
@@ -486,6 +512,7 @@ export {
486
512
  deepClone,
487
513
  bytesToSize,
488
514
  objectToUrlParams,
515
+ urlParamsToObject,
489
516
  random,
490
517
  range,
491
518
  getRect,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hy-app",
3
- "version": "0.4.5",
4
- "description": "fix: 修复toast在支付小程序获取不到ref问题",
3
+ "version": "0.4.7",
4
+ "description": "fix: 修复tooltip点击无法复制问题",
5
5
  "main": "./index.ts",
6
6
  "private": false,
7
7
  "scripts": {},