初始化项目, 添加TDesign等包

This commit is contained in:
zhengw
2025-11-28 16:49:36 +08:00
commit 3e53beb7bb
980 changed files with 39201 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
/// <reference types="miniprogram-api-typings" />
/// <reference types="miniprogram-api-typings" />
declare type Context = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
declare type ToastType = 'loading' | 'success' | 'warning' | 'error';
declare type ToastPositionType = 'top' | 'middle' | 'bottom';
declare type ToastDirectionType = 'row' | 'column';
export declare type ToastOptionsType = {
context?: Context;
selector?: string;
icon?: string;
message?: string;
duration?: number;
theme?: ToastType;
placement?: ToastPositionType;
preventScrollThrough?: boolean;
direction?: ToastDirectionType;
close?: () => void;
};
declare function Toast(options: ToastOptionsType): void;
declare function showToast(options?: ToastOptionsType): void;
declare function hideToast(options?: ToastOptionsType): void;
export { Toast as default, showToast, hideToast };

View File

@@ -0,0 +1 @@
import{__rest}from"tslib";import{getInstance}from"../common/utils";function Toast(t){var o;const{context:s,selector:e="#t-toast"}=t,n=__rest(t,["context","selector"]),a=getInstance(s,e);a&&a.show(Object.assign(Object.assign({},n),{duration:null!==(o=n.duration)&&void 0!==o?o:2e3}))}function showToast(t={}){Toast(t)}function hideToast(t={}){const{context:o,selector:s="#t-toast"}=t,e=getInstance(o,s);e&&e.hide()}export{Toast as default,showToast,hideToast};

View File

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

View File

@@ -0,0 +1 @@
const props={direction:{type:String,value:"row"},duration:{type:Number,value:2e3},icon:{type:null},message:{type:String},overlayProps:{type:Object},placement:{type:String,value:"middle"},preventScrollThrough:{type:Boolean,value:!1},showOverlay:{type:Boolean,value:!1},theme:{type:String},usingCustomNavbar:{type:Boolean,value:!1}};export default props;

View File

@@ -0,0 +1,31 @@
/// <reference types="node" />
import { SuperComponent } from '../common/src/index';
import { ToastOptionsType } from './index';
declare type Timer = NodeJS.Timeout | null;
export default class Toast extends SuperComponent {
externalClasses: string[];
options: {
multipleSlots: boolean;
};
behaviors: string[];
hideTimer: Timer;
data: {
prefix: string;
classPrefix: string;
typeMapIcon: string;
};
properties: import("./type").TdToastProps;
lifetimes: {
detached(): void;
};
pageLifetimes: {
hide(): void;
};
methods: {
show(options: ToastOptionsType): void;
hide(): void;
destroyed(): void;
loop(): void;
};
}
export {};

View File

@@ -0,0 +1 @@
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";import transition from"../mixins/transition";import{calcIcon}from"../common/utils";import useCustomNavbar from"../mixins/using-custom-navbar";const{prefix:prefix}=config,name=`${prefix}-toast`;let Toast=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`],this.options={multipleSlots:!0},this.behaviors=[transition(),useCustomNavbar],this.hideTimer=null,this.data={prefix:prefix,classPrefix:name,typeMapIcon:""},this.properties=props,this.lifetimes={detached(){this.destroyed()}},this.pageLifetimes={hide(){this.hide()}},this.methods={show(e){this.hideTimer&&clearTimeout(this.hideTimer);const i={loading:"loading",success:"check-circle",warning:"error-circle",error:"close-circle"}[null==e?void 0:e.theme],t={direction:props.direction.value,duration:props.duration.value,icon:props.icon.value,message:props.message.value,placement:props.placement.value,preventScrollThrough:props.preventScrollThrough.value,theme:props.theme.value},o=Object.assign(Object.assign(Object.assign({},t),e),{visible:!0,isLoading:"loading"===(null==e?void 0:e.theme),_icon:calcIcon(null!=i?i:e.icon)}),{duration:s}=o;this.setData(o),s>0&&(this.hideTimer=setTimeout(()=>{this.hide()},s))},hide(){var e,i;this.data.visible&&(this.setData({visible:!1}),null===(i=null===(e=this.data)||void 0===e?void 0:e.close)||void 0===i||i.call(e),this.triggerEvent("close"))},destroyed(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null),this.triggerEvent("destory")},loop(){}}}};Toast=__decorate([wxComponent()],Toast);export default Toast;

View File

@@ -0,0 +1 @@
{"component":true,"styleIsolation":"apply-shared","usingComponents":{"t-icon":"../icon/icon","t-loading":"../loading/loading","t-overlay":"../overlay/overlay"}}

View File

@@ -0,0 +1 @@
<import src="../common/template/icon.wxml"/><wxs src="../common/utils.wxs" module="_"/><view wx:if="{{realVisible}}" class="{{_.cls(classPrefix, [direction, theme, ['with-text', message]])}} class {{prefix}}-class {{transitionClass}}" style="{{_._style([ 'top:' + (placement === 'top' ? '25%' : placement === 'bottom' ? '75%': '45%'), style, customStyle])}}" bind:transitionend="onTransitionEnd" catch:touchstart="loop"><view class="{{classPrefix}}__content {{classPrefix}}__content--{{direction}}"><t-loading wx:if="{{isLoading}}" theme="circular" size="{{direction === 'row' ? '48rpx' : '64rpx'}}" loading inherit-color layout="vertical"/><template wx:elif="{{_icon}}" is="icon" data="{{ ariaHidden: true, tClass: classPrefix + '__icon ' + classPrefix + '__icon--' + direction, ..._icon }}"/><slot name="icon"/><view aria-role="alert" class="{{classPrefix}}__text {{classPrefix}}__text--{{direction}}">{{message}}</view><slot name="message"/></view></view><t-overlay style="{{ overlayProps && overlayProps.style || ''}}" visible="{{realVisible && (showOverlay || preventScrollThrough)}}" z-index="{{overlayProps && overlayProps.zIndex || 11000}}" duration="{{overlayProps && overlayProps.duration || 300}}" usingCustomNavbar="{{overlayProps && overlayProps.usingCustomNavbar || usingCustomNavbar}}" backgroundColor="{{!showOverlay && preventScrollThrough ? 'transparent' : overlayProps && overlayProps.backgroundColor || ''}}" preventScrollThrough="{{preventScrollThrough || overlayProps && overlayProps.preventScrollThrough}}"/>

View File

@@ -0,0 +1,12 @@
@import '../common/style/index.wxss';.t-toast{position:fixed;left:50%;transform:translate(-50%,-50%);z-index:12001;opacity:1;transition:opacity .3s ease;background-color:var(--td-toast-bg-color,var(--td-mask-active,rgba(0,0,0,.6)));border-radius:var(--td-toast-radius,var(--td-radius-default,12rpx));font-size:28rpx;color:var(--td-toast-color,var(--td-text-color-anti,var(--td-font-white-1,#fff)));max-width:var(--td-toast-max-width,370rpx);min-height:0;width:auto;display:flex;flex-direction:column;align-items:stretch;box-sizing:border-box;}
.t-toast--column{padding:48rpx;min-width:160rpx;min-height:160rpx;border-radius:16rpx;display:flex;align-items:center;justify-content:center;}
.t-toast--loading.t-toast--with-text{min-width:204rpx;min-height:204rpx;padding-top:0;padding-bottom:0;}
.t-toast__content{align-items:center;line-height:44rpx;}
.t-toast__content--row{display:flex;text-align:left;padding:28rpx 44rpx;}
.t-toast__content--column{display:flex;flex-direction:column;justify-content:center;align-items:center;}
.t-toast__icon--row{display:flex;font-size:var(--td-toast-row-icon-size,48rpx);}
.t-toast__icon--column{font-size:var(--td-toast-column-icon-size,64rpx);}
.t-toast__text{overflow:hidden;text-overflow:ellipsis;-webkit-line-clamp:3;display:-webkit-box;-webkit-box-orient:vertical;white-space:pre-line;}
.t-toast__text--column:not(:empty):not(:only-child){margin-top:16rpx;}
.t-toast__text--row:not(:empty):not(:only-child){margin-left:16rpx;}
.t-toast.t-fade-enter,.t-toast.t-fade-leave-to{opacity:0;}

View File

@@ -0,0 +1,43 @@
import { OverlayProps } from '../overlay/index';
export interface TdToastProps {
direction?: {
type: StringConstructor;
value?: 'row' | 'column';
};
duration?: {
type: NumberConstructor;
value?: number;
};
icon?: {
type: null;
value?: string | object;
};
message?: {
type: StringConstructor;
value?: string;
};
overlayProps?: {
type: ObjectConstructor;
value?: OverlayProps;
};
placement?: {
type: StringConstructor;
value?: 'top' | 'middle' | 'bottom';
};
preventScrollThrough?: {
type: BooleanConstructor;
value?: boolean;
};
showOverlay?: {
type: BooleanConstructor;
value?: boolean;
};
theme?: {
type: StringConstructor;
value?: 'loading' | 'success' | 'warning' | 'error';
};
usingCustomNavbar?: {
type: BooleanConstructor;
value?: boolean;
};
}

View File

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