import $ from 'jquery' import _ from 'lodash' /** * 显示错误异常信息 * @param msg 错误内容 * @param sender 发送者按钮(可以为空) */ export function showErrorDialog(msg, sender?) { Ext.MessageBox.show({ title: '错误', msg: msg, buttons: Ext.MessageBox.OK, animateTarget: sender, icon: 'error', cls: 'show-icon-messagebox', }); } /** * 中间灰底白字提示 */ export function msg(message: string): void { const $body = $('body') $body.find('[xtype=tooltip]').remove() const $w = $( '
' + '
' + _.escape(message) + '
' ) $body.append($w) const iframeWidth = $w.parent().width() as number const iframeHeight = $w.parent().height() as number const windowWidth = $w.width() as number const windowHeight = $w.height() as number let setWidth = (iframeWidth - windowWidth) / 2 let setHeight = (iframeHeight - windowHeight) / 2 if (iframeHeight < windowHeight || setHeight < 0) { setHeight = 0 } if (iframeWidth < windowWidth || setWidth < 0) { setWidth = 0 } $w.css({left: setWidth, top: setHeight}) setTimeout(() => { $w.remove() }, 3000) }