sadais-piui 1.2.7-beta18 → 1.2.7-beta181

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 (104) hide show
  1. package/.prettierrc +8 -0
  2. package/CHANGELOG.md +7 -1
  3. package/components/pi-action-sheet/index.vue +262 -247
  4. package/components/pi-badge/index.vue +66 -8
  5. package/components/pi-bottom-bar/index.vue +15 -4
  6. package/components/pi-bubble/index.vue +14 -3
  7. package/components/pi-button/index.vue +17 -4
  8. package/components/pi-calendar/index.vue +207 -182
  9. package/components/pi-calendar-input/index.vue +72 -31
  10. package/components/pi-calendar-panel/components/calendar-days/index.vue +134 -54
  11. package/components/pi-calendar-panel/index.vue +52 -19
  12. package/components/pi-canvas/index.vue +18 -2
  13. package/components/pi-card/index.vue +5 -1
  14. package/components/pi-cascader/index.vue +635 -0
  15. package/components/pi-checkbox/index.vue +8 -4
  16. package/components/pi-checkbox-group/index.vue +12 -11
  17. package/components/pi-circle-progress/index.vue +75 -19
  18. package/components/pi-code-input/index.vue +11 -2
  19. package/components/pi-collapse/index.vue +18 -7
  20. package/components/pi-collapse-item/index.vue +35 -22
  21. package/components/pi-count-up/index.vue +8 -2
  22. package/components/pi-date-picker/index.vue +678 -391
  23. package/components/pi-date-picker-input/index.vue +74 -31
  24. package/components/pi-divider/index.vue +5 -1
  25. package/components/pi-dropdown/components/dropdown-tab.vue +38 -23
  26. package/components/pi-dropdown/index.vue +50 -23
  27. package/components/pi-dropdown-item/index.vue +82 -62
  28. package/components/pi-form/index.vue +9 -3
  29. package/components/pi-form-item/index.vue +105 -21
  30. package/components/pi-grid/index.vue +6 -2
  31. package/components/pi-grid-item/index.vue +17 -8
  32. package/components/pi-icon/index.vue +6 -1
  33. package/components/pi-img/index.vue +275 -267
  34. package/components/pi-img-cropper/canvas.js +10 -3
  35. package/components/pi-img-cropper/index.vue +6 -3
  36. package/components/pi-img-cropper/touch.js +4 -1
  37. package/components/pi-img-cropper/vector.js +2 -2
  38. package/components/pi-input/index.vue +97 -36
  39. package/components/pi-line-progress/index.vue +9 -2
  40. package/components/pi-list/index.vue +5 -1
  41. package/components/pi-list-item/index.vue +9 -4
  42. package/components/pi-loading/index.vue +10 -2
  43. package/components/pi-marquee/index.vue +322 -310
  44. package/components/pi-marquee-pure-css/index.vue +267 -0
  45. package/components/pi-mask/index.vue +3 -1
  46. package/components/pi-modal/index.vue +311 -303
  47. package/components/pi-navbar/index.vue +22 -5
  48. package/components/pi-notify/index.vue +9 -3
  49. package/components/pi-number-keyboard/index.vue +15 -3
  50. package/components/pi-opentype-button/index.vue +11 -3
  51. package/components/pi-pagination/index.vue +18 -1
  52. package/components/pi-picker/index.vue +332 -317
  53. package/components/pi-popup/index.vue +12 -5
  54. package/components/pi-popup-select/index.vue +13 -4
  55. package/components/pi-radio/index.vue +12 -11
  56. package/components/pi-radio-group/index.vue +28 -6
  57. package/components/pi-rate/index.vue +9 -2
  58. package/components/pi-regions-select/index.vue +50 -12
  59. package/components/pi-regions-select-input/index.vue +69 -31
  60. package/components/pi-search/index.vue +37 -2
  61. package/components/pi-section/index.vue +6 -2
  62. package/components/pi-select/index.vue +237 -22
  63. package/components/pi-select-input/index.vue +106 -41
  64. package/components/pi-skeleton/index.vue +2 -1
  65. package/components/pi-status-bar/index.vue +4 -1
  66. package/components/pi-stepper/index.vue +34 -20
  67. package/components/pi-steps/index.vue +56 -13
  68. package/components/pi-subsection/index.vue +10 -5
  69. package/components/pi-swiper/index.vue +21 -7
  70. package/components/pi-switch/index.vue +19 -6
  71. package/components/pi-table/index.vue +351 -0
  72. package/components/pi-tabs/index.vue +87 -20
  73. package/components/pi-tag/index.vue +17 -5
  74. package/components/pi-upload-img/index.vue +914 -44
  75. package/components/pi-waterfall/index.vue +14 -5
  76. package/components/pi-webview/index.vue +95 -82
  77. package/config/actionSheet.js +1 -2
  78. package/config/badge.js +2 -1
  79. package/config/calendarInput.js +2 -1
  80. package/config/calendarPanel.js +2 -1
  81. package/config/cascader.js +22 -0
  82. package/config/circleProgress.js +32 -4
  83. package/config/codeInput.js +2 -1
  84. package/config/datePicker.js +31 -24
  85. package/config/datePickerInput.js +2 -1
  86. package/config/dropdown.js +3 -1
  87. package/config/formItem.js +2 -1
  88. package/config/input.js +5 -3
  89. package/config/marqueePureCss.js +18 -0
  90. package/config/regionsSelectInput.js +2 -1
  91. package/config/select.js +13 -1
  92. package/config/selectInput.js +2 -1
  93. package/config/table.js +9 -0
  94. package/config/uploadImg.js +57 -12
  95. package/context7.json +4 -0
  96. package/index.js +15 -2
  97. package/mixin/emitter.js +8 -1
  98. package/mixin/page-transitions/index.js +7 -2
  99. package/mixin/value-sync.js +5 -0
  100. package/package.json +5 -2
  101. package/scss/common.scss +18 -21
  102. package/scss/icon/icon.scss +2 -1
  103. package/scss/mixin.scss +5 -5
  104. package/utils/file-utils.js +273 -0
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "trailingComma": "none",
3
+ "arrowParens": "avoid",
4
+ "bracketSpacing": true,
5
+ "quoteProps": "consistent",
6
+ "semi": false,
7
+ "singleQuote": true
8
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ <a name="1.2.7-beta180"></a>
4
+ ## 1.2.7-beta180 (2026-05-11)
5
+
6
+ ### Added
7
+
8
+ - ✨ feat: pi-calendar-panel 的 marks 支持对象形式配置标记颜色
9
+
3
10
  <a name="1.2.5"></a>
4
11
  ## 1.2.5 (2022-04-25)
5
12
 
@@ -542,4 +549,3 @@
542
549
  - feat: 初始化预设样式 [95e77f9]
543
550
  - feat: 初始化提交 [f4abca2]
544
551
 
545
-
@@ -1,247 +1,262 @@
1
- <template>
2
- <pi-popup-select
3
- :value="val"
4
- :custom-style="getPopupSelect.customStyle"
5
- :custom-class="getPopupSelect.customClass"
6
- :height="getPopupSelect.height"
7
- :show-title="getPopupSelect.showTitle"
8
- :title="getPopupSelect.title"
9
- :title-padding="getPopupSelect.titlePadding"
10
- :toolbar-position="getPopupSelect.toolbarPosition"
11
- :on-confirm-close="getPopupSelect.onConfirmClose"
12
- :on-cancel-close="getPopupSelect.onCancelClose"
13
- :confirm-btn="getPopupSelect.confirmBtn"
14
- :cancel-btn="getPopupSelect.cancelBtn"
15
- :popup="getPopup"
16
- @close="handlePopupClose"
17
- @cancel="handleCancel"
18
- @confirm="handleConfirm"
19
- >
20
- <slot name="header" />
21
- <!-- 描述列 -->
22
- <view
23
- v-if="description"
24
- class="pi-solid-bottom-2 pi-align-center pi-pd-32 pi-light-gray"
25
- :style="[getItemAlignStyle]"
26
- >
27
- {{ description }}
28
- </view>
29
- <view
30
- v-for="item in items"
31
- :id="`id-${item[keyField]}`"
32
- :key="item[keyField]"
33
- :style="[itemStyle, getItemStyle, getItemAlignStyle, { color: item.color }]"
34
- :class="{
35
- 'pi-solid-bottom-1': showItemBottomBorder,
36
- 'pi-disabled': item.disabled
37
- }"
38
- class="pi-align-center pi-fz-30 pi-pd-lr-32"
39
- hover-class="pi-hover-class"
40
- @tap.stop="handleSelectItem(item)"
41
- >
42
- <!-- 自定义列表项 -->
43
- <slot name="item" :item="item" class="pi-w-100P">
44
- <template v-if="!item.loading">
45
- {{ item[displayField] }}
46
- </template>
47
- <pi-loading v-else show />
48
- </slot>
49
- </view>
50
- <!-- 取消action -->
51
- <template v-if="cancelText">
52
- <pi-gap height="20" />
53
- <view
54
- class="pi-align-center pi-fz-30 pi-pd-32 pi-light-gray"
55
- hover-class="pi-hover-class"
56
- :style="[getItemAlignStyle]"
57
- @tap="handleCancel"
58
- >
59
- {{ cancelText }}
60
- </view>
61
- </template>
62
-
63
- <slot name="footer" />
64
- </pi-popup-select>
65
- </template>
66
-
67
- <script>
68
- import ValueSync from '../../mixin/value-sync'
69
- import { getConfig } from '../../config'
70
-
71
- const TAG = 'PiActionSheet'
72
- const { actionSheet } = getConfig()
73
-
74
- const alignFlexMap = {
75
- left: 'flex-start',
76
- center: 'center',
77
- right: 'flex-end'
78
- }
79
-
80
- export default {
81
- name: 'PiActionSheet',
82
- // 混入v-model
83
- mixins: [ValueSync],
84
- props: {
85
- // 初始值
86
- value: {
87
- required: false
88
- },
89
- // 自定义样式
90
- customStyle: {
91
- type: Object,
92
- // {}
93
- default() {
94
- return actionSheet.customStyle
95
- }
96
- },
97
- // 自定义样式类
98
- customClass: {
99
- type: String,
100
- // ''
101
- default() {
102
- return actionSheet.customClass
103
- }
104
- },
105
- // 选项列表
106
- items: {
107
- type: Array,
108
- // []
109
- default() {
110
- return actionSheet.items
111
- }
112
- },
113
- // 选项id字段
114
- keyField: {
115
- type: String,
116
- // 'id'
117
- default: actionSheet.keyField
118
- },
119
- // 选项显示字段
120
- displayField: {
121
- type: String,
122
- // 'text'
123
- default: actionSheet.displayField
124
- },
125
- // 自定义多列联动模式的children属性名
126
- childField: {
127
- type: String,
128
- // 'children'
129
- default: actionSheet.childField
130
- },
131
- // 行高 单位默认rpx
132
- itemHeight: {
133
- type: [String, Number],
134
- // 110
135
- default: actionSheet.itemHeight
136
- },
137
- // 是否显示item下边框
138
- showItemBottomBorder: {
139
- type: Boolean,
140
- // true
141
- default: actionSheet.showItemBottomBorder
142
- },
143
- // 行样式
144
- itemStyle: {
145
- type: Object,
146
- // {}
147
- default() {
148
- return actionSheet.itemStyle
149
- }
150
- },
151
- itemAlign: {
152
- type: String,
153
- // 'center'
154
- default: actionSheet.itemAlign,
155
- validator: function(value) {
156
- return ['left', 'center', 'right'].includes(value)
157
- }
158
- },
159
- // 弹窗选择参数设置
160
- popupSelect: {
161
- type: Object,
162
- default() {
163
- // 参照popup
164
- return actionSheet.popupSelect
165
- }
166
- },
167
- // 弹窗参数设置
168
- popup: {
169
- type: Object,
170
- default() {
171
- // 参照popup
172
- return actionSheet.popup
173
- }
174
- },
175
- // 选项上方的描述信息,不填则不显示
176
- description: {
177
- type: String,
178
- // ''
179
- default: actionSheet.description
180
- },
181
- // 取消按钮文字,不填则不显示
182
- cancelText: {
183
- type: String,
184
- // ''
185
- default: actionSheet.cancelText
186
- }
187
- },
188
- data() {
189
- return {}
190
- },
191
- computed: {
192
- getPopupSelect() {
193
- return this.$pi.lang.mergeDeep(actionSheet.popupSelect, this.popupSelect)
194
- },
195
- getPopup() {
196
- const actionSheetPopup = this.$pi.lang.mergeDeep(actionSheet.popup, this.popupSelect.popup)
197
- return this.$pi.lang.mergeDeep(actionSheetPopup, this.popup)
198
- },
199
- getItemAlignStyle() {
200
- return {
201
- justifyContent: alignFlexMap[this.itemAlign]
202
- }
203
- },
204
- getItemStyle() {
205
- const itemHeight = this.$pi.common.addUnit(this.itemHeight)
206
- return {
207
- height: itemHeight,
208
- lineHeight: itemHeight
209
- }
210
- },
211
- indicatorStyle() {
212
- const itemHeight = uni.upx2px(this.itemHeight)
213
- return `height: ${itemHeight}px;line-height: ${itemHeight}px;`
214
- }
215
- },
216
- methods: {
217
- handlePopupClose() {
218
- this.val = false
219
- // 弹窗关闭
220
- this.$emit('close')
221
- this.handleEmitChange()
222
- },
223
- /**
224
- * @vuese
225
- * 取消选择
226
- */
227
- handleCancel() {
228
- this.$emit('cancel')
229
- this.getPopupSelect.onConfirmClose && this.handlePopupClose()
230
- },
231
- /**
232
- * @vuese
233
- * 确认选择
234
- */
235
- handleSelectItem(item) {
236
- if (item.disabled) return
237
- this.$emit('select', item)
238
- this.getPopupSelect.onConfirmClose && this.handlePopupClose()
239
- }
240
- }
241
- }
242
- </script>
243
-
244
- <style lang="scss" scoped>
245
- .pi-action-sheet {
246
- }
247
- </style>
1
+ <template>
2
+ <pi-popup-select
3
+ :value="val"
4
+ :custom-style="getPopupSelect.customStyle"
5
+ :custom-class="getPopupSelect.customClass"
6
+ :height="getPopupSelect.height"
7
+ :show-title="getPopupSelect.showTitle"
8
+ :title="getPopupSelect.title"
9
+ :title-padding="getPopupSelect.titlePadding"
10
+ :toolbar-position="getPopupSelect.toolbarPosition"
11
+ :on-confirm-close="getPopupSelect.onConfirmClose"
12
+ :on-cancel-close="getPopupSelect.onCancelClose"
13
+ :confirm-btn="getPopupSelect.confirmBtn"
14
+ :cancel-btn="getPopupSelect.cancelBtn"
15
+ :popup="getPopup"
16
+ @show="$emit('show')"
17
+ @showed="$emit('showed')"
18
+ @close="handlePopupClose"
19
+ @cancel="handleCancel"
20
+ @confirm="handleConfirm"
21
+ >
22
+ <slot name="header" />
23
+ <!-- 描述列 -->
24
+ <view
25
+ v-if="description"
26
+ class="pi-solid-bottom-2 pi-align-center pi-pd-32 pi-light-gray"
27
+ :style="[getItemAlignStyle]"
28
+ >
29
+ {{ description }}
30
+ </view>
31
+ <view
32
+ v-for="item in items"
33
+ :id="`id-${item[keyField]}`"
34
+ :key="item[keyField]"
35
+ :style="[
36
+ itemStyle,
37
+ getItemStyle,
38
+ getItemAlignStyle,
39
+ { color: item.color }
40
+ ]"
41
+ :class="{
42
+ 'pi-solid-bottom-1': showItemBottomBorder,
43
+ 'pi-disabled': item.disabled
44
+ }"
45
+ class="pi-align-center pi-fz-32 pi-pd-lr-32"
46
+ hover-class="pi-hover-class"
47
+ @tap.stop="handleSelectItem(item)"
48
+ >
49
+ <!-- 自定义列表项 -->
50
+ <slot name="item" :item="item" class="pi-w-100P">
51
+ <template v-if="!item.loading">
52
+ {{ item[displayField] }}
53
+ </template>
54
+ <pi-loading v-else show />
55
+ </slot>
56
+ </view>
57
+ <!-- 取消action -->
58
+ <template v-if="cancelText">
59
+ <pi-gap height="20" />
60
+ <view
61
+ class="pi-align-center pi-fz-32 pi-pd-32 pi-light-gray"
62
+ hover-class="pi-hover-class"
63
+ :style="[getItemAlignStyle]"
64
+ @tap="handleCancel"
65
+ >
66
+ {{ cancelText }}
67
+ </view>
68
+ </template>
69
+
70
+ <slot name="footer" />
71
+ </pi-popup-select>
72
+ </template>
73
+
74
+ <script>
75
+ import ValueSync from '../../mixin/value-sync'
76
+ import { getConfig } from '../../config'
77
+
78
+ const TAG = 'PiActionSheet'
79
+ const { actionSheet } = getConfig()
80
+
81
+ const alignFlexMap = {
82
+ left: 'flex-start',
83
+ center: 'center',
84
+ right: 'flex-end'
85
+ }
86
+
87
+ export default {
88
+ name: 'PiActionSheet',
89
+ // 混入v-model
90
+ mixins: [ValueSync],
91
+ props: {
92
+ // 初始值
93
+ value: {
94
+ required: false
95
+ },
96
+ // 自定义样式
97
+ customStyle: {
98
+ type: Object,
99
+ // {}
100
+ default() {
101
+ return actionSheet.customStyle
102
+ }
103
+ },
104
+ // 自定义样式类
105
+ customClass: {
106
+ type: String,
107
+ // ''
108
+ default() {
109
+ return actionSheet.customClass
110
+ }
111
+ },
112
+ // 选项列表
113
+ items: {
114
+ type: Array,
115
+ // []
116
+ default() {
117
+ return actionSheet.items
118
+ }
119
+ },
120
+ // 选项id字段
121
+ keyField: {
122
+ type: String,
123
+ // 'id'
124
+ default: actionSheet.keyField
125
+ },
126
+ // 选项显示字段
127
+ displayField: {
128
+ type: String,
129
+ // 'text'
130
+ default: actionSheet.displayField
131
+ },
132
+ // 自定义多列联动模式的children属性名
133
+ childField: {
134
+ type: String,
135
+ // 'children'
136
+ default: actionSheet.childField
137
+ },
138
+ // 行高 单位默认rpx
139
+ itemHeight: {
140
+ type: [String, Number],
141
+ // 110
142
+ default: actionSheet.itemHeight
143
+ },
144
+ // 是否显示item下边框
145
+ showItemBottomBorder: {
146
+ type: Boolean,
147
+ // true
148
+ default: actionSheet.showItemBottomBorder
149
+ },
150
+ // 行样式
151
+ itemStyle: {
152
+ type: Object,
153
+ // {}
154
+ default() {
155
+ return actionSheet.itemStyle
156
+ }
157
+ },
158
+ itemAlign: {
159
+ type: String,
160
+ // 'center'
161
+ default: actionSheet.itemAlign,
162
+ validator: function(value) {
163
+ return ['left', 'center', 'right'].includes(value)
164
+ }
165
+ },
166
+ // 弹窗选择参数设置
167
+ popupSelect: {
168
+ type: Object,
169
+ default() {
170
+ // 参照popup
171
+ return actionSheet.popupSelect
172
+ }
173
+ },
174
+ // 弹窗参数设置
175
+ popup: {
176
+ type: Object,
177
+ default() {
178
+ // 参照popup
179
+ return actionSheet.popup
180
+ }
181
+ },
182
+ // 选项上方的描述信息,不填则不显示
183
+ description: {
184
+ type: String,
185
+ // ''
186
+ default: actionSheet.description
187
+ },
188
+ // 取消按钮文字,不填则不显示
189
+ cancelText: {
190
+ type: String,
191
+ // ''
192
+ default: actionSheet.cancelText
193
+ }
194
+ },
195
+ data() {
196
+ return {}
197
+ },
198
+ computed: {
199
+ getPopupSelect() {
200
+ return this.$pi.lang.mergeDeep(actionSheet.popupSelect, this.popupSelect)
201
+ },
202
+ getPopup() {
203
+ const actionSheetPopup = this.$pi.lang.mergeDeep(
204
+ actionSheet.popup,
205
+ this.popupSelect.popup
206
+ )
207
+ return this.$pi.lang.mergeDeep(actionSheetPopup, this.popup)
208
+ },
209
+ getItemAlignStyle() {
210
+ return {
211
+ justifyContent: alignFlexMap[this.itemAlign]
212
+ }
213
+ },
214
+ getItemStyle() {
215
+ const itemHeight = this.$pi.common.addUnit(this.itemHeight)
216
+ return {
217
+ height: itemHeight,
218
+ lineHeight: itemHeight
219
+ }
220
+ },
221
+ indicatorStyle() {
222
+ const itemHeight = uni.upx2px(this.itemHeight)
223
+ return `height: ${itemHeight}px;line-height: ${itemHeight}px;`
224
+ }
225
+ },
226
+ methods: {
227
+ handlePopupClose() {
228
+ this.val = false
229
+ // 弹窗关闭
230
+ this.$emit('close')
231
+ this.handleEmitChange()
232
+ },
233
+ /**
234
+ * @vuese
235
+ * 取消选择
236
+ */
237
+ handleCancel() {
238
+ this.$emit('cancel')
239
+ this.getPopupSelect.onCancelClose && this.handlePopupClose()
240
+ },
241
+ /**
242
+ * @vuese
243
+ * 确认选择
244
+ */
245
+ handleConfirm() {
246
+ this.$emit('confirm')
247
+ this.getPopupSelect.onConfirmClose && this.handlePopupClose()
248
+ },
249
+ /**
250
+ * @vuese
251
+ * 确认选择
252
+ */
253
+ handleSelectItem(item) {
254
+ if (item.disabled) return
255
+ this.$emit('select', item)
256
+ this.getPopupSelect.onConfirmClose && this.handlePopupClose()
257
+ }
258
+ }
259
+ }
260
+ </script>
261
+
262
+ <style lang="scss" scoped></style>
@@ -1,8 +1,20 @@
1
1
  <template>
2
- <view class="badge-wrap" :style="[customStyle]" :class="[customClass]" @tap="handleClick">
2
+ <view
3
+ class="badge-wrap"
4
+ :style="[customStyle]"
5
+ :class="[customClass]"
6
+ @tap="handleClick"
7
+ >
3
8
  <view
4
9
  class="badge"
5
- :class="[{ dot, abso: $slots.default || $slots.$default }]"
10
+ :class="[
11
+ {
12
+ dot,
13
+ 'abso': $slots.default || $slots.$default,
14
+ 'hide-border':
15
+ !dot && !getContent && !($slots.content || $slots.$content)
16
+ }
17
+ ]"
6
18
  :style="[badgeStyle]"
7
19
  >
8
20
  <slot name="content">
@@ -16,7 +28,6 @@
16
28
  <script>
17
29
  import { getConfig } from '../../config'
18
30
 
19
- const TAG = 'PiBadge'
20
31
  const { badge } = getConfig()
21
32
 
22
33
  export default {
@@ -67,12 +78,32 @@ export default {
67
78
  type: [String, Number],
68
79
  // ''
69
80
  default: badge.max
81
+ },
82
+ // 徽标尺寸,可以是数字(如 12、14、16)或字符串(small、medium、large)
83
+ size: {
84
+ type: [String, Number],
85
+ // 16
86
+ default: badge.size
70
87
  }
71
88
  },
72
89
  data() {
73
90
  return {}
74
91
  },
75
92
  computed: {
93
+ // 尺寸配置
94
+ sizeConfig() {
95
+ // 将 size 转换为数字
96
+ const size = Math.max(10, Number(this.size) || 16)
97
+ const padding = Math.max(2, Math.floor(size / 5))
98
+ const fontSize = Math.max(10, Math.floor(size * 0.75))
99
+
100
+ return {
101
+ minSize: `${size}px`,
102
+ padding: `0 ${padding}px`,
103
+ fontSize: `${fontSize}px`,
104
+ borderRadius: `${size}px`
105
+ }
106
+ },
76
107
  getDotRadius() {
77
108
  return this.$pi.common.addUnit(this.dotRadius)
78
109
  },
@@ -83,13 +114,40 @@ export default {
83
114
  if (this.dot) {
84
115
  style.width = this.getDotRadius
85
116
  style.height = this.getDotRadius
117
+ } else {
118
+ // 应用尺寸配置
119
+ const content = this.getContent
120
+ const contentStr = String(content)
121
+ const contentLength = contentStr.length
122
+
123
+ // 一个字符时使用正方形(圆形),多个字符时使用椭圆形
124
+ if (contentLength === 1 && contentStr.trim()) {
125
+ style.width = this.sizeConfig.minSize
126
+ style.height = this.sizeConfig.minSize
127
+ style.padding = '0'
128
+ style.lineHeight = this.sizeConfig.minSize
129
+ } else if (contentLength > 1) {
130
+ style.minWidth = this.sizeConfig.minSize
131
+ style.padding = this.sizeConfig.padding
132
+ }
133
+
134
+ style.fontSize = this.sizeConfig.fontSize
135
+ style.borderRadius = this.sizeConfig.borderRadius
86
136
  }
87
137
  return style
88
138
  },
89
139
  getContent() {
90
140
  const max = parseInt(this.max, 10)
91
141
  const content = parseInt(this.content, 10)
92
- if (this.$pi.lang.isNumber(content) && max < content) return `${max}+`
142
+
143
+ // 更严格的数字判断
144
+ if (
145
+ this.$pi.lang.isNumber(content) &&
146
+ this.$pi.lang.isNumber(max) &&
147
+ content > max
148
+ ) {
149
+ return `${max}+`
150
+ }
93
151
  return this.content
94
152
  }
95
153
  },
@@ -108,16 +166,16 @@ export default {
108
166
 
109
167
  .badge {
110
168
  box-sizing: border-box;
111
- min-width: 16px;
112
- padding: 0 3px;
113
- font-size: 12px;
114
169
  font-weight: 500;
115
170
  line-height: 1.2;
116
171
  color: #ffffff;
117
172
  text-align: center;
118
173
  background-color: #ee0a24;
119
174
  border: 1px solid #ffffff;
120
- border-radius: 16px;
175
+
176
+ &.hide-border {
177
+ border: none;
178
+ }
121
179
 
122
180
  &.dot {
123
181
  min-width: 0;