sadais-piui 1.2.7-beta173 → 1.2.7-beta175
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.
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
<script>
|
|
29
29
|
import { getConfig } from '../../config'
|
|
30
30
|
|
|
31
|
-
const TAG = 'PiBadge'
|
|
32
31
|
const { badge } = getConfig()
|
|
33
32
|
|
|
34
33
|
export default {
|
|
@@ -79,12 +78,32 @@ export default {
|
|
|
79
78
|
type: [String, Number],
|
|
80
79
|
// ''
|
|
81
80
|
default: badge.max
|
|
81
|
+
},
|
|
82
|
+
// 徽标尺寸,可以是数字(如 12、14、16)或字符串(small、medium、large)
|
|
83
|
+
size: {
|
|
84
|
+
type: [String, Number],
|
|
85
|
+
// 16
|
|
86
|
+
default: badge.size
|
|
82
87
|
}
|
|
83
88
|
},
|
|
84
89
|
data() {
|
|
85
90
|
return {}
|
|
86
91
|
},
|
|
87
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
|
+
},
|
|
88
107
|
getDotRadius() {
|
|
89
108
|
return this.$pi.common.addUnit(this.dotRadius)
|
|
90
109
|
},
|
|
@@ -95,13 +114,40 @@ export default {
|
|
|
95
114
|
if (this.dot) {
|
|
96
115
|
style.width = this.getDotRadius
|
|
97
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
|
|
98
136
|
}
|
|
99
137
|
return style
|
|
100
138
|
},
|
|
101
139
|
getContent() {
|
|
102
140
|
const max = parseInt(this.max, 10)
|
|
103
141
|
const content = parseInt(this.content, 10)
|
|
104
|
-
|
|
142
|
+
|
|
143
|
+
// 更严格的数字判断
|
|
144
|
+
if (
|
|
145
|
+
this.$pi.lang.isNumber(content) &&
|
|
146
|
+
this.$pi.lang.isNumber(max) &&
|
|
147
|
+
content > max
|
|
148
|
+
) {
|
|
149
|
+
return `${max}+`
|
|
150
|
+
}
|
|
105
151
|
return this.content
|
|
106
152
|
}
|
|
107
153
|
},
|
|
@@ -120,16 +166,12 @@ export default {
|
|
|
120
166
|
|
|
121
167
|
.badge {
|
|
122
168
|
box-sizing: border-box;
|
|
123
|
-
min-width: 16px;
|
|
124
|
-
padding: 0 3px;
|
|
125
|
-
font-size: 12px;
|
|
126
169
|
font-weight: 500;
|
|
127
170
|
line-height: 1.2;
|
|
128
171
|
color: #ffffff;
|
|
129
172
|
text-align: center;
|
|
130
173
|
background-color: #ee0a24;
|
|
131
174
|
border: 1px solid #ffffff;
|
|
132
|
-
border-radius: 16px;
|
|
133
175
|
|
|
134
176
|
&.hide-border {
|
|
135
177
|
border: none;
|
|
@@ -73,6 +73,8 @@
|
|
|
73
73
|
:popup-select="getDatePicker.popupSelect"
|
|
74
74
|
:confirm-btn="getDatePicker.confirmBtn"
|
|
75
75
|
:cancel-btn="getDatePicker.cancelBtn"
|
|
76
|
+
:min-date="getDatePicker.minDate"
|
|
77
|
+
:max-date="getDatePicker.maxDate"
|
|
76
78
|
@confirm="handleDatePickerConfirm"
|
|
77
79
|
@close="$emit('close', $event)"
|
|
78
80
|
@closed="$emit('closed', $event)"
|
package/config/badge.js
CHANGED