Files
aurora-admin/frameworks/NotificationPro.html
T

50 lines
2.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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 · NotificationPro(普通 H5)</title>
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css" />
<link rel="stylesheet" href="NotificationPro.css" />
<style>body{margin:0;padding:24px;background:#F5F7FA;display:flex;gap:8px;flex-wrap:wrap;}</style>
</head>
<body>
<button onclick="AaNotify.success('审批通过', '订单 ORD-2024 已通过主管审批')">success</button>
<button onclick="AaNotify.error('提交失败', '网络异常,请稍后重试')">error</button>
<button onclick="AaNotify.warning('存储空间不足', '当前已使用 92%')">warning</button>
<button onclick="AaNotify.info('新版本', '系统已发布 v2.3.0')">info</button>
<script>
(function () {
var ICON = { success: '✓', error: '✕', warning: '!', info: 'i' };
var wrap = document.createElement('div');
wrap.className = 'aa-notification-wrap';
document.body.appendChild(wrap);
var id = 0;
function open(opts) {
var el = document.createElement('div');
el.className = 'aa-notification is-' + opts.type;
el.innerHTML = '<span class="aa-notification-icon">' + (ICON[opts.type] || 'i') + '</span>' +
'<div class="aa-notification-body"><div class="aa-notification-title">' + opts.title + '</div>' +
'<div class="aa-notification-desc">' + opts.desc + '</div></div>' +
'<span class="aa-notification-close">✕</span>';
wrap.appendChild(el);
var myId = ++id;
function close() { if (el.parentNode) el.parentNode.removeChild(el); }
el.querySelector('.aa-notification-close').addEventListener('click', close);
var d = opts.duration == null ? 4500 : opts.duration;
if (d > 0) setTimeout(close, d);
return close;
}
window.AaNotify = {
success: function (t, d, dur) { return open({ type: 'success', title: t, desc: d, duration: dur }); },
error: function (t, d, dur) { return open({ type: 'error', title: t, desc: d, duration: dur }); },
warning: function (t, d, dur) { return open({ type: 'warning', title: t, desc: d, duration: dur }); },
info: function (t, d, dur) { return open({ type: 'info', title: t, desc: d, duration: dur }); },
open: open
};
})();
</script>
</body>
</html>