showMessageBox 超时时间根据文本长度自动调整

This commit is contained in:
fofolee
2022-05-02 16:07:12 +08:00
parent 0e48da299f
commit 35a68dec97
2 changed files with 3 additions and 2 deletions

View File

@@ -84,9 +84,10 @@ export default {
this.showUI(ConfirmBox, { message, title }, false, reslove); this.showUI(ConfirmBox, { message, title }, false, reslove);
}), }),
showMessageBox: (message, icon = "success", time = 3000) => { showMessageBox: (message, icon = "success", time) => {
if (icon === "success") icon = "positive"; if (icon === "success") icon = "positive";
if (icon === "error") icon = "negative"; if (icon === "error") icon = "negative";
if (!time) time = Math.max(message.toString().length * 120, 1000);
Notify.create({ Notify.create({
type: icon, type: icon,
message: message, message: message,

View File

@@ -138,7 +138,7 @@ interface quickcommandApi {
* ``` * ```
* @param message 显示的消息内容 * @param message 显示的消息内容
* @param icon 图标,默认为 success * @param icon 图标,默认为 success
* @param time 多少毫秒后消失,默认为 3000,当设为 0 时则需要手动点击关闭 * @param time 多少毫秒后消失,如不指定则根据文本长度自动调整,当设为 0 时则需要手动点击关闭
*/ */
showMessageBox( showMessageBox(
message: string, message: string,