| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <style>
- .notification {
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%) scale(0.9);
- max-width: 400px;
- width: 90%;
- background-color: white;
- border-radius: 10px;
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
- padding: 20px 25px;
- display: flex;
- align-items: center;
- opacity: 0;
- visibility: hidden;
- transition: all 0.3s ease;
- z-index: 1000;
- }
- .notification.active {
- opacity: 1;
- visibility: visible;
- transform: translate(-50%, -50%) scale(1);
- }
- .notification-content {
- display: flex;
- align-items: center;
- width: 100%;
- }
- .notification-icon {
- width: 40px;
- height: 40px;
- background-color: var(--secondary-color);
- color: white;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 15px;
- flex-shrink: 0;
- }
- .notification-message {
- flex-grow: 1;
- font-size: 1rem;
- line-height: 1.4;
- }
- .notification-close {
- background: none;
- border: none;
- cursor: pointer;
- margin-left: 15px;
- color: var(--light-text);
- transition: color 0.3s ease;
- flex-shrink: 0;
- }
- .notification-close:hover {
- color: var(--primary-color);
- }
- /* 添加遮罩层 */
- .notification-overlay {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.1);
- opacity: 0;
- visibility: hidden;
- transition: all 0.3s ease;
- z-index: 999;
- }
- .notification-overlay.active {
- opacity: 1;
- visibility: visible;
- }
- </style>
- <!-- 提示消息组件 -->
- <div id="notification" class="notification">
- <div class="notification-content">
- <div class="notification-icon">
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
- <path d="M9 21L15 21" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
- <path d="M12 17C14.2091 17 16 15.2091 16 13C16 10.7909 14.2091 9 12 9C9.79086 9 8 10.7909 8 13C8 15.2091 9.79086 17 12 17Z" stroke="currentColor" stroke-width="2"/>
- <path d="M12 13C12.5523 13 13 12.5523 13 12C13 11.4477 12.5523 11 12 11C11.4477 11 11 11.4477 11 12C11 12.5523 11.4477 13 12 13Z" fill="currentColor"/>
- <circle cx="12" cy="5" r="3" fill="currentColor"/>
- </svg>
- </div>
- <div class="notification-message" id="notification-message"></div>
- <button class="notification-close" id="notification-close">
- <svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
- <path d="M18 6L6 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
- <path d="M6 6L18 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
- </svg>
- </button>
- </div>
- </div>
- <script>
- // 创建遮罩层
- const notificationOverlay = document.createElement('div');
- notificationOverlay.className = 'notification-overlay';
- document.body.appendChild(notificationOverlay);
- // 通知组件
- const notification = document.getElementById('notification');
- const notificationMessage = document.getElementById('notification-message');
- const notificationClose = document.getElementById('notification-close');
- function showNotification(message, duration = 4000) {
- notificationMessage.textContent = message;
-
- // 显示通知和遮罩层
- notification.classList.add('active');
- notificationOverlay.classList.add('active');
-
- // 设置定时器自动关闭
- const timeoutId = setTimeout(() => {
- hideNotification();
- }, duration);
-
- // 点击关闭按钮或遮罩层
- notificationClose.addEventListener('click', closeNotification);
- notificationOverlay.addEventListener('click', closeNotification);
-
- function closeNotification() {
- clearTimeout(timeoutId);
- hideNotification();
- notificationClose.removeEventListener('click', closeNotification);
- notificationOverlay.removeEventListener('click', closeNotification);
- }
- }
- function hideNotification() {
- notification.classList.remove('active');
- notificationOverlay.classList.remove('active');
- }
-
- </script>
|