start
This commit is contained in:
58
miniprogram_npm/tdesign-miniprogram/message/README.en-US.md
Normal file
58
miniprogram_npm/tdesign-miniprogram/message/README.en-US.md
Normal file
@@ -0,0 +1,58 @@
|
||||
:: BASE_DOC ::
|
||||
|
||||
## API
|
||||
|
||||
### Message 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
|
||||
action | String / Slot | - | `deprecated`。operation。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
align | String | left | options: left/center。Typescript:`MessageAlignType` `type MessageAlignType = 'left' \| 'center'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
close-btn | String / Boolean / Object / Slot | false | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
content | String / Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
duration | Number | 3000 | \- | N
|
||||
gap | String / Number / Boolean | 12 | \- | N
|
||||
icon | String / Boolean / Object / Slot | true | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
link | String / Object / Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
marquee | Boolean / Object | false | Typescript:`boolean \| MessageMarquee` `interface MessageMarquee { speed?: number; loop?: number; delay?: number }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
offset | Array | - | Typescript:`Array<string \| number>` | N
|
||||
single | Boolean | true | \- | N
|
||||
theme | String | info | options: info/success/warning/error。Typescript:`MessageThemeList` `type MessageThemeList = 'info' \| 'success' \| 'warning' \| 'error'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
visible | Boolean | false | \- | N
|
||||
default-visible | Boolean | undefined | uncontrolled property | N
|
||||
z-index | Number | 15000 | \- | N
|
||||
|
||||
### Message Events
|
||||
|
||||
name | params | description
|
||||
-- | -- | --
|
||||
action-btn-click | - | \-
|
||||
close-btn-click | - | \-
|
||||
duration-end | \- | \-
|
||||
link-click | - | \-
|
||||
### Message External Classes
|
||||
|
||||
className | Description
|
||||
-- | --
|
||||
t-class | \-
|
||||
t-class-close-btn | \-
|
||||
t-class-content | \-
|
||||
t-class-icon | \-
|
||||
t-class-link | \-
|
||||
|
||||
### CSS Variables
|
||||
|
||||
The component provides the following CSS variables, which can be used to customize styles.
|
||||
Name | Default Value | Description
|
||||
-- | -- | --
|
||||
--td-message-bg-color | @bg-color-container | -
|
||||
--td-message-border-radius | @radius-default | -
|
||||
--td-message-box-shadow | @shadow-4 | -
|
||||
--td-message-close-icon-color | @font-gray-3 | -
|
||||
--td-message-content-font-color | @font-gray-1 | -
|
||||
--td-message-error-color | @error-color | -
|
||||
--td-message-info-color | @brand-color | -
|
||||
--td-message-success-color | @success-color | -
|
||||
--td-message-warning-color | @warning-color | -
|
||||
104
miniprogram_npm/tdesign-miniprogram/message/README.md
Normal file
104
miniprogram_npm/tdesign-miniprogram/message/README.md
Normal file
@@ -0,0 +1,104 @@
|
||||
---
|
||||
title: Message 消息通知
|
||||
description: 用于轻量级反馈或提示,不会打断用户操作。
|
||||
spline: message
|
||||
isComponent: true
|
||||
---
|
||||
|
||||
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-94%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-89%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-94%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-86%25-blue" /></span>
|
||||
## 引入
|
||||
|
||||
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
|
||||
|
||||
```json
|
||||
"usingComponents": {
|
||||
"t-message": "tdesign-miniprogram/message/message"
|
||||
}
|
||||
```
|
||||
|
||||
### 引入 API
|
||||
|
||||
若以 API 形式调用 Message,则需在页面 `page.js` 中引入组件 API:
|
||||
|
||||
```js
|
||||
import Message from 'tdesign-miniprogram/message/index';
|
||||
```
|
||||
|
||||
## 代码演示
|
||||
|
||||
<a href="https://developers.weixin.qq.com/s/Sr8qhimx7bSW" 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>
|
||||
|
||||
### 组件类型
|
||||
|
||||
弹窗内容为纯文本、标题和副标题、带输入框,用 API `Message.info` 方法调用反馈类对话框。
|
||||
|
||||
|
||||
{{ base }}
|
||||
|
||||
|
||||
### 组件状态
|
||||
|
||||
消息通知类型为普通(info)、警示(warning)、成功(success)、错误(error)
|
||||
|
||||
{{ theme }}
|
||||
|
||||
## API
|
||||
|
||||
### Message Props
|
||||
|
||||
名称 | 类型 | 默认值 | 描述 | 必传
|
||||
-- | -- | -- | -- | --
|
||||
style | Object | - | 样式 | N
|
||||
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
|
||||
action | String / Slot | - | 已废弃。操作。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
align | String | left | 文本对齐方式。可选项:left/center。TS 类型:`MessageAlignType` `type MessageAlignType = 'left' \| 'center'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
close-btn | String / Boolean / Object / Slot | false | 关闭按钮,可以自定义。值为 true 显示默认关闭按钮,值为 false 不显示关闭按钮。值类型为 string ,如:'user',则显示组件内置图标。值类型为 object ,则会透传至 icon 组件。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
content | String / Slot | - | 用于自定义消息弹出内容。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
duration | Number | 3000 | 消息内置计时器,计时到达时会触发 duration-end 事件。单位:毫秒。值为 0 则表示没有计时器。 | N
|
||||
gap | String / Number / Boolean | 12 | 两条 `message` 之间的间距 | N
|
||||
icon | String / Boolean / Object / Slot | true | 消息提醒前面的图标,可以自定义。值为 true 则根据 theme 显示对应的图标,值为 false 则不显示图标。值为 true 显示默认关闭按钮,值为 false 不显示关闭按钮。值类型为 string ,如:'info',则显示组件内置图标。值类型为 object ,则会透传至 icon 组件。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
link | String / Object / Slot | - | 链接名称。值为字符串表示链接名称,值为 `Object` 类型,表示透传至 `Link`。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
|
||||
marquee | Boolean / Object | false | 跑马灯效果。speed 指速度控制;loop 指循环播放次数,值为 -1 表示循环播放,值为 0 表示不循环播放;delay 表示延迟多久开始播放。TS 类型:`boolean \| MessageMarquee` `interface MessageMarquee { speed?: number; loop?: number; delay?: number }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
offset | Array | - | 相对于 placement 的偏移量,默认单位 rpx。示例:[-10, 20] 或 ['10rpx', '8rpx']。TS 类型:`Array<string \| number>` | N
|
||||
single | Boolean | true | 是否保持仅显示一条信息 | N
|
||||
theme | String | info | 消息组件风格。可选项:info/success/warning/error。TS 类型:`MessageThemeList` `type MessageThemeList = 'info' \| 'success' \| 'warning' \| 'error'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/message/type.ts) | N
|
||||
visible | Boolean | false | 是否显示,隐藏时默认销毁组件 | N
|
||||
default-visible | Boolean | undefined | 是否显示,隐藏时默认销毁组件。非受控属性 | N
|
||||
z-index | Number | 15000 | 元素层级,样式默认为 15000 | N
|
||||
|
||||
### Message Events
|
||||
|
||||
名称 | 参数 | 描述
|
||||
-- | -- | --
|
||||
action-btn-click | - | 已废弃。当操作按钮存在时,用户点击操作按钮时触发
|
||||
close-btn-click | - | 当关闭按钮存在时,用户点击关闭按钮触发
|
||||
duration-end | \- | 计时结束后触发
|
||||
link-click | - | 当`link`链接存在时,点击链接文本时触发
|
||||
### Message External Classes
|
||||
|
||||
类名 | 描述
|
||||
-- | --
|
||||
t-class | 根节点样式类
|
||||
t-class-close-btn | 关闭按钮样式类
|
||||
t-class-content | 内容样式类
|
||||
t-class-icon | 图标样式类
|
||||
t-class-link | 链接样式类
|
||||
|
||||
### CSS Variables
|
||||
|
||||
组件提供了下列 CSS 变量,可用于自定义样式。
|
||||
名称 | 默认值 | 描述
|
||||
-- | -- | --
|
||||
--td-message-bg-color | @bg-color-container | -
|
||||
--td-message-border-radius | @radius-default | -
|
||||
--td-message-box-shadow | @shadow-4 | -
|
||||
--td-message-close-icon-color | @font-gray-3 | -
|
||||
--td-message-content-font-color | @font-gray-1 | -
|
||||
--td-message-error-color | @error-color | -
|
||||
--td-message-info-color | @brand-color | -
|
||||
--td-message-success-color | @success-color | -
|
||||
--td-message-warning-color | @warning-color | -
|
||||
17
miniprogram_npm/tdesign-miniprogram/message/index.d.ts
vendored
Normal file
17
miniprogram_npm/tdesign-miniprogram/message/index.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
import { MessageProps } from './message.interface';
|
||||
declare type Context = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
|
||||
interface MessageActionOptionsType extends Optional<MessageProps> {
|
||||
context?: Context;
|
||||
selector?: string;
|
||||
}
|
||||
declare const _default: {
|
||||
info(options: MessageActionOptionsType): WechatMiniprogram.Component.TrivialInstance;
|
||||
success(options: MessageActionOptionsType): WechatMiniprogram.Component.TrivialInstance;
|
||||
warning(options: MessageActionOptionsType): WechatMiniprogram.Component.TrivialInstance;
|
||||
error(options: MessageActionOptionsType): WechatMiniprogram.Component.TrivialInstance;
|
||||
hide(options: MessageActionOptionsType): void;
|
||||
};
|
||||
export default _default;
|
||||
47
miniprogram_npm/tdesign-miniprogram/message/index.js
Normal file
47
miniprogram_npm/tdesign-miniprogram/message/index.js
Normal file
@@ -0,0 +1,47 @@
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
import { MessageType } from './message.interface';
|
||||
import { getInstance } from '../common/utils';
|
||||
const showMessage = function (options, theme = MessageType.info) {
|
||||
const { context, selector = '#t-message' } = options, otherOptions = __rest(options, ["context", "selector"]);
|
||||
const instance = getInstance(context, selector);
|
||||
if (typeof otherOptions.single !== 'boolean') {
|
||||
otherOptions.single = true;
|
||||
}
|
||||
if (instance) {
|
||||
instance.setMessage(otherOptions, theme);
|
||||
return instance;
|
||||
}
|
||||
console.error('未找到组件,请确认 selector && context 是否正确');
|
||||
};
|
||||
export default {
|
||||
info(options) {
|
||||
return showMessage(options, MessageType.info);
|
||||
},
|
||||
success(options) {
|
||||
return showMessage(options, MessageType.success);
|
||||
},
|
||||
warning(options) {
|
||||
return showMessage(options, MessageType.warning);
|
||||
},
|
||||
error(options) {
|
||||
return showMessage(options, MessageType.error);
|
||||
},
|
||||
hide(options) {
|
||||
const { context, selector = '#t-message' } = Object.assign({}, options);
|
||||
const instance = getInstance(context, selector);
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
instance.hide();
|
||||
},
|
||||
};
|
||||
37
miniprogram_npm/tdesign-miniprogram/message/message.d.ts
vendored
Normal file
37
miniprogram_npm/tdesign-miniprogram/message/message.d.ts
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
import { SuperComponent, ComponentsOptionsType } from '../common/src/index';
|
||||
import { MessageType, MessageProps } from './message.interface';
|
||||
export default class Message extends SuperComponent {
|
||||
options: ComponentsOptionsType;
|
||||
properties: MessageProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
messageList: any[];
|
||||
};
|
||||
index: number;
|
||||
instances: any[];
|
||||
gap: number;
|
||||
observers: {
|
||||
visible(value: any): void;
|
||||
};
|
||||
pageLifetimes: {
|
||||
show(): void;
|
||||
};
|
||||
lifetimes: {
|
||||
ready(): void;
|
||||
};
|
||||
memoInitialData(): void;
|
||||
setMessage(msg: MessageProps, theme?: MessageType): void;
|
||||
addMessage(msgObj: MessageProps): void;
|
||||
getOffsetHeight(index?: number): number;
|
||||
showMessageItem(options: MessageProps, id: string, offsetHeight: number): WechatMiniprogram.Component.TrivialInstance;
|
||||
close(id: any): void;
|
||||
hide(id?: string): void;
|
||||
hideAll(): void;
|
||||
removeInstance(id: any): void;
|
||||
removeMsg(id: any): void;
|
||||
handleClose(): void;
|
||||
handleLinkClick(): void;
|
||||
handleDurationEnd(): void;
|
||||
}
|
||||
28
miniprogram_npm/tdesign-miniprogram/message/message.interface.d.ts
vendored
Normal file
28
miniprogram_npm/tdesign-miniprogram/message/message.interface.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
export declare enum MessageType {
|
||||
info = "info",
|
||||
success = "success",
|
||||
warning = "warning",
|
||||
error = "error"
|
||||
}
|
||||
export interface MessageMarquee {
|
||||
speed?: number;
|
||||
loop?: number;
|
||||
delay?: number;
|
||||
}
|
||||
export interface MessageProps {
|
||||
visible?: boolean;
|
||||
content: string;
|
||||
align?: string;
|
||||
theme?: MessageType;
|
||||
icon?: boolean | string;
|
||||
link?: string | object;
|
||||
closeBtn?: boolean;
|
||||
action?: string;
|
||||
marquee?: MessageMarquee;
|
||||
offset?: object;
|
||||
duration?: number;
|
||||
zIndex?: number;
|
||||
id?: string;
|
||||
gap?: string | number;
|
||||
single?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export var MessageType;
|
||||
(function (MessageType) {
|
||||
MessageType["info"] = "info";
|
||||
MessageType["success"] = "success";
|
||||
MessageType["warning"] = "warning";
|
||||
MessageType["error"] = "error";
|
||||
})(MessageType || (MessageType = {}));
|
||||
174
miniprogram_npm/tdesign-miniprogram/message/message.js
Normal file
174
miniprogram_npm/tdesign-miniprogram/message/message.js
Normal file
@@ -0,0 +1,174 @@
|
||||
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 { MessageType } from './message.interface';
|
||||
import props from './props';
|
||||
import { unitConvert } from '../common/utils';
|
||||
const SHOW_DURATION = 400;
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-message`;
|
||||
let Message = class Message extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.options = {
|
||||
multipleSlots: true,
|
||||
};
|
||||
this.properties = Object.assign({}, props);
|
||||
this.data = {
|
||||
prefix,
|
||||
classPrefix: name,
|
||||
messageList: [],
|
||||
};
|
||||
this.index = 0;
|
||||
this.instances = [];
|
||||
this.gap = 12;
|
||||
this.observers = {
|
||||
visible(value) {
|
||||
if (value) {
|
||||
this.setMessage(this.properties, this.properties.theme);
|
||||
}
|
||||
else {
|
||||
this.setData({
|
||||
messageList: [],
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
this.pageLifetimes = {
|
||||
show() {
|
||||
this.hideAll();
|
||||
},
|
||||
};
|
||||
this.lifetimes = {
|
||||
ready() {
|
||||
this.memoInitialData();
|
||||
},
|
||||
};
|
||||
}
|
||||
memoInitialData() {
|
||||
this.initialData = Object.assign(Object.assign({}, this.properties), this.data);
|
||||
}
|
||||
setMessage(msg, theme = MessageType.info) {
|
||||
let id = `${name}_${this.index}`;
|
||||
if (msg.single) {
|
||||
id = name;
|
||||
}
|
||||
this.gap = unitConvert(msg.gap || this.gap);
|
||||
const msgObj = Object.assign(Object.assign({}, msg), { theme,
|
||||
id, gap: this.gap });
|
||||
const instanceIndex = this.instances.findIndex((x) => x.id === id);
|
||||
if (instanceIndex < 0) {
|
||||
this.addMessage(msgObj);
|
||||
}
|
||||
else {
|
||||
const instance = this.instances[instanceIndex];
|
||||
const offsetHeight = this.getOffsetHeight(instanceIndex);
|
||||
instance.resetData(() => {
|
||||
instance.setData(msgObj, instance.show.bind(instance, offsetHeight));
|
||||
instance.onHide = () => {
|
||||
this.close(id);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
addMessage(msgObj) {
|
||||
const list = [...this.data.messageList, { id: msgObj.id }];
|
||||
this.setData({
|
||||
messageList: list,
|
||||
}, () => {
|
||||
const offsetHeight = this.getOffsetHeight();
|
||||
const instance = this.showMessageItem(msgObj, msgObj.id, offsetHeight);
|
||||
if (this.instances) {
|
||||
this.instances.push(instance);
|
||||
this.index += 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
getOffsetHeight(index = -1) {
|
||||
let offsetHeight = 0;
|
||||
let len = index;
|
||||
if (len === -1 || len > this.instances.length) {
|
||||
len = this.instances.length;
|
||||
}
|
||||
for (let i = 0; i < len; i += 1) {
|
||||
const instance = this.instances[i];
|
||||
offsetHeight += instance.data.height + instance.data.gap;
|
||||
}
|
||||
return offsetHeight;
|
||||
}
|
||||
showMessageItem(options, id, offsetHeight) {
|
||||
const instance = this.selectComponent(`#${id}`);
|
||||
if (instance) {
|
||||
instance.resetData(() => {
|
||||
instance.setData(options, instance.show.bind(instance, offsetHeight));
|
||||
instance.onHide = () => {
|
||||
this.close(id);
|
||||
};
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
console.error('未找到组件,请确认 selector && context 是否正确');
|
||||
}
|
||||
close(id) {
|
||||
setTimeout(() => {
|
||||
this.removeMsg(id);
|
||||
}, SHOW_DURATION);
|
||||
this.removeInstance(id);
|
||||
}
|
||||
hide(id) {
|
||||
if (!id) {
|
||||
this.hideAll();
|
||||
}
|
||||
const instance = this.instances.find((x) => x.id === id);
|
||||
if (instance) {
|
||||
instance.hide();
|
||||
}
|
||||
}
|
||||
hideAll() {
|
||||
for (let i = 0; i < this.instances.length;) {
|
||||
const instance = this.instances[i];
|
||||
instance.hide();
|
||||
}
|
||||
}
|
||||
removeInstance(id) {
|
||||
const index = this.instances.findIndex((x) => x.id === id);
|
||||
if (index < 0)
|
||||
return;
|
||||
const instance = this.instances[index];
|
||||
const removedHeight = instance.data.height;
|
||||
this.instances.splice(index, 1);
|
||||
for (let i = index; i < this.instances.length; i += 1) {
|
||||
const instance = this.instances[i];
|
||||
instance.setData({
|
||||
wrapTop: instance.data.wrapTop - removedHeight - instance.data.gap,
|
||||
});
|
||||
}
|
||||
}
|
||||
removeMsg(id) {
|
||||
const msgIndex = this.data.messageList.findIndex((x) => x.id === id);
|
||||
if (msgIndex > -1) {
|
||||
this.data.messageList.splice(msgIndex, 1);
|
||||
this.setData({
|
||||
messageList: this.data.messageList,
|
||||
});
|
||||
}
|
||||
}
|
||||
handleClose() {
|
||||
this.triggerEvent('close-btn-click');
|
||||
}
|
||||
handleLinkClick() {
|
||||
this.triggerEvent('link-click');
|
||||
}
|
||||
handleDurationEnd() {
|
||||
this.triggerEvent('duration-end');
|
||||
}
|
||||
};
|
||||
Message = __decorate([
|
||||
wxComponent()
|
||||
], Message);
|
||||
export default Message;
|
||||
7
miniprogram_npm/tdesign-miniprogram/message/message.json
Normal file
7
miniprogram_npm/tdesign-miniprogram/message/message.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"styleIsolation": "apply-shared",
|
||||
"usingComponents": {
|
||||
"t-message-item": "../message-item/message-item"
|
||||
}
|
||||
}
|
||||
14
miniprogram_npm/tdesign-miniprogram/message/message.wxml
Normal file
14
miniprogram_npm/tdesign-miniprogram/message/message.wxml
Normal file
@@ -0,0 +1,14 @@
|
||||
<block wx:for="{{messageList}}" wx:key="id">
|
||||
<t-message-item
|
||||
id="{{item.id}}"
|
||||
bind:close-btn-click="handleClose"
|
||||
bind:link-click="handleLinkClick"
|
||||
bind:duration-end="handleDurationEnd"
|
||||
>
|
||||
<slot name="icon" slot="icon" />
|
||||
<slot name="content" slot="content" />
|
||||
<slot />
|
||||
<slot name="link" slot="link" />
|
||||
<slot name="close-btn" slot="close-btn" />
|
||||
</t-message-item>
|
||||
</block>
|
||||
3
miniprogram_npm/tdesign-miniprogram/message/props.d.ts
vendored
Normal file
3
miniprogram_npm/tdesign-miniprogram/message/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdMessageProps } from './type';
|
||||
declare const props: TdMessageProps;
|
||||
export default props;
|
||||
56
miniprogram_npm/tdesign-miniprogram/message/props.js
Normal file
56
miniprogram_npm/tdesign-miniprogram/message/props.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const props = {
|
||||
align: {
|
||||
type: String,
|
||||
value: 'left',
|
||||
},
|
||||
closeBtn: {
|
||||
type: null,
|
||||
value: false,
|
||||
},
|
||||
content: {
|
||||
type: String,
|
||||
},
|
||||
duration: {
|
||||
type: Number,
|
||||
value: 3000,
|
||||
},
|
||||
gap: {
|
||||
type: null,
|
||||
value: 12,
|
||||
},
|
||||
icon: {
|
||||
type: null,
|
||||
value: true,
|
||||
},
|
||||
link: {
|
||||
type: null,
|
||||
},
|
||||
marquee: {
|
||||
type: null,
|
||||
value: false,
|
||||
},
|
||||
offset: {
|
||||
type: Array,
|
||||
},
|
||||
single: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
theme: {
|
||||
type: String,
|
||||
value: 'info',
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
defaultVisible: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
zIndex: {
|
||||
type: Number,
|
||||
value: 15000,
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
65
miniprogram_npm/tdesign-miniprogram/message/type.d.ts
vendored
Normal file
65
miniprogram_npm/tdesign-miniprogram/message/type.d.ts
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
export interface TdMessageProps {
|
||||
align?: {
|
||||
type: StringConstructor;
|
||||
value?: MessageAlignType;
|
||||
};
|
||||
closeBtn?: {
|
||||
type: null;
|
||||
value?: string | boolean | object;
|
||||
};
|
||||
content?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
duration?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
gap?: {
|
||||
type: null;
|
||||
value?: string | number | boolean;
|
||||
};
|
||||
icon?: {
|
||||
type: null;
|
||||
value?: string | boolean | object;
|
||||
};
|
||||
link?: {
|
||||
type: null;
|
||||
value?: string | object;
|
||||
};
|
||||
marquee?: {
|
||||
type: null;
|
||||
value?: boolean | MessageMarquee;
|
||||
};
|
||||
offset?: {
|
||||
type: ArrayConstructor;
|
||||
value?: Array<string | number>;
|
||||
};
|
||||
single?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: MessageThemeList;
|
||||
};
|
||||
visible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
defaultVisible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
zIndex?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
}
|
||||
export declare type MessageAlignType = 'left' | 'center';
|
||||
export interface MessageMarquee {
|
||||
speed?: number;
|
||||
loop?: number;
|
||||
delay?: number;
|
||||
}
|
||||
export declare type MessageThemeList = 'info' | 'success' | 'warning' | 'error';
|
||||
1
miniprogram_npm/tdesign-miniprogram/message/type.js
Normal file
1
miniprogram_npm/tdesign-miniprogram/message/type.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user