hy-app 0.5.4 → 0.5.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.
Files changed (115) hide show
  1. package/components/hy-action-sheet/typing.d.ts +1 -63
  2. package/components/hy-address-picker/hy-address-picker.vue +7 -6
  3. package/components/hy-address-picker/typing.d.ts +0 -84
  4. package/components/hy-avatar/typing.d.ts +0 -66
  5. package/components/hy-back-top/props.ts +2 -3
  6. package/components/hy-back-top/typing.d.ts +0 -47
  7. package/components/hy-badge/props.ts +1 -1
  8. package/components/hy-badge/typing.d.ts +3 -60
  9. package/components/hy-button/props.ts +1 -1
  10. package/components/hy-button/typing.d.ts +28 -162
  11. package/components/hy-calendar/hy-calendar.vue +2 -2
  12. package/components/hy-calendar/typing.d.ts +0 -128
  13. package/components/hy-card/hy-card.vue +14 -13
  14. package/components/hy-card/props.ts +4 -6
  15. package/components/hy-card/typing.d.ts +1 -114
  16. package/components/hy-cell/hy-cell.vue +9 -190
  17. package/components/hy-cell/props.ts +7 -26
  18. package/components/hy-cell/typing.d.ts +2 -96
  19. package/components/hy-cell-item/hy-cell-item.vue +160 -0
  20. package/components/hy-cell-item/index.scss +100 -0
  21. package/components/hy-cell-item/props.ts +66 -0
  22. package/components/hy-cell-item/typing.d.ts +7 -0
  23. package/components/hy-check-button/typing.d.ts +0 -43
  24. package/components/hy-checkbox/typing.d.ts +1 -73
  25. package/components/hy-checkbox-group/props.ts +1 -1
  26. package/components/hy-checkbox-group/typing.d.ts +0 -65
  27. package/components/hy-checkbox-item/typing.d.ts +3 -3
  28. package/components/hy-code-input/typing.d.ts +0 -70
  29. package/components/hy-count-down/typing.d.ts +1 -20
  30. package/components/hy-count-to/typing.d.ts +0 -47
  31. package/components/hy-coupon/typing.d.ts +0 -133
  32. package/components/hy-datetime-picker/typing.d.ts +0 -119
  33. package/components/hy-dropdown-item/typing.d.ts +12 -31
  34. package/components/hy-empty/typing.d.ts +1 -59
  35. package/components/hy-float-button/typing.d.ts +24 -113
  36. package/components/hy-form/typing.d.ts +0 -27
  37. package/components/hy-form-item/hy-form-item.vue +7 -5
  38. package/components/hy-form-item/typing.d.ts +0 -19
  39. package/components/hy-grid/props.ts +1 -1
  40. package/components/hy-grid/typing.d.ts +1 -45
  41. package/components/hy-icon/props.ts +1 -1
  42. package/components/hy-icon/typing.d.ts +3 -84
  43. package/components/hy-image/typing.d.ts +0 -80
  44. package/components/hy-input/hy-input.vue +19 -22
  45. package/components/hy-input/props.ts +1 -1
  46. package/components/hy-input/typing.d.ts +0 -149
  47. package/components/hy-list/typing.d.ts +0 -51
  48. package/components/hy-menu/props.ts +2 -2
  49. package/components/hy-menu/typing.d.ts +0 -35
  50. package/components/hy-modal/typing.d.ts +9 -84
  51. package/components/hy-navbar/typing.d.ts +0 -81
  52. package/components/hy-notice-bar/typing.d.ts +0 -65
  53. package/components/hy-number-step/props.ts +1 -1
  54. package/components/hy-number-step/typing.d.ts +0 -110
  55. package/components/hy-overlay/typing.d.ts +2 -27
  56. package/components/hy-pagination/typing.d.ts +6 -49
  57. package/components/hy-picker/typing.d.ts +27 -124
  58. package/components/hy-popover/typing.d.ts +25 -66
  59. package/components/hy-popup/typing.d.ts +8 -77
  60. package/components/hy-price/hy-price.vue +9 -2
  61. package/components/hy-price/typing.d.ts +0 -41
  62. package/components/hy-qrcode/hy-qrcode.vue +3 -4
  63. package/components/hy-qrcode/index.scss +3 -3
  64. package/components/hy-qrcode/qrcode.js +0 -138
  65. package/components/hy-qrcode/typing.d.ts +0 -66
  66. package/components/hy-radio/typing.d.ts +1 -86
  67. package/components/hy-rate/typing.d.ts +0 -62
  68. package/components/hy-read-more/typing.d.ts +4 -49
  69. package/components/hy-scroll-list/typing.d.ts +4 -33
  70. package/components/hy-search/props.ts +1 -2
  71. package/components/hy-search/typing.d.ts +19 -120
  72. package/components/hy-signature/typing.d.ts +0 -101
  73. package/components/hy-slider/typing.d.ts +8 -77
  74. package/components/hy-steps/typing.d.ts +16 -60
  75. package/components/hy-submit-bar/typing.d.ts +0 -72
  76. package/components/hy-subsection/typing.d.ts +0 -49
  77. package/components/hy-swipe-action/index.ts +13 -22
  78. package/components/hy-swipe-action/typing.d.ts +1 -38
  79. package/components/hy-swiper/typing.d.ts +0 -101
  80. package/components/hy-switch/props.ts +1 -1
  81. package/components/hy-switch/typing.d.ts +0 -62
  82. package/components/hy-tabbar/index.scss +1 -1
  83. package/components/hy-tabbar/props.ts +1 -1
  84. package/components/hy-tabbar/typing.d.ts +0 -40
  85. package/components/hy-tabbar-group/props.ts +1 -1
  86. package/components/hy-tabbar-item/typing.ts +0 -12
  87. package/components/hy-tabs/props.ts +1 -1
  88. package/components/hy-tabs/typing.d.ts +25 -92
  89. package/components/hy-tag/props.ts +1 -1
  90. package/components/hy-tag/typing.d.ts +9 -78
  91. package/components/hy-text/typing.d.ts +3 -100
  92. package/components/hy-textarea/typing.d.ts +0 -27
  93. package/components/hy-tooltip/props.ts +0 -1
  94. package/components/hy-tooltip/typing.d.ts +2 -55
  95. package/components/hy-transition/typing.d.ts +14 -43
  96. package/components/hy-upload/typing.d.ts +56 -164
  97. package/components/hy-warn/typing.d.ts +4 -45
  98. package/global.d.ts +1 -0
  99. package/libs/css/theme.scss +1 -1
  100. package/package.json +2 -2
  101. package/web-types.json +1 -1
  102. package/components/hy-card/index.scss +0 -57
  103. package/components/hy-cell/index.scss +0 -136
  104. package/components/hy-config-provider/typing.d.ts +0 -24
  105. package/components/hy-divider/typing.d.ts +0 -64
  106. package/components/hy-dropdown/typing.d.ts +0 -48
  107. package/components/hy-form-group/typing.d.ts +0 -0
  108. package/components/hy-line/typing.d.ts +0 -32
  109. package/components/hy-line-progress/typing.d.ts +0 -32
  110. package/components/hy-loading/typing.d.ts +0 -52
  111. package/components/hy-notify/typing.d.ts +0 -48
  112. package/components/hy-status-bar/typing.d.ts +0 -12
  113. package/components/hy-tabbar-group/README.md +0 -326
  114. package/components/hy-waterfall/typing.d.ts +0 -14
  115. package/components/hy-watermark/typing.d.ts +0 -76
@@ -1,131 +1,34 @@
1
- import type { CSSProperties } from "vue";
2
- import type HyInputProps from "../hy-input/typing";
3
-
4
1
  export interface PickerColumnVo extends AnyObject {
5
- /**
6
- * @description id必填
7
- * */
8
- id: string;
9
- /**
10
- * @description 显示文本
11
- * */
12
- text?: string;
2
+ /**
3
+ * @description id必填
4
+ * */
5
+ id: string
6
+ /**
7
+ * @description 显示文本
8
+ * */
9
+ text?: string
13
10
  }
14
11
 
15
- export default interface HyPickerProps {
16
- /**
17
- * @description 显示到输入框值
18
- * */
19
- modelValue?: string | string[];
20
- /**
21
- * @description 对象数组,设置每一列的数据
22
- * */
23
- columns: (string | PickerColumnVo)[][];
24
- /**
25
- * @description 是否显示弹窗(默认 false )
26
- * */
27
- show?: boolean;
28
- /**
29
- * @description 弹窗弹出模式
30
- * */
31
- popupMode?: HyApp.LayoutType;
32
- /**
33
- * @description 分割数组条件
34
- * */
35
- separator?: string;
36
- /**
37
- * @description 是否显示顶部的操作栏(默认 true )
38
- * */
39
- showToolbar?: boolean;
40
- /**
41
- * @description 顶部标题
42
- * */
43
- title?: string;
44
- /**
45
- * @description 是否显示加载中状态(默认 false )
46
- * */
47
- loading?: boolean;
48
- /**
49
- * @description 各列中,单个选项的高度(默认 44 )
50
- * */
51
- itemHeight?: number;
52
- /**
53
- * @description 取消按钮的文字(默认 '取消' )
54
- * */
55
- cancelText?: string;
56
- /**
57
- * @description 确认按钮的文字(默认 '确定' )
58
- * */
59
- confirmText?: string;
60
- /**
61
- * @description 取消按钮的颜色(默认 '#909193' )
62
- * */
63
- cancelColor?: string;
64
- /**
65
- * @description 确认按钮的颜色(默认 '#3c9cff' )
66
- * */
67
- confirmColor?: string;
68
- /**
69
- * @description 每列中可见选项的数量(默认 5 )
70
- * */
71
- visibleItemCount?: number;
72
- /**
73
- * @description 选项对象中,需要展示的属性键名(默认 'text' )
74
- * */
75
- keyName?: string;
76
- /**
77
- * @description 是否允许点击遮罩关闭选择器(默认 false )
78
- * */
79
- closeOnClickOverlay?: boolean;
80
- /**
81
- * @description 各列的默认索引
82
- * */
83
- defaultIndex?: number[];
84
- /**
85
- * @description 是否在手指松开时立即触发change事件(默认 true )
86
- * */
87
- immediateChange?: boolean;
88
- /**
89
- * @description 最高层级
90
- * */
91
- zIndex?: number;
92
- /**
93
- * @description 是否显示输入框(默认 false )
94
- * */
95
- hasInput?: boolean;
96
- /**
97
- * @description 输入框集合属性
98
- * */
99
- input?: Partial<HyInputProps>;
100
- /**
101
- * @description 是否自定义选择器nav左边内容
102
- * */
103
- toolbarRightSlot?: boolean;
104
- /**
105
- * @description 自定义输入框外部样式
106
- * */
107
- customStyle?: CSSProperties;
12
+ export type SelectValueVo = {
13
+ value: string[]
14
+ index?: number
15
+ indexs?: number[]
16
+ // values为当前变化列的数组内容
17
+ values?: Array<any>
18
+ columnIndex?: number
108
19
  }
109
20
 
110
- export type SelectValueVo = {
111
- value: string[];
112
- index?: number;
113
- indexs?: number[];
114
- // values为当前变化列的数组内容
115
- values?: Array<any>;
116
- columnIndex?: number;
117
- };
118
21
  export interface IPickerEmits {
119
- /** 关闭选择器时触发 */
120
- (e: "close"): void;
121
- /** 点击取消按钮 */
122
- (e: "cancel"): void;
123
- /** 点击确定按钮,返回当前选择的值 */
124
- (e: "confirm", params: SelectValueVo): void;
125
- /** 当选择值变化时触发 */
126
- (e: "change", params: SelectValueVo): void;
127
- /** 显示隐藏触发 */
128
- (e: "update:show", show: boolean): void;
129
- /** 选中值触发 */
130
- (e: "update:modelValue", value: any): void;
22
+ /** 关闭选择器时触发 */
23
+ (e: 'close'): void
24
+ /** 点击取消按钮 */
25
+ (e: 'cancel'): void
26
+ /** 点击确定按钮,返回当前选择的值 */
27
+ (e: 'confirm', params: SelectValueVo): void
28
+ /** 当选择值变化时触发 */
29
+ (e: 'change', params: SelectValueVo): void
30
+ /** 显示隐藏触发 */
31
+ (e: 'update:show', show: boolean): void
32
+ /** 选中值触发 */
33
+ (e: 'update:modelValue', value: any): void
131
34
  }
@@ -1,80 +1,39 @@
1
- import type { CSSProperties } from 'vue'
2
-
3
1
  export type IPlacementVo =
4
- | 'top'
5
- | 'top-start'
6
- | 'top-end'
7
- | 'bottom'
8
- | 'bottom-start'
9
- | 'bottom-end'
10
- | 'left'
11
- | 'left-start'
12
- | 'left-end'
13
- | 'right'
14
- | 'right-start'
15
- | 'right-end'
2
+ | 'top'
3
+ | 'top-start'
4
+ | 'top-end'
5
+ | 'bottom'
6
+ | 'bottom-start'
7
+ | 'bottom-end'
8
+ | 'left'
9
+ | 'left-start'
10
+ | 'left-end'
11
+ | 'right'
12
+ | 'right-start'
13
+ | 'right-end'
16
14
  export type IOffset = number | number[] | Record<'x' | 'y', number>
17
15
 
18
16
  export type PopoverExpose = {
19
- open: () => void
20
- close: () => void
17
+ open: () => void
18
+ close: () => void
21
19
  }
22
20
  export interface PopoverContentVo {
23
- iconClass: string
24
- content: string
25
- icon: string
26
- }
27
-
28
- export default interface HyOverlayProps {
29
- /**
30
- * @description 控制 popover 的显示状态
31
- * */
32
- modelValue?: boolean
33
- /**
34
- * @description 显示的内容,也可以通过 slot#content 传入
35
- */
36
- content?: string | (string | PopoverContentVo)[]
37
- /**
38
- * @description 指定 popover 的放置位置:top / top-start / top-end / bottom / bottom-start / bottom-end / left / left-start / left-end / right / right-start / right-end
39
- */
40
- placement?: IPlacementVo
41
- /**
42
- * @description 控制 popover 的显示状态
43
- */
44
- offset?: IOffset
45
- /**
46
- * @description 是否禁用 popover
47
- */
48
- disabled?: boolean
49
- /**
50
- * @description 是否显示关闭按钮
51
- */
52
- showClose?: boolean
53
- /**
54
- * 当前显示的模式,决定内容的展现形式,可选值:normal(普通模式)/ menu(菜单模式)
55
- */
56
- mode?: 'normal' | 'menu'
57
- /**
58
- * @description 定义需要用到的外部样式
59
- * */
60
- customStyle?: CSSProperties
61
- /**
62
- * @description 定义需要用到的类名
63
- * */
64
- customClass?: string
21
+ iconClass: string
22
+ content: string
23
+ icon: string
65
24
  }
66
25
 
67
26
  export type PopoverParamsVo = {
68
- show: boolean
27
+ show: boolean
69
28
  }
70
29
  export type PopoverItemParamsVo = {
71
- item: Record<string, any>
72
- index: number
30
+ item: Record<string, any>
31
+ index: number
73
32
  }
74
33
  export interface IPopoverEmits {
75
- (e: 'menuClick', params: PopoverItemParamsVo): void
76
- (e: 'change', params: PopoverParamsVo): void
77
- (e: 'open'): void
78
- (e: 'close'): void
79
- (e: 'update:modelValue', value: boolean): void
34
+ (e: 'menuClick', params: PopoverItemParamsVo): void
35
+ (e: 'change', params: PopoverParamsVo): void
36
+ (e: 'open'): void
37
+ (e: 'close'): void
38
+ (e: 'update:modelValue', value: boolean): void
80
39
  }
@@ -1,79 +1,10 @@
1
- import type { CSSProperties } from 'vue'
2
-
3
- export default interface HyPopupProps {
4
- /**
5
- * @description 是否展示弹窗 (默认 false )
6
- * */
7
- show: boolean
8
- /**
9
- * @description 是否显示遮罩 (默认 true )
10
- * */
11
- overlay?: boolean
12
- /**
13
- * @description 弹出方向(默认 'bottom' )
14
- * */
15
- mode?: HyApp.LayoutType
16
- /**
17
- * @description 动画时长,单位ms (默认 300 )
18
- * */
19
- duration?: number
20
- /**
21
- * @description 是否显示关闭图标(默认 false )
22
- * */
23
- closeable?: boolean
24
- /**
25
- * @description 自定义遮罩的样式
26
- * */
27
- overlayStyle?: CSSProperties
28
- /**
29
- * @description 遮罩透明度,0-1之间(默认 0.5)
30
- * */
31
- overlayOpacity?: number
32
- /**
33
- * @description 点击遮罩是否关闭弹窗 (默认 true )
34
- * */
35
- closeOnClickOverlay?: boolean
36
- /**
37
- * @description 层级 (默认 10075 )
38
- * */
39
- zIndex?: number
40
- /**
41
- * @description 是否为iPhoneX留出底部安全距离 (默认 true )
42
- * */
43
- safeAreaInsetBottom?: boolean
44
- /**
45
- * @description 是否留出顶部安全距离(状态栏高度) (默认 false )
46
- * */
47
- safeAreaInsetTop?: boolean
48
- /**
49
- * @description 自定义关闭图标位置(默认 'top-right' )
50
- * */
51
- closeIconPos?: 'top-left' | 'top-right'
52
- /**
53
- * @description 圆角值(默认 0)
54
- * */
55
- round?: string | number
56
- /**
57
- * @description 当mode=center时 是否开启缩放(默认 true )
58
- * */
59
- zoom?: boolean
60
- /**
61
- * @description 背景颜色
62
- * */
63
- bgColor?: string
64
- /**
65
- * @description 自定义样式
66
- * */
67
- customStyle?: CSSProperties
68
- }
69
-
70
1
  export interface IPopupEmits {
71
- /** 弹出层打开触发 */
72
- (e: 'open'): void
73
- /** 弹出层关闭触发 */
74
- (e: 'close'): void
75
- /** 弹出层点击触发 */
76
- (e: 'click'): void
77
- /** 显示隐藏触发 */
78
- (e: 'update:show', visible: boolean): void
2
+ /** 弹出层打开触发 */
3
+ (e: 'open'): void
4
+ /** 弹出层关闭触发 */
5
+ (e: 'close'): void
6
+ /** 弹出层点击触发 */
7
+ (e: 'click'): void
8
+ /** 显示隐藏触发 */
9
+ (e: 'update:show', visible: boolean): void
79
10
  }
@@ -54,10 +54,17 @@ const priceOne = computed(() => {
54
54
  if (props.text === undefined || props.text === null) return error('text值不能为空')
55
55
 
56
56
  let value = typeof props.text === 'string' ? props.text : props.text.toString()
57
+
58
+ // 格式化整数部分为千分位
59
+ const formatValue = (val: string) => {
60
+ return val.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
61
+ }
62
+
57
63
  if (/\./g.test(value)) {
58
- return Number(value) ? value.split('.') : ['0', '000000']
64
+ const [integer, decimal] = value.split('.')
65
+ return [formatValue(integer), decimal]
59
66
  } else {
60
- return [value, '000000']
67
+ return [formatValue(value), '000000']
61
68
  }
62
69
  })
63
70
 
@@ -1,44 +1,3 @@
1
- import type { CSSProperties } from 'vue'
2
-
3
- export default interface HyPriceProps {
4
- /**
5
- * @description 传入金额值
6
- * */
7
- text: string | number
8
- /**
9
- * @description 金额符号(默认:¥)
10
- * */
11
- symbol?: string
12
- /**
13
- * @description 比例大小(默认:1.4)
14
- * */
15
- ratio?: number
16
- /**
17
- * @description 保留小数点后几位数(默认:2)
18
- * */
19
- num?: number
20
- /**
21
- * @description 字体颜色(默认:#FE3232)
22
- * */
23
- color?: string
24
- /**
25
- * @description 字体大小(默认:12)
26
- * */
27
- size?: string | number
28
- /**
29
- * @description 字体粗细(默认:500)
30
- * */
31
- weight?: number
32
- /**
33
- * @description 是否倾斜(默认:false)
34
- * */
35
- slant?: boolean
36
- /**
37
- * @description 自定义样式
38
- * */
39
- customStyle?: CSSProperties
40
- }
41
-
42
1
  export interface IPriceEmits {
43
2
  /** 点击事件 */
44
3
  (e: 'click', text: string | number): void
@@ -6,7 +6,7 @@
6
6
  <canvas
7
7
  class="hy-qrcode__content--canvas"
8
8
  :id="cid"
9
- type="2d"
9
+ :canvas-id="cid"
10
10
  :style="{ width: addUnit(size), height: addUnit(size) }"
11
11
  />
12
12
  <!-- #endif -->
@@ -36,7 +36,7 @@ export default {
36
36
  import { getCurrentInstance, ref, watch, nextTick } from 'vue'
37
37
  import type { IQrcodeEmits } from './typing'
38
38
  import QRCode from './qrcode.js'
39
- import { addUnit, error, random } from '../../libs'
39
+ import { addUnit, error } from '../../libs'
40
40
  // 组件
41
41
  import HyLoading from '../hy-loading/hy-loading.vue'
42
42
  import HyImage from '../hy-image/hy-image.vue'
@@ -52,7 +52,7 @@ const props = defineProps({
52
52
  /** 实例ID字符串(如果有多个二维码组件必须设置不一样的cid) */
53
53
  cid: {
54
54
  type: String,
55
- default: 'hy-qrcode-canvas_' + random(1, 1000)
55
+ default: 'hy-qrcode-canvas' + Math.random().toString()
56
56
  },
57
57
  /** 二维码大小 */
58
58
  size: {
@@ -138,7 +138,6 @@ const initQrCode = () => {
138
138
  image: props.icon, // 二维码图标
139
139
  imageSize: props.iconSize, // 二维码图标大小
140
140
  cbResult: function (res: any) {
141
- console.log(res)
142
141
  // 生成二维码的回调
143
142
  _result(res)
144
143
  }
@@ -7,9 +7,9 @@
7
7
 
8
8
  @include m(canvas) {
9
9
  position: fixed;
10
- // top: -99999rpx;
11
- // left: -99999rpx;
12
- // z-index: -99999;
10
+ top: -99999rpx;
11
+ left: -99999rpx;
12
+ z-index: -99999;
13
13
  overflow: hidden;
14
14
  }
15
15
 
@@ -1146,111 +1146,6 @@ let QRCode = {}
1146
1146
  }
1147
1147
  return options.foreground
1148
1148
  }
1149
- // 为2D Canvas添加辅助函数
1150
- function drawIconWithBackground(canvas, ctx, options, qrCodeAlg) {
1151
- // 在小程序中使用canvas.createImage()而不是wx.createImage()
1152
- const img = canvas.createImage()
1153
- img.src = options.image
1154
- img.onload = function () {
1155
- var ratioImgSize = options.imageSize || 40
1156
- var x = Number(((options.size - ratioImgSize) / 2).toFixed(2))
1157
- var y = Number(((options.size - ratioImgSize) / 2).toFixed(2))
1158
-
1159
- // 绘制圆角矩形背景
1160
- drawRoundedRect2D(ctx, x, y, ratioImgSize, ratioImgSize, 2, options.background)
1161
-
1162
- // 绘制图标
1163
- ctx.drawImage(img, x, y, ratioImgSize, ratioImgSize)
1164
-
1165
- // 导出图片
1166
- exportCanvasImage(canvas, options)
1167
- }
1168
-
1169
- // 添加错误处理
1170
- img.onerror = function (e) {
1171
- console.error('Failed to load QR code icon:', e)
1172
- // 即使图标加载失败也要导出二维码
1173
- exportCanvasImage(canvas, options)
1174
- }
1175
- }
1176
-
1177
- function drawRoundedRect2D(ctx, x, y, width, height, r, fillColor) {
1178
- ctx.beginPath()
1179
- ctx.moveTo(x + r, y)
1180
- ctx.arcTo(x + width, y, x + width, y + r, r)
1181
- ctx.arcTo(x + width, y + height, x + width - r, y + height, r)
1182
- ctx.arcTo(x, y + height, x, y + height - r, r)
1183
- ctx.arcTo(x, y, x + r, y, r)
1184
- ctx.closePath()
1185
- ctx.fillStyle = fillColor
1186
- ctx.fill()
1187
- }
1188
-
1189
- function exportCanvasImage(canvas, options) {
1190
- setTimeout(() => {
1191
- wx.canvasToTempFilePath(
1192
- {
1193
- canvas: canvas,
1194
- quality: 1,
1195
- success: function (res) {
1196
- if (options.cbResult) {
1197
- options.cbResult(res.tempFilePath)
1198
- }
1199
- },
1200
- fail: function (res) {
1201
- if (options.cbResult) {
1202
- options.cbResult(res)
1203
- }
1204
- },
1205
- complete: function () {
1206
- uni.hideLoading()
1207
- }
1208
- },
1209
- options.context
1210
- )
1211
- }, options.text.length + 100)
1212
- }
1213
-
1214
- // 2D Canvas二维码绘制函数
1215
- function drawQRCode2D(canvas, ctx, options, qrCodeAlg) {
1216
- var count = qrCodeAlg.getModuleCount()
1217
- var ratioSize = options.size
1218
-
1219
- // 清除画布
1220
- ctx.clearRect(0, 0, ratioSize, ratioSize)
1221
- // 设置背景色
1222
- ctx.fillStyle = options.background
1223
- ctx.fillRect(0, 0, ratioSize, ratioSize)
1224
-
1225
- //计算每个点的长宽
1226
- var tileW = (ratioSize / count).toPrecision(4)
1227
- var tileH = (ratioSize / count).toPrecision(4)
1228
-
1229
- //绘制二维码
1230
- for (var row = 0; row < count; row++) {
1231
- for (var col = 0; col < count; col++) {
1232
- var w = Math.ceil((col + 1) * tileW) - Math.floor(col * tileW)
1233
- var h = Math.ceil((row + 1) * tileW) - Math.floor(row * tileW)
1234
- var foreground = getForeGround({
1235
- row: row,
1236
- col: col,
1237
- count: count,
1238
- options: options
1239
- })
1240
- ctx.fillStyle = qrCodeAlg.modules[row][col] ? foreground : options.background
1241
- ctx.fillRect(Math.round(col * tileW), Math.round(row * tileH), w, h)
1242
- }
1243
- }
1244
-
1245
- if (options.image) {
1246
- // 绘制中间图标
1247
- drawIconWithBackground(canvas, ctx, options, qrCodeAlg)
1248
- } else {
1249
- // 导出图片
1250
- exportCanvasImage(canvas, options)
1251
- }
1252
- }
1253
-
1254
1149
  // 创建canvas
1255
1150
  let createCanvas = function (options) {
1256
1151
  if (options.showLoading) {
@@ -1259,39 +1154,6 @@ let QRCode = {}
1259
1154
  mask: true
1260
1155
  })
1261
1156
  }
1262
-
1263
- // 尝试使用2D Canvas (小程序端)
1264
- try {
1265
- if (!options.nvueContext && typeof wx !== 'undefined' && wx.createSelectorQuery) {
1266
- const query = wx.createSelectorQuery().in(options.context)
1267
- query
1268
- .select('#' + options.canvasId)
1269
- .fields({ node: true, size: true })
1270
- .exec((res) => {
1271
- if (res[0] && res[0].node) {
1272
- const canvas = res[0].node
1273
- const ctx = canvas.getContext('2d')
1274
-
1275
- // 设置canvas尺寸
1276
- const dpr = wx.getSystemInfoSync().pixelRatio
1277
- canvas.width = options.size * dpr
1278
- canvas.height = options.size * dpr
1279
- ctx.scale(dpr, dpr)
1280
-
1281
- // 创建二维码算法实例
1282
- var qrCodeAlg = new QRCodeAlg(options.text, options.correctLevel)
1283
-
1284
- // 使用2D Canvas绘制
1285
- drawQRCode2D(canvas, ctx, options, qrCodeAlg)
1286
- return
1287
- }
1288
- })
1289
- }
1290
- } catch (e) {
1291
- console.warn('2D Canvas initialization failed, falling back to legacy mode:', e)
1292
- }
1293
-
1294
- // 回退到传统Canvas方式
1295
1157
  var ctx = ''
1296
1158
  if (options.nvueContext) {
1297
1159
  ctx = options.nvueContext
@@ -1,69 +1,3 @@
1
- import type { CSSProperties } from 'vue'
2
-
3
- export default interface HyQrcodeProps {
4
- /**
5
- * @description 实例ID字符串(如果有多个二维码组件必须设置不一样的cid)
6
- * */
7
- cid?: string
8
- /**
9
- * @description 二维码大小
10
- * */
11
- size?: string | number
12
-
13
- /**
14
- * @description 二维码内容
15
- * */
16
- text: string
17
- /**
18
- * @description 是否显示二维码
19
- * */
20
- show?: boolean
21
- /**
22
- * @description 二维码背景色
23
- * */
24
- background?: string
25
- /**
26
- * @description 二维码颜色
27
- * */
28
- foreground?: string
29
- /**
30
- * @description 定位角点颜色
31
- * */
32
- pdGround?: string
33
- /**
34
- * @description 容错级别
35
- * */
36
- lv?: number
37
- /**
38
- * @description 是否是自定义组件
39
- * */
40
- usingComponents?: boolean
41
- /**
42
- * @description 二维码中间图标
43
- * */
44
- icon?: string
45
- /**
46
- * @description 二维码中间图标大小
47
- * */
48
- iconSize?: string | number
49
- /**
50
- * @description 显示加载状态
51
- * */
52
- showLoading?: boolean
53
- /**
54
- * @description 加载中提示语
55
- * */
56
- loadingText?: string
57
- /**
58
- * @description 是否预览
59
- * */
60
- allowPreview?: boolean
61
- /**
62
- * @description 定义需要用到的外部样式
63
- * */
64
- customStyle?: CSSProperties
65
- }
66
-
67
1
  export interface IQrcodeEmits {
68
2
  /** 二维码生成成功 */
69
3
  (e: 'result', res: any): void