mirror of
https://github.com/Cola-Echo/Cola.git
synced 2026-06-06 03:35:50 +00:00
Add files via upload
This commit is contained in:
20
toast.js
20
toast.js
@@ -2,7 +2,17 @@
|
||||
* Toast 提示(显示在手机面板内)
|
||||
*/
|
||||
|
||||
export function showToast(message, icon = '✅', durationMs = 2000) {
|
||||
import { ICON_SUCCESS, ICON_INFO, ICON_REFUND, ICON_RED_PACKET } from './icons.js';
|
||||
|
||||
// 图标类型映射
|
||||
const TOAST_ICONS = {
|
||||
'success': ICON_SUCCESS,
|
||||
'info': ICON_INFO,
|
||||
'refund': ICON_REFUND,
|
||||
'red-packet': ICON_RED_PACKET
|
||||
};
|
||||
|
||||
export function showToast(message, icon = 'success', durationMs = 2000) {
|
||||
const phone = document.getElementById('wechat-phone');
|
||||
if (!phone) return;
|
||||
|
||||
@@ -14,7 +24,13 @@ export function showToast(message, icon = '✅', durationMs = 2000) {
|
||||
|
||||
const iconEl = document.createElement('span');
|
||||
iconEl.className = 'wechat-toast-icon';
|
||||
iconEl.textContent = icon;
|
||||
|
||||
// 支持图标类型字符串或直接的 SVG/emoji
|
||||
if (TOAST_ICONS[icon]) {
|
||||
iconEl.innerHTML = TOAST_ICONS[icon];
|
||||
} else {
|
||||
iconEl.textContent = icon;
|
||||
}
|
||||
|
||||
const textEl = document.createElement('span');
|
||||
textEl.textContent = message;
|
||||
|
||||
Reference in New Issue
Block a user