This commit is contained in:
Ling53666
2025-08-18 09:11:51 +08:00
commit 02554225da
2516 changed files with 133155 additions and 0 deletions

View File

@ -0,0 +1,52 @@
<view
a:if="{{show}}"
class="ant-toast {{className || ''}} {{icon || image || type ? 'ant-toast-icon-wrapper' : ''}}"
style="{{style || ''}}"
>
<view
a:if="{{type}}"
class="ant-toast-normal"
>
<loading
a:if="{{type === 'loading'}}"
type="mini"
></loading>
<am-icon
a:elif="{{type === 'warning'}}"
type="ExclamationOutline"
className="ant-toast-icon"
></am-icon>
<am-icon
a:elif="{{type === 'error'}}"
type="CloseOutline"
className="ant-toast-icon"
></am-icon>
<am-icon
a:elif="{{type === 'success'}}"
type="CheckOutline"
className="ant-toast-icon"
></am-icon>
</view>
<am-icon
a:elif="{{icon}}"
type="{{icon}}"
className="ant-toast-icon"
></am-icon>
<view
a:elif="{{image}}"
style="background-image: url({{image}})"
class="ant-toast-image"
></view>
<view class="ant-toast-text-body">
<view class="ant-toast-text-box">
<view class="ant-toast-text-content">{{content.substring(0, 24)}}</view>
</view>
</view>
</view>
<mask
a:if="{{show && showMask}}"
className="ant-toast-mask"
show="{{true}}"
onMaskTap="handleClickMask"
style="{{maskStyle}}"
></mask>

View File

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

View File

@ -0,0 +1,51 @@
import { Component, triggerEventOnly, getValueFromProps, } from '../_util/simply';
import { ToastDefaultProps } from './props';
Component(ToastDefaultProps, {
closeMask: function () {
if (this.timer) {
clearTimeout(this.timer);
}
this.setData({ show: false });
this.timer = null;
triggerEventOnly(this, 'close');
},
handleShowToast: function () {
var _this = this;
this.setData({ show: true });
var duration = getValueFromProps(this, 'duration');
if (duration > 0) {
var timer = setTimeout(function () {
_this.closeMask();
}, duration);
this.timer = timer;
}
},
handleClickMask: function () {
var _a = getValueFromProps(this, [
'showMask',
'maskCloseable',
]), showMask = _a[0], maskCloseable = _a[1];
if (showMask && maskCloseable) {
this.closeMask();
}
},
}, {
show: false,
}, undefined, {
timer: null,
didUpdate: function (prev) {
var visible = getValueFromProps(this, 'visible');
if (!prev.visible && visible) {
this.handleShowToast();
}
else if (!visible && this.data.show) {
this.closeMask();
}
},
didMount: function () {
var visible = getValueFromProps(this, 'visible');
if (visible) {
this.handleShowToast();
}
},
});

View File

@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"am-icon": "../Icon/index",
"mask": "../Mask/index",
"loading": "../Loading/index"
}
}

View File

@ -0,0 +1,79 @@
@import (reference) './variable.less';
@toastPrefix: ant-toast;
.@{toastPrefix} {
color: #fff;
position: fixed;
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0);
z-index: 999;
padding: 24 * @rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #000;
border-radius: 16 * @rpx;
&-icon,
&-image,
&-normal {
margin-bottom: 16 * @rpx;
}
&-normal {
height: 80 * @rpx;
}
&-icon {
display: flex;
justify-content: center;
align-items: center;
font-size: 100 * @rpx;
}
&-image,
&-icon {
width: 80 * @rpx;
height: 80 * @rpx;
background-size: contain;
background-repeat: no-repeat;
}
&-text {
&-body {
display: flex;
max-width: 380 * @rpx;
max-height: 84 * @rpx;
justify-content: center;
}
&-box {
min-width: 0;
max-height: 84 * @rpx;
}
&-content {
font-size: 30 * @rpx;
line-height: 42 * @rpx;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
}
&-icon-wrapper {
width: 280 * @rpx;
height: 280 * @rpx;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
&-mask {
z-index: 998;
}
}

View File

@ -0,0 +1,47 @@
import { IBaseProps, IconType } from '../_util/base';
/**
* @description 标签,突出利益点、以及属性说明。
*/
type EnumToastType = 'success' | 'warning' | 'error' | 'loading';
export interface IToastProps extends IBaseProps {
/**
* @description Toast 完全关闭后的回调
*/
onClose: (e: any) => void;
/**
* @description Toast 文本内容
*/
content: string;
/**
* @description Toast 图标
*/
icon: IconType;
/**
* @description Toast 图片,与 icon 互斥,优先展示 icon
*/
image: string;
/**
* @description Toast 持续时间
* @default 2000
*/
duration: number;
/**
* @description 是否展示 Toast
*/
visible: boolean;
/**
* @description 是否展示蒙层
*/
showMask: boolean;
/**
* @description 点击蒙层是否隐藏 Toast
*/
maskCloseable: boolean;
maskStyle: string;
/**
* @description 点击蒙层是否隐藏 Toast
*/
type: EnumToastType;
}
export declare const ToastDefaultProps: Partial<IToastProps>;
export {};

View File

@ -0,0 +1,11 @@
export var ToastDefaultProps = {
content: null,
icon: null,
image: null,
duration: 2000,
visible: false,
showMask: false,
maskCloseable: false,
maskStyle: '',
type: null,
};

View File

@ -0,0 +1 @@
@import (reference) '../style/themes/index.less';