From 5788a411a1529809d61b1edaa8126729fd75e1b5 Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 16 Jan 2023 17:40:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dlayer.notify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/layer/index.wc | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 073b861..3383359 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bytedo/wcui", - "version": "1.0.8", + "version": "1.0.9", "type": "module", "description": "基于wc开发的一套UI库, 面向未来, 面向electron", "scripts": { diff --git a/src/layer/index.wc b/src/layer/index.wc index 1eca058..6c0d2c4 100644 --- a/src/layer/index.wc +++ b/src/layer/index.wc @@ -48,8 +48,8 @@ font-size: 14px; background: rgba(255, 255, 255, 0.8); box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3); - transition: opacity 0.2s ease-in-out, left 0.2s ease-in-out, right 0.2s ease-in-out, - top 0.2s ease-in-out, bottom 0.2s ease-in-out; + transition: opacity 0.2s ease-in-out, left 0.2s ease-in-out, + right 0.2s ease-in-out, top 0.2s ease-in-out, bottom 0.2s ease-in-out; opacity: 0; &.scale { @@ -261,7 +261,8 @@ const LANGUAGES = { } } LANGUAGES['zh-CN'] = LANGUAGES.cn -const lang = LANGUAGES[window.__ENV_LANG__ || navigator.language] || LANGUAGES.cn +const lang = + LANGUAGES[window.__ENV_LANG__ || navigator.language] || LANGUAGES.cn let uniqueInstance = null // 缓存当前打开的alert/confirm/prompt类型的弹窗 let toastInstance = null // 缓存toast的实例 @@ -315,7 +316,10 @@ export default class Layer { this.props.title = val if (val) { if (this.__TITLE__.firstElementChild) { - this.__TITLE__.insertBefore(document.createTextNode(val), this.__TITLE__.firstElementChild) + this.__TITLE__.insertBefore( + document.createTextNode(val), + this.__TITLE__.firstElementChild + ) } else { this.__TITLE__.textContent = val } @@ -388,7 +392,9 @@ export default class Layer { } } else { this._dragIns = new Drag(this.root.children[1]).by(this.__TITLE__, { - overflow: this.props.hasOwnProperty('overflow') ? this.props.overflow : false + overflow: this.props.hasOwnProperty('overflow') + ? this.props.overflow + : false }) this.removeAttribute('fixed') } @@ -571,8 +577,12 @@ export default class Layer { this.root.children[1].style.cssText += _style } - // 自动聚焦最后一个按钮 - if (this.props.btns.length) { + // 不是prompt类型, 在有按钮时, 自动聚焦最后一个按钮 + if ( + this.props.type !== 'prompt' && + this.props.btns.length && + this.__CTRL__.lastElementChild + ) { // 部分浏览器需要执行一下 focus()才能聚焦成功 this.__CTRL__.lastElementChild.setAttribute('autofocus', '') setTimeout(_ => this.__CTRL__.lastElementChild.focus(), 10) @@ -754,7 +764,7 @@ Object.assign(_layer, { } if (!intercept) { - intercept = function(val, done) { + intercept = function (val, done) { if (val) { done() }