From 3d59f3795308330da25f58126c5fc9740a9f9618 Mon Sep 17 00:00:00 2001 From: jian Date: Wed, 3 Jan 2024 17:21:14 +0800 Subject: [PATCH] =?UTF-8?q?BI-137665=20fix:=20=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fineui/src/base/foundation/message.js | 289 +++++++++--------- 1 file changed, 145 insertions(+), 144 deletions(-) diff --git a/packages/fineui/src/base/foundation/message.js b/packages/fineui/src/base/foundation/message.js index 400185774..90990e37b 100644 --- a/packages/fineui/src/base/foundation/message.js +++ b/packages/fineui/src/base/foundation/message.js @@ -33,10 +33,10 @@ const defaultConfig = { export const Msg = { alert(title, message, callback, config = defaultConfig) { - this._show(false, title, message, callback, config); + _show(false, title, message, callback, config); }, confirm(title, message, callback, config = defaultConfig) { - this._show(true, title, message, callback, config); + _show(true, title, message, callback, config); }, toast(message, options, context) { isString(options) && (options = { level: options }); @@ -97,173 +97,174 @@ export const Msg = { toast.destroy?.(); }; }, - _show(hasCancel, title, message, callback, config) { - isNull($mask) && - ($mask = Widget._renderEngine - .createElement("
") - .css({ - position: "absolute", - zIndex: zIndex_tip - 2, - top: 0, - left: 0, - right: 0, - bottom: 0, - opacity: 0.5, - }) - .appendTo("body")); - $pop = Widget._renderEngine - .createElement("
") - .css({ - position: "absolute", - zIndex: zIndex_tip - 1, - top: 0, - left: 0, - right: 0, - bottom: 0, - }) - .appendTo("body"); +}; - function close() { - messageShows[messageShows.length - 1].destroy(); - messageShows.pop(); - if (messageShows.length === 0) { - $mask.remove(); - $mask = null; - } - } +function _show(hasCancel, title, message, callback, config) { + isNull($mask) && + ($mask = Widget._renderEngine + .createElement("
") + .css({ + position: "absolute", + zIndex: zIndex_tip - 2, + top: 0, + left: 0, + right: 0, + bottom: 0, + opacity: 0.5, + }) + .appendTo("body")); + $pop = Widget._renderEngine + .createElement("
") + .css({ + position: "absolute", + zIndex: zIndex_tip - 1, + top: 0, + left: 0, + right: 0, + bottom: 0, + }) + .appendTo("body"); - const controlItems = []; - if (hasCancel === true) { - controlItems.push({ - el: { - type: "bi.button", - height: config.buttonHeight, - text: i18nText("BI-Basic_Cancel"), - light: true, - handler() { - close(); - if (isFunction(callback)) { - callback.apply(null, [false]); - } - }, - }, - }); + function close() { + messageShows[messageShows.length - 1].destroy(); + messageShows.pop(); + if (messageShows.length === 0) { + $mask.remove(); + $mask = null; } + } + + const controlItems = []; + if (hasCancel === true) { controlItems.push({ el: { type: "bi.button", height: config.buttonHeight, - text: i18nText("BI-Basic_OK"), + text: i18nText("BI-Basic_Cancel"), + light: true, handler() { close(); if (isFunction(callback)) { - callback.apply(null, [true]); + callback.apply(null, [false]); } }, }, }); - const conf = { - element: $pop, - type: "bi.center_adapt", - items: [ - { - type: "bi.border", - attributes: { - tabIndex: 1, - }, - mounted() { - this.element.keyup(e => { - if (e.keyCode === KeyCode.ENTER) { - close(); + } + controlItems.push({ + el: { + type: "bi.button", + height: config.buttonHeight, + text: i18nText("BI-Basic_OK"), + handler() { + close(); + if (isFunction(callback)) { + callback.apply(null, [true]); + } + }, + }, + }); + const conf = { + element: $pop, + type: "bi.center_adapt", + items: [ + { + type: "bi.border", + attributes: { + tabIndex: 1, + }, + mounted() { + this.element.keyup(e => { + if (e.keyCode === KeyCode.ENTER) { + close(); + if (isFunction(callback)) { + callback.apply(null, [true]); + } + } else if (e.keyCode === KeyCode.ESCAPE) { + close(); + if (hasCancel === true) { if (isFunction(callback)) { - callback.apply(null, [true]); - } - } else if (e.keyCode === KeyCode.ESCAPE) { - close(); - if (hasCancel === true) { - if (isFunction(callback)) { - callback.apply(null, [false]); - } + callback.apply(null, [false]); } } - }); - try { - this.element.focus(); - } catch (e) { } - }, - cls: "bi-card", - items: { - north: { - el: { - type: "bi.border", - cls: "bi-message-title bi-background", - items: { - center: { - el: { - type: "bi.label", - cls: "bi-font-bold", - text: title || i18nText("BI-Basic_Prompt"), - textAlign: "left", - hgap: 20, - height: 40, - }, + }); + try { + this.element.focus(); + } catch (e) { + } + }, + cls: "bi-card", + items: { + north: { + el: { + type: "bi.border", + cls: "bi-message-title bi-background", + items: { + center: { + el: { + type: "bi.label", + cls: "bi-font-bold", + text: title || i18nText("BI-Basic_Prompt"), + textAlign: "left", + hgap: 20, + height: 40, }, - east: { - el: { - type: "bi.icon_button", - cls: "bi-message-close close-font", - // height: 50, - handler() { - close(); - if (isFunction(callback)) { - callback.apply(null, [false]); - } - }, + }, + east: { + el: { + type: "bi.icon_button", + cls: "bi-message-close close-font", + // height: 50, + handler() { + close(); + if (isFunction(callback)) { + callback.apply(null, [false]); + } }, - width: 56, }, + width: 56, }, }, - height: 40, - }, - center: { - el: isPlainObject(message) - ? message - : { - type: "bi.label", - vgap: 10, - hgap: 20, - whiteSpace: "normal", - text: message, - }, }, - south: { - el: { - type: "bi.absolute", - items: [ - { - el: { - type: "bi.right_vertical_adapt", - lgap: 10, - items: controlItems, - }, - top: 0, - left: 20, - right: 20, - bottom: 0, - } - ], + height: 40, + }, + center: { + el: isPlainObject(message) + ? message + : { + type: "bi.label", + vgap: 10, + hgap: 20, + whiteSpace: "normal", + text: message, }, - height: 44, + }, + south: { + el: { + type: "bi.absolute", + items: [ + { + el: { + type: "bi.right_vertical_adapt", + lgap: 10, + items: controlItems, + }, + top: 0, + left: 20, + right: 20, + bottom: 0, + } + ], }, + height: 44, }, - width: 450, - height: 200, - } - ], - }; + }, + width: 450, + height: 200, + } + ], + }; - messageShows[messageShows.length] = createWidget(conf); - }, -}; + messageShows[messageShows.length] = createWidget(conf); +}