From 8e3f3890e93d097df4be744648b9ac404d20a558 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 23 四月 2026 17:58:50 +0800
Subject: [PATCH] 2026.4.23

---
 miniprogram_npm/tdesign-miniprogram/rate/rate.js |  116 ---------------------------------------------------------
 1 files changed, 1 insertions(+), 115 deletions(-)

diff --git a/miniprogram_npm/tdesign-miniprogram/rate/rate.js b/miniprogram_npm/tdesign-miniprogram/rate/rate.js
index 3528916..74e88f2 100644
--- a/miniprogram_npm/tdesign-miniprogram/rate/rate.js
+++ b/miniprogram_npm/tdesign-miniprogram/rate/rate.js
@@ -1,115 +1 @@
-var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
-    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
-    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
-    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
-    return c > 3 && r && Object.defineProperty(target, key, r), r;
-};
-import { SuperComponent, wxComponent } from '../common/src/index';
-import config from '../common/config';
-import props from './props';
-import { unitConvert, getRect } from '../common/utils';
-const { prefix } = config;
-const name = `${prefix}-rate`;
-let Rate = class Rate extends SuperComponent {
-    constructor() {
-        super(...arguments);
-        this.externalClasses = [`${prefix}-class`, `${prefix}-class-icon`, `${prefix}-class-text`];
-        this.properties = props;
-        this.controlledProps = [
-            {
-                key: 'value',
-                event: 'change',
-            },
-        ];
-        this.data = {
-            prefix,
-            classPrefix: name,
-            defaultTexts: ['鏋佸樊', '澶辨湜', '涓�鑸�', '婊℃剰', '鎯婂枩'],
-            tipsVisible: false,
-            tipsLeft: 0,
-            actionType: '',
-            scaleIndex: -1,
-            isVisibleToScreenReader: false,
-        };
-        this.methods = {
-            onTouch(e, eventType) {
-                const { count, allowHalf, gap, value: currentValue, size } = this.properties;
-                const [touch] = e.touches;
-                const margin = unitConvert(gap);
-                getRect(this, `.${name}__wrapper`).then((rect) => {
-                    const { width, left } = rect;
-                    const starWidth = (width - (count - 1) * margin) / count;
-                    const offsetX = touch.pageX - left;
-                    const num = (offsetX + margin) / (starWidth + margin);
-                    const remainder = num % 1;
-                    const integral = num - remainder;
-                    let value = remainder <= 0.5 && allowHalf ? integral + 0.5 : integral + 1;
-                    if (value > count) {
-                        value = count;
-                    }
-                    else if (value < 0) {
-                        value = 0;
-                    }
-                    if (eventType === 'move' || (eventType === 'tap' && allowHalf)) {
-                        const left = Math.ceil(value - 1) * (unitConvert(gap) + unitConvert(size)) + unitConvert(size) * 0.5;
-                        this.setData({
-                            tipsVisible: true,
-                            actionType: eventType,
-                            scaleIndex: Math.ceil(value),
-                            tipsLeft: Math.max(left, 0),
-                        });
-                    }
-                    if (value !== currentValue) {
-                        this._trigger('change', { value });
-                    }
-                    if (this.touchEnd) {
-                        this.hideTips();
-                    }
-                });
-            },
-            onTap(e) {
-                this.onTouch(e, 'tap');
-            },
-            onTouchStart() {
-                this.touchEnd = false;
-            },
-            onTouchMove(e) {
-                this.onTouch(e, 'move');
-                this.showAlertText();
-            },
-            onTouchEnd() {
-                this.touchEnd = true;
-                this.hideTips();
-            },
-            hideTips() {
-                if (this.data.actionType === 'move') {
-                    this.setData({ tipsVisible: false, scaleIndex: -1 });
-                }
-            },
-            onSelect(e) {
-                const { value } = e.currentTarget.dataset;
-                const { actionType } = this.data;
-                if (actionType === 'move')
-                    return;
-                this._trigger('change', { value });
-                setTimeout(() => this.setData({ tipsVisible: false, scaleIndex: -1 }), 300);
-            },
-            showAlertText() {
-                if (this.data.isVisibleToScreenReader === true)
-                    return;
-                this.setData({
-                    isVisibleToScreenReader: true,
-                });
-                setTimeout(() => {
-                    this.setData({
-                        isVisibleToScreenReader: false,
-                    });
-                }, 2e3);
-            },
-        };
-    }
-};
-Rate = __decorate([
-    wxComponent()
-], Rate);
-export default Rate;
+import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";import{unitConvert,getRect}from"../common/utils";import usingConfig from"../mixins/using-config";const{prefix:prefix}=config,componentName="rate";let Rate=class extends SuperComponent{constructor(){super(...arguments),this.behaviors=[usingConfig({componentName:"rate"})],this.externalClasses=[`${prefix}-class`,`${prefix}-class-icon`,`${prefix}-class-text`],this.properties=props,this.controlledProps=[{key:"value",event:"change"}],this.data={prefix:prefix,classPrefix:`${prefix}-rate`,tipsVisible:!1,tipsLeft:0,actionType:"",scaleIndex:-1,isVisibleToScreenReader:!1},this.methods={onTouch(e,t){const{classPrefix:i}=this.data,{count:s,allowHalf:o,gap:n,value:a,size:r}=this.properties,[c]=e.changedTouches,p=unitConvert(n);getRect(this,`.${i}__wrapper`).then(e=>{const{width:i,left:h}=e,l=(i-(s-1)*p)/s,m=(c.pageX-h+p)/(l+p),u=m%1,d=m-u;let f=u<=.5&&o?d+.5:d+1;f>s?f=s:f<0&&(f=0);const x=Math.ceil(f-1)*(unitConvert(n)+unitConvert(r))+.5*unitConvert(r);this.setData({tipsVisible:!0,actionType:t,scaleIndex:Math.ceil(f),tipsLeft:Math.max(x,0)}),f!==a&&this._trigger("change",{value:f}),this.touchEnd&&this.hideTips()})},onTap(e){const{disabled:t}=this.properties;t||this.onTouch(e,"tap")},onTouchStart(){this.touchEnd=!1},onTouchMove(e){this.onTouch(e,"move"),this.showAlertText()},onTouchEnd(){this.touchEnd=!0,this.hideTips()},hideTips(){"move"===this.data.actionType&&this.setData({tipsVisible:!1,scaleIndex:-1})},onSelect(e){const{value:t}=e.currentTarget.dataset,{actionType:i}=this.data;"move"!==i&&(this._trigger("change",{value:t}),setTimeout(()=>this.setData({tipsVisible:!1,scaleIndex:-1}),300))},showAlertText(){!0!==this.data.isVisibleToScreenReader&&(this.setData({isVisibleToScreenReader:!0}),setTimeout(()=>{this.setData({isVisibleToScreenReader:!1})},2e3))}}}};Rate=__decorate([wxComponent()],Rate);export default Rate;
\ No newline at end of file

--
Gitblit v1.9.3