diff --git a/src/App.vue b/src/App.vue
index 1346afb427027c834254ac350879270728a8646d..b6d28b15693436c1c98fdfc986bfd22b1c960461 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,52 +1,75 @@
@@ -85,14 +108,20 @@ function minus() {
border: 1px solid #eee;
}
-.button:hover {
+.button:hover:not(.disabled) {
background: #f5f5f5;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
-.button:active {
+.button:active:not(.disabled) {
transform: translateY(0);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
+
+.button.disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ background: #f5f5f5;
+}
diff --git a/src/components/ProgressBar.vue b/src/components/ProgressBar.vue
index a8a7eedc505a00596c4a9ad40f2fac87b7bdcb59..f866ad4ede6019062dd1189e8dc9d99a16d3ba3c 100644
--- a/src/components/ProgressBar.vue
+++ b/src/components/ProgressBar.vue
@@ -31,6 +31,8 @@
* width?: number; // 画布宽度,默认自适应
* height?: number; // 画布高度,默认自适应
* background?: string; // 画布背景色,默认 #fff
+ * lineCap?: CanvasLineCap; // 线条末端样式:'butt' | 'round' | 'square',默认 'round'
+ * fillStyle?: string; // 圆环中心填充样式,默认 'transparent'
* text?: {
* size?: number | null; // 字体大小,null 时自动计算
* color?: string; // 字体颜色,默认 #333
@@ -70,6 +72,10 @@ interface ChartOptions {
height?: number;
// 画布背景色,默认 #fff
background?: string;
+ // 线条末端样式:'butt' | 'round' | 'square',默认 'round'
+ lineCap?: CanvasLineCap;
+ // 圆环中心填充样式,默认 'transparent'
+ fillStyle?: string;
// 文字相关配置
text?: {
// 字体大小,默认自适应(为 null 时自动计算)
@@ -101,12 +107,14 @@ const props = withDefaults(defineProps<{
width: 500,
height: 500,
background: '#fff',
+ lineCap: 'round',
+ fillStyle: 'transparent',
text: {
size: null,
color: '#333',
font: 'Arial',
showPercentage: true,
- show: true // 默认显示文本
+ show: true
}
})
})
@@ -246,21 +254,17 @@ function startDraw(end: number, start?: number, dontClear?: boolean) {
// 绘制外圆
ctx.beginPath();
- // 设置线条宽度
- ctx.lineWidth = lineWidth || 10; // 设置默认值避免 undefined
- // 设置线条末端样式为圆角
- ctx.lineCap = 'round';
+ ctx.lineWidth = lineWidth || 10;
+ ctx.lineCap = props.options.lineCap || 'round';
ctx.strokeStyle = strokeStyle;
- ctx.arc(centerX, centerY, radius, start || Math.PI * 1.5, end || Math.PI * 2); // 设置默认值避免 undefined
- // 使用 stroke 代替 fill
+ ctx.arc(centerX, centerY, radius, start || Math.PI * 1.5, end || Math.PI * 2);
ctx.stroke();
ctx.closePath();
- // 绘制内圆(可选,如果不需要内圆可以移除这部分)
+ // 绘制内圆
ctx.beginPath();
ctx.arc(centerX, centerY, (radius) - (lineWidth || 10), 0, Math.PI * 2);
- // 使用透明填充
- ctx.fillStyle = 'transparent';
+ ctx.fillStyle = props.options.fillStyle || 'transparent';
ctx.fill();
ctx.closePath();