New Huajishe Check ChaoXing

This commit is contained in:
e2hang
2025-10-01 10:01:52 +08:00
parent 240b884eac
commit 80be8ae3cf
1094 changed files with 61709 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
:: BASE_DOC ::
## API
### Loading Props
name | type | default | description | required
-- | -- | -- | -- | --
style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets)used to set style on virtual component | N
delay | Number | 0 | \- | N
duration | Number | 800 | \- | N
fullscreen | Boolean | false | `1.8.5` | N
indicator | Boolean / Slot | true | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
inherit-color | Boolean | false | \- | N
layout | String | horizontal | options: horizontal/vertical | N
loading | Boolean | true | \- | N
pause | Boolean | false | \- | N
progress | Number | - | \- | N
reverse | Boolean | - | \- | N
size | String | '20px' | \- | N
text | String / Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
theme | String | circular | options: circular/spinner/dots | N
### Loading External Classes
className | Description
-- | --
t-class | \-
t-class-indicator | \-
t-class-text | \-
### CSS Variables
The component provides the following CSS variables, which can be used to customize styles.
Name | Default Value | Description
-- | -- | --
--td-loading-color | @brand-color | -
--td-loading-text-color | inherit | -
--td-loading-text-font-size | 24rpx | -
--td-loading-text-line-height | 40rpx | -

View File

@@ -0,0 +1,97 @@
---
title: Loading 加载
description: 用于表示页面或操作的加载状态,给予用户反馈的同时减缓等待的焦虑感,由一个或一组反馈动效组成。
spline: message
isComponent: true
---
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-95%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-95%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-83%25-blue" /></span>
## 引入
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
```json
"usingComponents": {
"t-loading": "tdesign-miniprogram/loading/loading"
}
```
## 代码演示
<a href="https://developers.weixin.qq.com/s/Jraocimc7mSr" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后依次执行npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
</blockquote>
### 纯icon
{{ base }}
### icon加文字横向
{{ horizontal }}
### icon加文字竖向
{{ vertical }}
### 纯文字
{{ text }}
### 加载失败
{{ error }}
### 状态
{{ status }}
### 加载速度
{{ duration }}
### 规格
{{ size }}
## API
### Loading Props
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
delay | Number | 0 | 延迟显示加载效果的时间,用于防止请求速度过快引起的加载闪烁,单位:毫秒 | N
duration | Number | 800 | 加载动画执行完成一次的时间,单位:毫秒 | N
fullscreen | Boolean | false | `1.8.5`。是否显示为全屏加载 | N
indicator | Boolean / Slot | true | 加载指示符,值为 true 显示默认指示符,值为 false 则不显示,也可以自定义指示符。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
inherit-color | Boolean | false | 是否继承父元素颜色 | N
layout | String | horizontal | 对齐方式。可选项horizontal/vertical | N
loading | Boolean | true | 是否处于加载状态 | N
pause | Boolean | false | 是否暂停动画 | N
progress | Number | - | 加载进度 | N
reverse | Boolean | - | 加载动画是否反向 | N
size | String | '20px' | 尺寸示例20px | N
text | String / Slot | - | 加载提示文案。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
theme | String | circular | 加载组件类型。可选项circular/spinner/dotsskyline 模式下暂不支持枚举值 circular | N
### Loading External Classes
类名 | 描述
-- | --
t-class | 根节点样式类
t-class-indicator | 指示符样式类
t-class-text | 文本样式类
### CSS Variables
组件提供了下列 CSS 变量,可用于自定义样式。
名称 | 默认值 | 描述
-- | -- | --
--td-loading-color | @brand-color | -
--td-loading-text-color | inherit | -
--td-loading-text-font-size | 24rpx | -
--td-loading-text-line-height | 40rpx | -

View File

@@ -0,0 +1,3 @@
export * from './props';
export * from './type';
export * from './loading';

View File

@@ -0,0 +1,3 @@
export * from './props';
export * from './type';
export * from './loading';

View File

@@ -0,0 +1,77 @@
import { SuperComponent } from '../common/src/index';
import type { TdLoadingProps } from './type';
export interface LoadingProps extends TdLoadingProps {
}
export default class Loading extends SuperComponent {
externalClasses: string[];
data: {
prefix: string;
classPrefix: string;
show: boolean;
};
options: {
multipleSlots: boolean;
};
properties: {
delay?: {
type: NumberConstructor;
value?: number;
};
duration?: {
type: NumberConstructor;
value?: number;
};
fullscreen?: {
type: BooleanConstructor;
value?: boolean;
};
indicator?: {
type: BooleanConstructor;
value?: boolean;
};
inheritColor?: {
type: BooleanConstructor;
value?: boolean;
};
layout?: {
type: StringConstructor;
value?: "horizontal" | "vertical";
};
loading?: {
type: BooleanConstructor;
value?: boolean;
};
pause?: {
type: BooleanConstructor;
value?: boolean;
};
progress?: {
type: NumberConstructor;
value?: number;
};
reverse?: {
type: BooleanConstructor;
value?: boolean;
};
size?: {
type: StringConstructor;
value?: string;
};
text?: {
type: StringConstructor;
value?: string;
};
theme?: {
type: StringConstructor;
value?: "circular" | "spinner" | "dots";
};
};
timer: any;
observers: {
loading(this: any, cur: any): void;
};
lifetimes: {
detached(): void;
};
refreshPage(): void;
}

View File

@@ -0,0 +1,61 @@
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';
const { prefix } = config;
const name = `${prefix}-loading`;
let Loading = class Loading extends SuperComponent {
constructor() {
super(...arguments);
this.externalClasses = [`${prefix}-class`, `${prefix}-class-text`, `${prefix}-class-indicator`];
this.data = {
prefix,
classPrefix: name,
show: true,
};
this.options = {
multipleSlots: true,
};
this.properties = Object.assign({}, props);
this.timer = null;
this.observers = {
loading(cur) {
const { delay } = this.properties;
if (this.timer) {
clearTimeout(this.timer);
}
if (cur) {
if (delay) {
this.timer = setTimeout(() => {
this.setData({ show: cur });
this.timer = null;
}, delay);
}
else {
this.setData({ show: cur });
}
}
else {
this.setData({ show: cur });
}
},
};
this.lifetimes = {
detached() {
clearTimeout(this.timer);
},
};
}
refreshPage() {
this.triggerEvent('reload');
}
};
Loading = __decorate([
wxComponent()
], Loading);
export default Loading;

View File

@@ -0,0 +1,5 @@
{
"component": true,
"styleIsolation": "apply-shared",
"usingComponents": {}
}

View File

@@ -0,0 +1,45 @@
<wxs src="../common/utils.wxs" module="_" />
<view
style="{{_._style([style, customStyle, show ? '' : 'display: none', inheritColor ? 'color: inherit' : ''])}}"
class="class {{prefix}}-class {{classPrefix}} {{classPrefix + '--' + layout}} {{fullscreen ? classPrefix + '--fullscreen' : ''}}"
>
<view
wx:if="{{indicator}}"
class="{{prefix}}-class-indicator {{classPrefix}}__spinner {{classPrefix}}__spinner--{{ theme }} {{reverse ? 'reverse' : ''}}"
style="width: {{ _.addUnit(size) }}; height: {{ _.addUnit(size) }}; {{inheritColor ? 'color: inherit;' : ''}} {{indicator ? '' : 'display: none;'}} {{duration ? 'animation-duration: ' + duration / 1000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
aria-role="{{ariaRole || 'img'}}"
aria-label="{{ ariaLabel || text || '加载中' }}"
>
<view
wx:if="{{ theme === 'spinner' }}"
wx:for="{{12}}"
wx:key="index"
class="{{classPrefix}}__dot {{classPrefix}}__dot-{{index}}"
/>
<view wx:if="{{ theme === 'circular' }}" class="{{classPrefix}}__circular" />
<block wx:if="{{ theme === 'dots' }}">
<view
class="{{classPrefix}}__dot"
style="{{duration ? 'animation-duration: ' + duration/1000 + 's; animation-delay:' + 0 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
></view>
<view
class="{{classPrefix}}__dot"
style="{{duration ? 'animation-duration: ' + duration/1000 + 's; animation-delay:' + duration * 1 / 3000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
></view>
<view
class="{{classPrefix}}__dot"
style="{{duration ? 'animation-duration: ' + duration/1000 + 's; animation-delay:' + duration * 2 / 3000 + 's;' : ''}} animation-play-state: {{pause ? 'paused' : 'running'}};"
></view>
</block>
<slot name="indicator" />
</view>
<view
class="{{_.cls(classPrefix + '__text', [layout])}} {{prefix}}-class-text"
aria-hidden="{{indicator}}"
aria-label="{{ ariaLabel || text }}"
>
<block wx:if="{{text}}">{{text}}</block>
<slot name="text" />
<slot />
</view>
</view>

View File

@@ -0,0 +1,232 @@
.t-float-left {
float: left;
}
.t-float-right {
float: right;
}
@keyframes tdesign-fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.hotspot-expanded.relative {
position: relative;
}
.hotspot-expanded::after {
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
transform: scale(1.5);
}
.t-loading {
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 24rpx;
}
.t-loading--fullscreen {
position: fixed;
display: flex;
align-items: center;
vertical-align: middle;
justify-content: center;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: var(--td-loading-z-index, 3500);
background-color: var(--td-loading-full-bg-color, rgba(255, 255, 255, 0.6));
}
.t-loading__spinner {
position: relative;
box-sizing: border-box;
width: 100%;
height: 100%;
max-width: 100%;
max-height: 100%;
animation: rotate 0.8s linear infinite;
color: var(--td-loading-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
}
.t-loading__spinner.reverse {
animation-name: rotateReverse;
}
.t-loading__spinner--spinner {
animation-timing-function: steps(12);
color: var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9)));
}
.t-loading__spinner--spinner .t-loading__dot {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.t-loading__spinner--spinner .t-loading__dot::before {
display: block;
width: 5rpx;
height: 25%;
margin: 0 auto;
background-color: var(--td-loading-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
border-radius: 40%;
content: ' ';
}
.t-loading__spinner--circular .t-loading__circular {
border-radius: 100%;
width: 100%;
height: 100%;
background: conic-gradient(from 180deg at 50% 50%, rgba(255, 255, 255, 0) 0deg, rgba(255, 255, 255, 0) 60deg, currentColor 330deg, rgba(255, 255, 255, 0) 360deg);
mask: radial-gradient(transparent calc(50% - 1rpx), #fff 50%);
/* stylelint-disable-next-line */
-webkit-mask: radial-gradient(transparent calc(50% - 1rpx), #fff 50%);
}
.t-loading__spinner--dots {
display: flex;
justify-content: space-between;
align-items: center;
animation: none;
}
.t-loading__spinner--dots .t-loading__dot {
width: 20%;
height: 20%;
border-radius: 50%;
background-color: var(--td-loading-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
animation-duration: 1.8s;
animation-name: dotting;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-fill-mode: both;
}
.t-loading__text {
color: var(--td-loading-text-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
font-size: var(--td-loading-text-font-size, 24rpx);
line-height: var(--td-loading-text-line-height, 40rpx);
}
.t-loading__text--vertical:not(:first-child):not(:empty) {
margin-top: 12rpx;
}
.t-loading__text--horizontal:not(:first-child):not(:empty) {
margin-left: 16rpx;
}
.t-loading--vertical {
flex-direction: column;
}
.t-loading--horizontal {
flex-direction: row;
vertical-align: top;
}
@keyframes t-bar {
0% {
width: 0;
}
50% {
width: 70%;
}
100% {
width: 80%;
}
}
@keyframes t-bar-loaded {
0% {
height: 6rpx;
opacity: 1;
width: 90%;
}
50% {
height: 6rpx;
opacity: 1;
width: 100%;
}
100% {
height: 0;
opacity: 0;
width: 100%;
}
}
.t-loading__dot-1 {
transform: rotate(30deg);
opacity: 0;
}
.t-loading__dot-2 {
transform: rotate(60deg);
opacity: 0.08333333;
}
.t-loading__dot-3 {
transform: rotate(90deg);
opacity: 0.16666667;
}
.t-loading__dot-4 {
transform: rotate(120deg);
opacity: 0.25;
}
.t-loading__dot-5 {
transform: rotate(150deg);
opacity: 0.33333333;
}
.t-loading__dot-6 {
transform: rotate(180deg);
opacity: 0.41666667;
}
.t-loading__dot-7 {
transform: rotate(210deg);
opacity: 0.5;
}
.t-loading__dot-8 {
transform: rotate(240deg);
opacity: 0.58333333;
}
.t-loading__dot-9 {
transform: rotate(270deg);
opacity: 0.66666667;
}
.t-loading__dot-10 {
transform: rotate(300deg);
opacity: 0.75;
}
.t-loading__dot-11 {
transform: rotate(330deg);
opacity: 0.83333333;
}
.t-loading__dot-12 {
transform: rotate(360deg);
opacity: 0.91666667;
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes rotateReverse {
from {
transform: rotate(360deg);
}
to {
transform: rotate(0deg);
}
}
@keyframes dotting {
0% {
opacity: 0.15;
}
1% {
opacity: 0.8;
}
33% {
opacity: 0.8;
}
34% {
opacity: 0.15;
}
100% {
opacity: 0.15;
}
}

View File

@@ -0,0 +1,3 @@
import { TdLoadingProps } from './type';
declare const props: TdLoadingProps;
export default props;

View File

@@ -0,0 +1,52 @@
const props = {
delay: {
type: Number,
value: 0,
},
duration: {
type: Number,
value: 800,
},
fullscreen: {
type: Boolean,
value: false,
},
indicator: {
type: Boolean,
value: true,
},
inheritColor: {
type: Boolean,
value: false,
},
layout: {
type: String,
value: 'horizontal',
},
loading: {
type: Boolean,
value: true,
},
pause: {
type: Boolean,
value: false,
},
progress: {
type: Number,
},
reverse: {
type: Boolean,
},
size: {
type: String,
value: '20px',
},
text: {
type: String,
},
theme: {
type: String,
value: 'circular',
},
};
export default props;

View File

@@ -0,0 +1,54 @@
export interface TdLoadingProps {
delay?: {
type: NumberConstructor;
value?: number;
};
duration?: {
type: NumberConstructor;
value?: number;
};
fullscreen?: {
type: BooleanConstructor;
value?: boolean;
};
indicator?: {
type: BooleanConstructor;
value?: boolean;
};
inheritColor?: {
type: BooleanConstructor;
value?: boolean;
};
layout?: {
type: StringConstructor;
value?: 'horizontal' | 'vertical';
};
loading?: {
type: BooleanConstructor;
value?: boolean;
};
pause?: {
type: BooleanConstructor;
value?: boolean;
};
progress?: {
type: NumberConstructor;
value?: number;
};
reverse?: {
type: BooleanConstructor;
value?: boolean;
};
size?: {
type: StringConstructor;
value?: string;
};
text?: {
type: StringConstructor;
value?: string;
};
theme?: {
type: StringConstructor;
value?: 'circular' | 'spinner' | 'dots';
};
}

View File

@@ -0,0 +1 @@
export {};