From 1333bdac4f8f605c3c9851d0f43d267205ce5aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=A6=82=E6=91=B8=E9=B1=BC=E5=8E=BB?= <1780903673@qq.com> Date: Thu, 18 Sep 2025 15:50:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Rate=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E8=AF=84=E5=88=86(#1302)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #1293 --- docs/component/rate.md | 9 + docs/en-US/component/rate.md | 9 + src/locale/en-US.json | 1 + src/locale/zh-CN.json | 1 + src/subPages/rate/Index.vue | 11 + .../components/wd-rate/types.ts | 9 +- .../components/wd-rate/wd-rate.vue | 33 ++- tests/components/wd-rate.test.ts | 212 +++++++++++++++++- 8 files changed, 273 insertions(+), 12 deletions(-) diff --git a/docs/component/rate.md b/docs/component/rate.md index a33d65ed..22d15e59 100644 --- a/docs/component/rate.md +++ b/docs/component/rate.md @@ -67,6 +67,14 @@ function changeValue({ value }) { ``` +## 允许清空评分 + +设置 `clearable` 属性,当 clearable 属性设置为 true,再次点击相同的值时,可以将值重置为 0。 + +```html + +``` + ## Attributes | 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 | @@ -83,6 +91,7 @@ function changeValue({ value }) { | disabled | 是否禁用 | boolean | - | false | - | | disabled-color | 禁用的图标颜色 | string | - | linear-gradient(315deg, rgba(177,177,177,1) 0%,rgba(199,199,199,1) 100%) | - | | allow-half | 是否允许半选 | boolean | - | false | 1.7.0 | +| clearable | 是否允许再次点击后清除 | boolean | - | false | $LOWEST_VERSION$ | ## Events diff --git a/docs/en-US/component/rate.md b/docs/en-US/component/rate.md index 682e2ce2..3be75b36 100644 --- a/docs/en-US/component/rate.md +++ b/docs/en-US/component/rate.md @@ -67,6 +67,14 @@ Set the `allowHalf` property. ``` +## Allow Clear Rating + +Set the `clearable` property. When clearable is set to true, clicking the same value again can reset the value to 0. + +```html + +``` + ## Attributes | Parameter | Description | Type | Options | Default | Version | @@ -83,6 +91,7 @@ Set the `allowHalf` property. | disabled | Whether it's disabled | boolean | - | false | - | | disabled-color | Disabled icon color | string | - | linear-gradient(315deg, rgba(177,177,177,1) 0%,rgba(199,199,199,1) 100%) | - | | allow-half | Whether to allow half selection | boolean | - | false | 1.7.0 | +| clearable | Whether to allow clear rating | boolean | - | false | $LOWEST_VERSION$ | ## Events diff --git a/src/locale/en-US.json b/src/locale/en-US.json index a6a5e41a..26382232 100644 --- a/src/locale/en-US.json +++ b/src/locale/en-US.json @@ -1451,6 +1451,7 @@ "yue-xiu-qu": "Yuexiu", "yue-xuan-ze": "Monthly selection", "yun-xu-ban-xuan": "Allow half selection", + "yun-xu-qing-kong-ping-fen": "Allow clear rating", "yun-xu-kong-zhi-bing-she-zhi-placeholder": "Allow null values and set placeholder", "yy-nian-mm-yue-dd-ri": "YY year MM month DD day", "yy-nian-mm-yue-dd-ri-0": "YY year MM month DD day", diff --git a/src/locale/zh-CN.json b/src/locale/zh-CN.json index 0e8bfbd6..9f915b63 100644 --- a/src/locale/zh-CN.json +++ b/src/locale/zh-CN.json @@ -1451,6 +1451,7 @@ "yue-xiu-qu": "越秀区", "yue-xuan-ze": "月选择", "yun-xu-ban-xuan": "允许半选", + "yun-xu-qing-kong-ping-fen": "允许清空评分", "yun-xu-kong-zhi-bing-she-zhi-placeholder": "允许空值,并设置 placeholder", "yy-nian-mm-yue-dd-ri": "YY年MM月DD日", "yy-nian-mm-yue-dd-ri-0": "YY年MM月DD日", diff --git a/src/subPages/rate/Index.vue b/src/subPages/rate/Index.vue index f4b676b9..aa54121e 100644 --- a/src/subPages/rate/Index.vue +++ b/src/subPages/rate/Index.vue @@ -36,6 +36,15 @@ + + + + + + + + +