|
39 | 39 | </footer> |
40 | 40 | <script> |
41 | 41 | (function() { |
| 42 | + // 如果本会话已关闭过提示,则不再显示 |
| 43 | + if (sessionStorage.getItem('domainNoticeClosed')) return; |
| 44 | + |
42 | 45 | // 创建提示条容器 |
43 | 46 | const div = document.createElement('div'); |
44 | 47 | div.id = 'domain-notice'; |
|
47 | 50 | <div class="domain-notice-inner"> |
48 | 51 | <p> |
49 | 52 | 提示:本站域名已由 |
50 | | - <a href="https://imas-sp.com" target="_blank" style="color:#ffd700;text-decoration:underline;">imas-sp.com</a> |
| 53 | + <a href="https://imas-sp.com" target="_blank" style="color:#ffd700;text-decoration:underline;">imas-sp.com</a> |
51 | 54 | 迁移至 |
52 | | - <a href="https://sp.idolmaster.top" target="_blank" style="color:#ffd700;text-decoration:underline;">sp.idolmaster.top</a>。请更新您的书签。 |
| 55 | + <a href="https://sp.idolmaster.top" target="_blank" style="color:#ffd700;text-decoration:underline;">sp.idolmaster.top</a>。 |
| 56 | + 请更新您的书签。 |
53 | 57 | </p> |
54 | 58 | <button id="close-domain-notice">我知道了</button> |
55 | 59 | </div> |
56 | 60 | `; |
57 | 61 | document.body.appendChild(div); |
58 | 62 |
|
59 | | - // 样式(含过渡) |
| 63 | + // 样式 |
60 | 64 | const style = document.createElement('style'); |
61 | 65 | style.innerHTML = ` |
62 | 66 | #domain-notice { |
|
115 | 119 | }); |
116 | 120 |
|
117 | 121 | // 隐藏函数 |
118 | | - let hideTimer = null; |
119 | 122 | function hide(immediate = false) { |
120 | 123 | const inner = document.querySelector('.domain-notice-inner'); |
121 | 124 | if (!inner) return; |
|
124 | 127 | } |
125 | 128 | inner.style.transform = 'translateY(120%)'; |
126 | 129 | inner.style.opacity = '0'; |
127 | | - clearTimeout(hideTimer); |
128 | 130 | setTimeout(() => { |
129 | 131 | const container = document.getElementById('domain-notice'); |
130 | 132 | if (container) container.remove(); |
131 | 133 | }, 320); |
132 | 134 | } |
133 | 135 |
|
134 | | - // 自动 3 秒隐藏 |
135 | | - const autoHideTimeout = 3000; |
136 | | - hideTimer = setTimeout(() => hide(false), autoHideTimeout); |
137 | | - |
138 | | - // 点击按钮立即隐藏 |
| 136 | + // 点击“我知道了”关闭提示,并标记为已关闭(仅当前会话) |
139 | 137 | document.getElementById('close-domain-notice').addEventListener('click', () => { |
140 | | - clearTimeout(hideTimer); |
| 138 | + sessionStorage.setItem('domainNoticeClosed', '1'); |
141 | 139 | hide(true); |
142 | 140 | }); |
143 | 141 |
|
|
0 commit comments