51 lines
2.4 KiB
Plaintext
51 lines
2.4 KiB
Plaintext
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>Aurora Admin · MessagePro(普通 H5)</title>
|
||
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css" />
|
||
<link rel="stylesheet" href="MessagePro.css" />
|
||
<style>body{margin:0;padding:24px;background: var(--au-color-page-bg);display:flex;gap:8px;flex-wrap:wrap;}</style>
|
||
</head>
|
||
<body>
|
||
<button onclick="AaMessage.success('保存成功')">success</button>
|
||
<button onclick="AaMessage.error('操作失败')">error</button>
|
||
<button onclick="AaMessage.warning('注意风险')">warning</button>
|
||
<button onclick="AaMessage.info('已发送通知')">info</button>
|
||
<button onclick="AaMessage.loading('加载中…')">loading</button>
|
||
|
||
<script>
|
||
(function () {
|
||
var ICON = { success: '✓', error: '✕', warning: '!', info: 'i', loading: '…' };
|
||
var wrap = document.createElement('div');
|
||
wrap.className = 'aa-message-wrap';
|
||
document.body.appendChild(wrap);
|
||
var id = 0;
|
||
function open(opts) {
|
||
var el = document.createElement('div');
|
||
el.className = 'aa-message is-' + opts.type;
|
||
el.innerHTML = '<span class="aa-message-icon" aria-live="polite">' + (ICON[opts.type] || 'i') + '</span>' +
|
||
'<span class="aa-message-content" aria-live="polite">' + opts.content + '</span>' +
|
||
(opts.closable !== false ? '<span class="aa-message-close" role="status" aria-live="polite">✕</span>' : '');
|
||
wrap.appendChild(el);
|
||
var myId = ++id;
|
||
function close() { if (el.parentNode) el.parentNode.removeChild(el); }
|
||
el.querySelector('.aa-message-close') && el.querySelector('.aa-message-close').addEventListener('click', close);
|
||
var d = opts.duration == null ? 3000 : opts.duration;
|
||
if (d > 0) setTimeout(close, d);
|
||
return close;
|
||
}
|
||
window.AaMessage = {
|
||
success: function (c, d) { return open({ type: 'success', content: c, duration: d }); },
|
||
error: function (c, d) { return open({ type: 'error', content: c, duration: d }); },
|
||
warning: function (c, d) { return open({ type: 'warning', content: c, duration: d }); },
|
||
info: function (c, d) { return open({ type: 'info', content: c, duration: d }); },
|
||
loading: function (c, d) { return open({ type: 'loading', content: c, duration: d }); },
|
||
open: open
|
||
};
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|