hy-app 0.6.4 → 0.6.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 (106) hide show
  1. package/attributes.json +1 -1
  2. package/components/hy-address-picker/hy-address-picker.vue +249 -249
  3. package/components/hy-address-picker/props.ts +103 -103
  4. package/components/hy-button/hy-button.vue +320 -289
  5. package/components/hy-button/props.ts +143 -143
  6. package/components/hy-button/typing.d.ts +43 -35
  7. package/components/hy-calendar/header.vue +58 -58
  8. package/components/hy-calendar/hy-calendar.vue +8 -6
  9. package/components/hy-calendar/month.vue +402 -402
  10. package/components/hy-calendar/props.ts +169 -169
  11. package/components/hy-calendar/typing.d.ts +47 -45
  12. package/components/hy-cell-item/hy-cell-item.vue +161 -161
  13. package/components/hy-cell-item/props.ts +59 -59
  14. package/components/hy-check-button/hy-check-button.vue +135 -135
  15. package/components/hy-code-input/hy-code-input.vue +231 -231
  16. package/components/hy-code-input/props.ts +90 -90
  17. package/components/hy-config-provider/hy-config-provider.vue +53 -53
  18. package/components/hy-config-provider/props.ts +30 -30
  19. package/components/hy-coupon/hy-coupon.vue +183 -183
  20. package/components/hy-coupon/props.ts +108 -108
  21. package/components/hy-datetime-picker/hy-datetime-picker.vue +41 -55
  22. package/components/hy-datetime-picker/props.ts +144 -144
  23. package/components/hy-datetime-picker/typing.d.ts +2 -0
  24. package/components/hy-divider/props.ts +83 -83
  25. package/components/hy-empty/icon.ts +72 -72
  26. package/components/hy-folding-panel/hy-folding-panel-group.vue +162 -162
  27. package/components/hy-form/hy-form.vue +220 -220
  28. package/components/hy-icon/hy-icon.vue +112 -112
  29. package/components/hy-index-bar/hy-index-bar.vue +185 -185
  30. package/components/hy-index-bar/index.scss +64 -64
  31. package/components/hy-index-bar/props.ts +94 -94
  32. package/components/hy-index-bar/typing.d.ts +36 -36
  33. package/components/hy-input/hy-input.vue +333 -333
  34. package/components/hy-input/props.ts +186 -186
  35. package/components/hy-modal/hy-modal.vue +211 -211
  36. package/components/hy-modal/props.ts +94 -94
  37. package/components/hy-modal/typing.d.ts +16 -16
  38. package/components/hy-notice-bar/hy-row-notice.vue +121 -121
  39. package/components/hy-notify/hy-notify.vue +174 -174
  40. package/components/hy-number-step/hy-number-step.vue +367 -367
  41. package/components/hy-overlay/hy-overlay.vue +61 -61
  42. package/components/hy-overlay/props.ts +38 -38
  43. package/components/hy-pagination/hy-pagination.vue +136 -136
  44. package/components/hy-pagination/props.ts +58 -58
  45. package/components/hy-parse/hy-parse.vue +550 -550
  46. package/components/hy-parse/node/node.vue +781 -781
  47. package/components/hy-parse/parser.js +1455 -1455
  48. package/components/hy-parse/props.ts +19 -19
  49. package/components/hy-parse/typing.d.ts +68 -68
  50. package/components/hy-picker/hy-picker.vue +435 -435
  51. package/components/hy-picker/props.ts +122 -122
  52. package/components/hy-picker/typing.d.ts +38 -38
  53. package/components/hy-qrcode/props.ts +72 -72
  54. package/components/hy-qrcode/qrcode.js.bak +1433 -1433
  55. package/components/hy-radio/props.ts +97 -97
  56. package/components/hy-read-more/props.ts +48 -48
  57. package/components/hy-search/props.ts +133 -133
  58. package/components/hy-signature/canvasHelper.ts +51 -51
  59. package/components/hy-signature/props.ts +121 -121
  60. package/components/hy-skeleton/hy-skeleton.vue +142 -142
  61. package/components/hy-skeleton/props.ts +46 -46
  62. package/components/hy-skeleton/typing.d.ts +31 -31
  63. package/components/hy-steps/hy-steps.vue +275 -275
  64. package/components/hy-steps/typing.d.ts +25 -25
  65. package/components/hy-swiper/hy-swiper.vue +3 -3
  66. package/components/hy-swiper/index.scss +5 -5
  67. package/components/hy-swiper/props.ts +0 -1
  68. package/components/hy-table/hy-table.vue +630 -630
  69. package/components/hy-table/props.ts +62 -62
  70. package/components/hy-table/typing.d.ts +29 -29
  71. package/components/hy-tabs/hy-tabs.vue +336 -335
  72. package/components/hy-tabs/props.ts +84 -77
  73. package/components/hy-tag/hy-tag.vue +173 -173
  74. package/components/hy-tag/props.ts +89 -89
  75. package/components/hy-text/hy-text.vue +237 -237
  76. package/components/hy-text/props.ts +115 -115
  77. package/components/hy-textarea/hy-textarea.vue +198 -198
  78. package/components/hy-toast/hy-toast.vue +200 -200
  79. package/components/hy-toast/props.ts +3 -3
  80. package/components/hy-transition/hy-transition.vue +157 -157
  81. package/components/hy-transition/props.ts +32 -32
  82. package/components/hy-upload/hy-upload.vue +384 -384
  83. package/components/hy-watermark/hy-watermark.vue +1058 -1058
  84. package/components/hy-watermark/props.ts +109 -109
  85. package/global.d.ts +94 -94
  86. package/libs/api/http.ts +119 -119
  87. package/libs/composables/index.ts +8 -8
  88. package/libs/composables/useMessage.ts +149 -149
  89. package/libs/composables/useToast.ts +45 -45
  90. package/libs/composables/useTranslate.ts +10 -10
  91. package/libs/css/_config.scss +5 -5
  92. package/libs/index.ts +8 -8
  93. package/libs/locale/index.ts +32 -32
  94. package/libs/locale/lang/en-US.ts +84 -84
  95. package/libs/locale/lang/zh-CN.ts +87 -87
  96. package/libs/typing/index.ts +2 -2
  97. package/libs/typing/modules/common.d.ts +139 -139
  98. package/libs/typing/modules/form.ts +176 -176
  99. package/libs/typing/modules/http.d.ts +19 -19
  100. package/libs/typing/modules/index.d.ts +12 -12
  101. package/libs/utils/inside.ts +340 -340
  102. package/libs/utils/inspect.ts +140 -140
  103. package/libs/utils/utils.ts +525 -525
  104. package/package.json +81 -81
  105. package/tags.json +1 -1
  106. package/web-types.json +1 -1
@@ -1,97 +1,97 @@
1
- import type { CSSProperties, PropType } from 'vue'
2
- import type { CheckboxColumnsVo, IFieldNames } from '../hy-check-button/typing'
3
-
4
- const radioProps = {
5
- /** 双向绑定值,数组类型 */
6
- modelValue: {
7
- type: [String, Number],
8
- required: true
9
- },
10
- /** 选择列表数据 */
11
- columns: {
12
- type: Array as PropType<Array<CheckboxColumnsVo>>,
13
- default: () => [],
14
- required: true
15
- },
16
- /** 自定义接收columns的键 */
17
- fieldNames: {
18
- type: Object as PropType<IFieldNames>,
19
- default: {
20
- label: 'label',
21
- value: 'value',
22
- checked: 'checked'
23
- }
24
- },
25
- /**
26
- * 标签的大小
27
- * @values small,medium,large
28
- * */
29
- size: {
30
- type: String,
31
- default: 'medium'
32
- },
33
- /**
34
- * 标签的形状
35
- * @values circle,square
36
- * */
37
- shape: {
38
- type: String,
39
- default: 'circle'
40
- },
41
- /** 是否禁用 */
42
- disabled: {
43
- type: Boolean,
44
- default: false
45
- },
46
- /** 选中状态下的颜色 */
47
- activeColor: String,
48
- /** 未选中的颜色 */
49
- inactiveColor: {
50
- type: String,
51
- default: '#c8c9cc'
52
- },
53
- /** 图标的大小,单位px */
54
- iconSize: {
55
- type: [String, Number],
56
- default: '20'
57
- },
58
- /** 图标颜色 */
59
- iconColor: String,
60
- /**
61
- * 勾选图标的对齐方式
62
- * @values left,right
63
- * */
64
- iconPlacement: {
65
- type: String,
66
- default: 'left'
67
- },
68
- /** 竖向配列时,是否显示下划线 */
69
- borderBottom: {
70
- type: Boolean,
71
- default: false
72
- },
73
- /** label的字体大小,px单位 */
74
- labelSize: [String, Number],
75
- /** label的颜色 */
76
- labelColor: String,
77
- /** 是否禁止点击提示语选中复选框 */
78
- labelDisabled: {
79
- type: Boolean,
80
- default: false
81
- },
82
- /**
83
- * 排列方式
84
- * @values row,column
85
- * */
86
- placement: {
87
- type: String,
88
- default: 'row'
89
- },
90
- /** 定义需要用到的外部样式 */
91
- customStyle: {
92
- type: Object as PropType<CSSProperties>,
93
- default: () => {}
94
- }
95
- }
96
-
97
- export default radioProps
1
+ import type { CSSProperties, PropType } from 'vue'
2
+ import type { CheckboxColumnsVo, IFieldNames } from '../hy-check-button/typing'
3
+
4
+ const radioProps = {
5
+ /** 双向绑定值,数组类型 */
6
+ modelValue: {
7
+ type: [String, Number],
8
+ required: true
9
+ },
10
+ /** 选择列表数据 */
11
+ columns: {
12
+ type: Array as PropType<Array<CheckboxColumnsVo>>,
13
+ default: () => [],
14
+ required: true
15
+ },
16
+ /** 自定义接收columns的键 */
17
+ fieldNames: {
18
+ type: Object as PropType<IFieldNames>,
19
+ default: {
20
+ label: 'label',
21
+ value: 'value',
22
+ checked: 'checked'
23
+ }
24
+ },
25
+ /**
26
+ * 标签的大小
27
+ * @values small,medium,large
28
+ * */
29
+ size: {
30
+ type: String,
31
+ default: 'medium'
32
+ },
33
+ /**
34
+ * 标签的形状
35
+ * @values circle,square
36
+ * */
37
+ shape: {
38
+ type: String,
39
+ default: 'circle'
40
+ },
41
+ /** 是否禁用 */
42
+ disabled: {
43
+ type: Boolean,
44
+ default: false
45
+ },
46
+ /** 选中状态下的颜色 */
47
+ activeColor: String,
48
+ /** 未选中的颜色 */
49
+ inactiveColor: {
50
+ type: String,
51
+ default: '#c8c9cc'
52
+ },
53
+ /** 图标的大小,单位px */
54
+ iconSize: {
55
+ type: [String, Number],
56
+ default: '20'
57
+ },
58
+ /** 图标颜色 */
59
+ iconColor: String,
60
+ /**
61
+ * 勾选图标的对齐方式
62
+ * @values left,right
63
+ * */
64
+ iconPlacement: {
65
+ type: String,
66
+ default: 'left'
67
+ },
68
+ /** 竖向配列时,是否显示下划线 */
69
+ borderBottom: {
70
+ type: Boolean,
71
+ default: false
72
+ },
73
+ /** label的字体大小,px单位 */
74
+ labelSize: [String, Number],
75
+ /** label的颜色 */
76
+ labelColor: String,
77
+ /** 是否禁止点击提示语选中复选框 */
78
+ labelDisabled: {
79
+ type: Boolean,
80
+ default: false
81
+ },
82
+ /**
83
+ * 排列方式
84
+ * @values row,column
85
+ * */
86
+ placement: {
87
+ type: String,
88
+ default: 'row'
89
+ },
90
+ /** 定义需要用到的外部样式 */
91
+ customStyle: {
92
+ type: Object as PropType<CSSProperties>,
93
+ default: () => {}
94
+ }
95
+ }
96
+
97
+ export default radioProps
@@ -1,48 +1,48 @@
1
- import type { CSSProperties, PropType } from 'vue'
2
- import { useTranslate } from '@/package'
3
-
4
- const { t } = useTranslate('readMore')
5
-
6
- const readMoreProps = {
7
- /** 内容超出此高度才会显示展开全文按钮,单位px */
8
- showHeight: {
9
- type: Number,
10
- default: 200
11
- },
12
- /** 展开后是否显示收起按钮 */
13
- toggle: {
14
- type: Boolean,
15
- default: true
16
- },
17
- /** 关闭时的提示文字 */
18
- closeText: {
19
- type: String,
20
- default: () => t('expand')
21
- },
22
- /** 展开时的提示文字 */
23
- openText: {
24
- type: String,
25
- default: () => t('retract')
26
- },
27
- /** 提示文字的颜色 */
28
- color: String,
29
- /** 提示文字的大小,单位px */
30
- fontSize: {
31
- type: Number,
32
- default: 14
33
- },
34
- /** 段落首行缩进的字符个数 */
35
- textIndent: {
36
- type: String,
37
- default: '2em'
38
- },
39
- /** 用于在 open 和 close 事件中当作回调参数返回 */
40
- name: String,
41
- /** 显示阴影的样式 */
42
- shadowStyle: {
43
- type: Object as PropType<CSSProperties>,
44
- default: () => {}
45
- }
46
- }
47
-
48
- export default readMoreProps
1
+ import type { CSSProperties, PropType } from 'vue'
2
+ import { useTranslate } from '@/package'
3
+
4
+ const { t } = useTranslate('readMore')
5
+
6
+ const readMoreProps = {
7
+ /** 内容超出此高度才会显示展开全文按钮,单位px */
8
+ showHeight: {
9
+ type: Number,
10
+ default: 200
11
+ },
12
+ /** 展开后是否显示收起按钮 */
13
+ toggle: {
14
+ type: Boolean,
15
+ default: true
16
+ },
17
+ /** 关闭时的提示文字 */
18
+ closeText: {
19
+ type: String,
20
+ default: () => t('expand')
21
+ },
22
+ /** 展开时的提示文字 */
23
+ openText: {
24
+ type: String,
25
+ default: () => t('retract')
26
+ },
27
+ /** 提示文字的颜色 */
28
+ color: String,
29
+ /** 提示文字的大小,单位px */
30
+ fontSize: {
31
+ type: Number,
32
+ default: 14
33
+ },
34
+ /** 段落首行缩进的字符个数 */
35
+ textIndent: {
36
+ type: String,
37
+ default: '2em'
38
+ },
39
+ /** 用于在 open 和 close 事件中当作回调参数返回 */
40
+ name: String,
41
+ /** 显示阴影的样式 */
42
+ shadowStyle: {
43
+ type: Object as PropType<CSSProperties>,
44
+ default: () => {}
45
+ }
46
+ }
47
+
48
+ export default readMoreProps
@@ -1,133 +1,133 @@
1
- import type { CSSProperties, PropType } from 'vue'
2
- import { IconConfig, useTranslate } from '../../libs'
3
- import type { HyIconProps } from '../hy-icon/typing'
4
-
5
- const { t } = useTranslate('search')
6
-
7
- const searchProps = {
8
- /** 输入框初始值 */
9
- modelValue: {
10
- type: String,
11
- default: ''
12
- },
13
- /**
14
- * 搜索框形状
15
- * @values circle,square
16
- * */
17
- shape: {
18
- type: String,
19
- default: 'circle'
20
- },
21
- /** 搜索框背景颜色 */
22
- bgColor: String,
23
- /** 占位文字内容 */
24
- placeholder: {
25
- type: String,
26
- default: () => t('placeholder')
27
- },
28
- /**
29
- * 设置右下角按钮的文字,兼容性详见uni-app文档
30
- * @valuse send,search,next,go,done
31
- * */
32
- confirmType: {
33
- type: String,
34
- default: 'search'
35
- },
36
- /** 是否启用清除控件 */
37
- clearable: {
38
- type: Boolean,
39
- default: true
40
- },
41
- /** 是否自动获得焦点 */
42
- autoFocus: {
43
- type: Boolean,
44
- default: false
45
- },
46
- /** 键盘收起时,是否自动失去焦点 */
47
- autoBlur: {
48
- type: Boolean,
49
- default: true
50
- },
51
- /** 键盘弹起时,是否自动上推页面 */
52
- adjustPosition: {
53
- type: Boolean,
54
- default: true
55
- },
56
- /** 是否显示右侧控件 */
57
- showAction: {
58
- type: Boolean,
59
- default: true
60
- },
61
- /** 右侧控件文字 */
62
- actionText: {
63
- type: String,
64
- default: () => t('search')
65
- },
66
- /** 右侧控件的样式,对象形式 */
67
- actionStyle: {
68
- type: Object as PropType<CSSProperties>,
69
- default: () => {}
70
- },
71
- /** 输入框内容水平对齐方式 */
72
- inputAlign: {
73
- type: String,
74
- default: 'left'
75
- },
76
- /** 自定义输入框样式,对象形式 */
77
- inputStyle: {
78
- type: Object as PropType<CSSProperties>,
79
- default: () => {}
80
- },
81
- /** 是否启用输入框 */
82
- disabled: {
83
- type: Boolean,
84
- default: false
85
- },
86
- /** 边框颜色,配置了颜色,才会有边框 */
87
- borderColor: {
88
- type: String,
89
- default: 'transparent'
90
- },
91
- /** 输入框字体颜色 */
92
- color: String,
93
- /** placeholder的颜色 */
94
- placeholderColor: {
95
- type: String,
96
- default: ''
97
- },
98
- /** 输入框左边的图标属性集合,可以为图标名称或图片路径 */
99
- searchIcon: {
100
- type: [Boolean, Object] as PropType<HyIconProps | boolean>,
101
- default: { name: IconConfig.SEARCH }
102
- },
103
- /** 组件与其他上下左右之间的距离,带单位的字符串形式,如"30px" */
104
- margin: {
105
- type: [String, Number],
106
- default: 0
107
- },
108
- /** 是否开启动画,见上方说明 */
109
- animation: {
110
- type: Boolean,
111
- default: false
112
- },
113
- /** 输入框最大能输入的长度,-1为不限制长度 */
114
- maxlength: {
115
- type: Number,
116
- default: -1
117
- },
118
- /** 输入框高度,单位px */
119
- height: {
120
- type: Number,
121
- default: 30
122
- },
123
- /** 搜索框左边显示内容 */
124
- label: String,
125
- /** 定义需要用到的外部样式 */
126
- customStyle: {
127
- type: Object as PropType<CSSProperties>
128
- },
129
- /** 自定义外部类名 */
130
- customClass: String
131
- }
132
-
133
- export default searchProps
1
+ import type { CSSProperties, PropType } from 'vue'
2
+ import { IconConfig, useTranslate } from '../../libs'
3
+ import type { HyIconProps } from '../hy-icon/typing'
4
+
5
+ const { t } = useTranslate('search')
6
+
7
+ const searchProps = {
8
+ /** 输入框初始值 */
9
+ modelValue: {
10
+ type: String,
11
+ default: ''
12
+ },
13
+ /**
14
+ * 搜索框形状
15
+ * @values circle,square
16
+ * */
17
+ shape: {
18
+ type: String,
19
+ default: 'circle'
20
+ },
21
+ /** 搜索框背景颜色 */
22
+ bgColor: String,
23
+ /** 占位文字内容 */
24
+ placeholder: {
25
+ type: String,
26
+ default: () => t('placeholder')
27
+ },
28
+ /**
29
+ * 设置右下角按钮的文字,兼容性详见uni-app文档
30
+ * @valuse send,search,next,go,done
31
+ * */
32
+ confirmType: {
33
+ type: String,
34
+ default: 'search'
35
+ },
36
+ /** 是否启用清除控件 */
37
+ clearable: {
38
+ type: Boolean,
39
+ default: true
40
+ },
41
+ /** 是否自动获得焦点 */
42
+ autoFocus: {
43
+ type: Boolean,
44
+ default: false
45
+ },
46
+ /** 键盘收起时,是否自动失去焦点 */
47
+ autoBlur: {
48
+ type: Boolean,
49
+ default: true
50
+ },
51
+ /** 键盘弹起时,是否自动上推页面 */
52
+ adjustPosition: {
53
+ type: Boolean,
54
+ default: true
55
+ },
56
+ /** 是否显示右侧控件 */
57
+ showAction: {
58
+ type: Boolean,
59
+ default: true
60
+ },
61
+ /** 右侧控件文字 */
62
+ actionText: {
63
+ type: String,
64
+ default: () => t('search')
65
+ },
66
+ /** 右侧控件的样式,对象形式 */
67
+ actionStyle: {
68
+ type: Object as PropType<CSSProperties>,
69
+ default: () => {}
70
+ },
71
+ /** 输入框内容水平对齐方式 */
72
+ inputAlign: {
73
+ type: String,
74
+ default: 'left'
75
+ },
76
+ /** 自定义输入框样式,对象形式 */
77
+ inputStyle: {
78
+ type: Object as PropType<CSSProperties>,
79
+ default: () => {}
80
+ },
81
+ /** 是否启用输入框 */
82
+ disabled: {
83
+ type: Boolean,
84
+ default: false
85
+ },
86
+ /** 边框颜色,配置了颜色,才会有边框 */
87
+ borderColor: {
88
+ type: String,
89
+ default: 'transparent'
90
+ },
91
+ /** 输入框字体颜色 */
92
+ color: String,
93
+ /** placeholder的颜色 */
94
+ placeholderColor: {
95
+ type: String,
96
+ default: ''
97
+ },
98
+ /** 输入框左边的图标属性集合,可以为图标名称或图片路径 */
99
+ searchIcon: {
100
+ type: [Boolean, Object] as PropType<HyIconProps | boolean>,
101
+ default: { name: IconConfig.SEARCH }
102
+ },
103
+ /** 组件与其他上下左右之间的距离,带单位的字符串形式,如"30px" */
104
+ margin: {
105
+ type: [String, Number],
106
+ default: 0
107
+ },
108
+ /** 是否开启动画,见上方说明 */
109
+ animation: {
110
+ type: Boolean,
111
+ default: false
112
+ },
113
+ /** 输入框最大能输入的长度,-1为不限制长度 */
114
+ maxlength: {
115
+ type: Number,
116
+ default: -1
117
+ },
118
+ /** 输入框高度,单位px */
119
+ height: {
120
+ type: Number,
121
+ default: 30
122
+ },
123
+ /** 搜索框左边显示内容 */
124
+ label: String,
125
+ /** 定义需要用到的外部样式 */
126
+ customStyle: {
127
+ type: Object as PropType<CSSProperties>
128
+ },
129
+ /** 自定义外部类名 */
130
+ customClass: String
131
+ }
132
+
133
+ export default searchProps
@@ -1,51 +1,51 @@
1
- /**
2
- * 适配 canvas 2d 上下文
3
- * @param ctx canvas 2d 上下文
4
- * @returns
5
- */
6
- export function canvas2dAdapter(
7
- ctx: CanvasRenderingContext2D,
8
- ): UniApp.CanvasContext {
9
- return Object.assign(ctx, {
10
- setFillStyle(color: string | CanvasGradient) {
11
- ctx.fillStyle = color;
12
- },
13
- setStrokeStyle(color: string | CanvasGradient | CanvasPattern) {
14
- ctx.strokeStyle = color;
15
- },
16
- setLineWidth(lineWidth: number) {
17
- ctx.lineWidth = lineWidth;
18
- },
19
- setLineCap(lineCap: "butt" | "round" | "square") {
20
- ctx.lineCap = lineCap;
21
- },
22
-
23
- setFontSize(font: string) {
24
- ctx.font = font;
25
- },
26
- setGlobalAlpha(alpha: number) {
27
- ctx.globalAlpha = alpha;
28
- },
29
- setLineJoin(lineJoin: "bevel" | "round" | "miter") {
30
- ctx.lineJoin = lineJoin;
31
- },
32
- setTextAlign(align: "left" | "center" | "right") {
33
- ctx.textAlign = align;
34
- },
35
- setMiterLimit(miterLimit: number) {
36
- ctx.miterLimit = miterLimit;
37
- },
38
- setShadow(offsetX: number, offsetY: number, blur: number, color: string) {
39
- ctx.shadowOffsetX = offsetX;
40
- ctx.shadowOffsetY = offsetY;
41
- ctx.shadowBlur = blur;
42
- ctx.shadowColor = color;
43
- },
44
- setTextBaseline(textBaseline: "top" | "bottom" | "middle") {
45
- ctx.textBaseline = textBaseline;
46
- },
47
- createCircularGradient() {},
48
- draw() {},
49
- addColorStop() {},
50
- }) as unknown as UniApp.CanvasContext;
51
- }
1
+ /**
2
+ * 适配 canvas 2d 上下文
3
+ * @param ctx canvas 2d 上下文
4
+ * @returns
5
+ */
6
+ export function canvas2dAdapter(
7
+ ctx: CanvasRenderingContext2D,
8
+ ): UniApp.CanvasContext {
9
+ return Object.assign(ctx, {
10
+ setFillStyle(color: string | CanvasGradient) {
11
+ ctx.fillStyle = color;
12
+ },
13
+ setStrokeStyle(color: string | CanvasGradient | CanvasPattern) {
14
+ ctx.strokeStyle = color;
15
+ },
16
+ setLineWidth(lineWidth: number) {
17
+ ctx.lineWidth = lineWidth;
18
+ },
19
+ setLineCap(lineCap: "butt" | "round" | "square") {
20
+ ctx.lineCap = lineCap;
21
+ },
22
+
23
+ setFontSize(font: string) {
24
+ ctx.font = font;
25
+ },
26
+ setGlobalAlpha(alpha: number) {
27
+ ctx.globalAlpha = alpha;
28
+ },
29
+ setLineJoin(lineJoin: "bevel" | "round" | "miter") {
30
+ ctx.lineJoin = lineJoin;
31
+ },
32
+ setTextAlign(align: "left" | "center" | "right") {
33
+ ctx.textAlign = align;
34
+ },
35
+ setMiterLimit(miterLimit: number) {
36
+ ctx.miterLimit = miterLimit;
37
+ },
38
+ setShadow(offsetX: number, offsetY: number, blur: number, color: string) {
39
+ ctx.shadowOffsetX = offsetX;
40
+ ctx.shadowOffsetY = offsetY;
41
+ ctx.shadowBlur = blur;
42
+ ctx.shadowColor = color;
43
+ },
44
+ setTextBaseline(textBaseline: "top" | "bottom" | "middle") {
45
+ ctx.textBaseline = textBaseline;
46
+ },
47
+ createCircularGradient() {},
48
+ draw() {},
49
+ addColorStop() {},
50
+ }) as unknown as UniApp.CanvasContext;
51
+ }