2026-10-16-web-admin-version-refresh-demo.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>web-admin · 发版后提示刷新 Demo</title>
  7. <link rel="preconnect" href="https://fonts.googleapis.com" />
  8. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  9. <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
  10. <style>
  11. :root {
  12. --primary: #10b981;
  13. --primary-dark: #059669;
  14. --primary-bg: #ecfdf5;
  15. --text: #1e293b;
  16. --text-muted: #64748b;
  17. --border: #d9e8e2;
  18. --bg-page: #fefefe;
  19. --surface: #ffffff;
  20. --table-head: #f7faf8;
  21. --row-alt: #f1f5f9;
  22. --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  23. --radius: 10px;
  24. --warn: #d97706;
  25. --warn-bg: #fffbeb;
  26. --mask: rgba(15, 23, 42, 0.35);
  27. }
  28. * { box-sizing: border-box; margin: 0; padding: 0; }
  29. body {
  30. font-family: Inter, -apple-system, sans-serif;
  31. font-size: 14px;
  32. line-height: 1.5;
  33. color: var(--text);
  34. background: #0f172a;
  35. min-height: 100vh;
  36. padding: 28px 20px 48px;
  37. }
  38. .page-head {
  39. max-width: 1100px;
  40. margin: 0 auto 20px;
  41. text-align: center;
  42. color: #fff;
  43. }
  44. .page-head h1 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
  45. .page-head p {
  46. color: #94a3b8;
  47. font-size: 13px;
  48. max-width: 640px;
  49. margin: 0 auto;
  50. }
  51. .controls {
  52. max-width: 1100px;
  53. margin: 0 auto 16px;
  54. display: flex;
  55. flex-wrap: wrap;
  56. gap: 8px;
  57. justify-content: center;
  58. }
  59. .controls button {
  60. appearance: none;
  61. border: 1px solid #334155;
  62. background: #1e293b;
  63. color: #e2e8f0;
  64. border-radius: 8px;
  65. padding: 8px 14px;
  66. font-size: 13px;
  67. font-family: inherit;
  68. cursor: pointer;
  69. transition: border-color .15s, background .15s;
  70. }
  71. .controls button:hover { border-color: var(--primary); }
  72. .controls button.is-active {
  73. background: var(--primary-bg);
  74. border-color: var(--primary);
  75. color: var(--primary-dark);
  76. font-weight: 600;
  77. }
  78. .stage-wrap {
  79. max-width: 1100px;
  80. margin: 0 auto;
  81. border-radius: 14px;
  82. overflow: hidden;
  83. box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  84. border: 1px solid #334155;
  85. background: var(--bg-page);
  86. position: relative;
  87. min-height: 560px;
  88. }
  89. /* —— 仿管理端壳 —— */
  90. .shell { display: flex; min-height: 560px; }
  91. .sidebar {
  92. width: 200px;
  93. flex-shrink: 0;
  94. background: var(--surface);
  95. border-right: 1px solid var(--border);
  96. padding: 20px 14px;
  97. }
  98. .brand {
  99. font-weight: 700;
  100. font-size: 15px;
  101. color: var(--primary-dark);
  102. margin-bottom: 20px;
  103. padding: 0 6px;
  104. }
  105. .nav-item {
  106. padding: 9px 10px;
  107. border-radius: 8px;
  108. color: var(--text-muted);
  109. font-size: 13px;
  110. margin-bottom: 4px;
  111. }
  112. .nav-item.is-active {
  113. background: var(--primary-bg);
  114. color: var(--primary-dark);
  115. font-weight: 600;
  116. }
  117. .main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  118. .topbar {
  119. height: 52px;
  120. border-bottom: 1px solid var(--border);
  121. background: var(--surface);
  122. display: flex;
  123. align-items: center;
  124. justify-content: space-between;
  125. padding: 0 20px;
  126. font-size: 13px;
  127. color: var(--text-muted);
  128. }
  129. .topbar .user { color: var(--text); font-weight: 500; }
  130. .content { padding: 20px; flex: 1; }
  131. .panel {
  132. background: var(--surface);
  133. border: 1px solid var(--border);
  134. border-radius: var(--radius);
  135. box-shadow: var(--shadow);
  136. overflow: hidden;
  137. }
  138. .panel-top {
  139. padding: 14px 16px;
  140. border-bottom: 1px solid var(--border);
  141. background: var(--table-head);
  142. }
  143. .panel-top h2 {
  144. font-size: 15px;
  145. font-weight: 600;
  146. display: flex;
  147. align-items: center;
  148. gap: 8px;
  149. }
  150. .panel-top h2::before {
  151. content: "";
  152. width: 3px;
  153. height: 14px;
  154. border-radius: 2px;
  155. background: var(--primary);
  156. }
  157. .toolbar {
  158. padding: 10px 16px;
  159. display: flex;
  160. align-items: center;
  161. gap: 10px;
  162. border-bottom: 1px solid var(--border);
  163. font-size: 13px;
  164. color: var(--text-muted);
  165. }
  166. .btn {
  167. appearance: none;
  168. border: 1px solid var(--border);
  169. background: var(--surface);
  170. color: var(--text);
  171. border-radius: 8px;
  172. height: 32px;
  173. padding: 0 12px;
  174. font-size: 13px;
  175. font-family: inherit;
  176. cursor: pointer;
  177. display: inline-flex;
  178. align-items: center;
  179. gap: 6px;
  180. }
  181. .btn-main {
  182. background: var(--primary);
  183. border-color: var(--primary);
  184. color: #fff;
  185. font-weight: 500;
  186. }
  187. .btn-main:hover { background: var(--primary-dark); }
  188. table { width: 100%; border-collapse: collapse; font-size: 13px; }
  189. th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
  190. th { background: var(--table-head); color: var(--text-muted); font-weight: 500; }
  191. tr:nth-child(even) td { background: var(--row-alt); }
  192. .tag {
  193. display: inline-block;
  194. padding: 2px 8px;
  195. border-radius: 4px;
  196. font-size: 12px;
  197. background: #059669;
  198. color: #fff;
  199. }
  200. .version-chip {
  201. font-size: 11px;
  202. color: var(--text-muted);
  203. background: var(--row-alt);
  204. border: 1px solid var(--border);
  205. border-radius: 999px;
  206. padding: 2px 8px;
  207. }
  208. /* —— A:强制弹窗 —— */
  209. .overlay {
  210. position: absolute;
  211. inset: 0;
  212. background: var(--mask);
  213. display: none;
  214. align-items: center;
  215. justify-content: center;
  216. z-index: 40;
  217. backdrop-filter: none;
  218. }
  219. .overlay.is-on { display: flex; }
  220. .dialog {
  221. width: 420px;
  222. max-width: calc(100% - 40px);
  223. background: var(--surface);
  224. border-radius: var(--radius);
  225. box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
  226. overflow: hidden;
  227. animation: pop .2s ease-out;
  228. }
  229. @keyframes pop {
  230. from { opacity: 0; transform: translateY(8px) scale(0.98); }
  231. to { opacity: 1; transform: none; }
  232. }
  233. .dialog-body { padding: 24px 24px 8px; }
  234. .dialog-icon {
  235. width: 44px;
  236. height: 44px;
  237. border-radius: 12px;
  238. background: var(--primary-bg);
  239. color: var(--primary-dark);
  240. display: flex;
  241. align-items: center;
  242. justify-content: center;
  243. font-size: 22px;
  244. margin-bottom: 14px;
  245. }
  246. .dialog-body h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
  247. .dialog-body p { color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
  248. .dialog-meta {
  249. margin-top: 12px;
  250. padding: 10px 12px;
  251. background: var(--table-head);
  252. border-radius: 8px;
  253. font-size: 12px;
  254. color: var(--text-muted);
  255. display: flex;
  256. justify-content: space-between;
  257. gap: 12px;
  258. }
  259. .dialog-meta strong { color: var(--text); font-weight: 600; }
  260. .dialog-footer {
  261. padding: 16px 24px 20px;
  262. display: flex;
  263. justify-content: flex-end;
  264. gap: 10px;
  265. }
  266. /* —— B:顶部横幅 —— */
  267. .banner {
  268. display: none;
  269. align-items: center;
  270. gap: 12px;
  271. padding: 10px 16px;
  272. background: var(--warn-bg);
  273. border-bottom: 1px solid rgba(217, 119, 6, 0.25);
  274. color: #92400e;
  275. font-size: 13px;
  276. z-index: 30;
  277. }
  278. .banner.is-on { display: flex; }
  279. .banner .dot {
  280. width: 8px;
  281. height: 8px;
  282. border-radius: 50%;
  283. background: var(--warn);
  284. flex-shrink: 0;
  285. animation: pulse 1.4s ease-in-out infinite;
  286. }
  287. @keyframes pulse {
  288. 0%, 100% { opacity: 1; }
  289. 50% { opacity: 0.35; }
  290. }
  291. .banner .msg { flex: 1; min-width: 0; }
  292. .banner .msg strong { color: #b45309; }
  293. .banner .actions { display: flex; gap: 8px; flex-shrink: 0; }
  294. .btn-warn {
  295. background: var(--warn);
  296. border-color: var(--warn);
  297. color: #fff;
  298. height: 28px;
  299. padding: 0 10px;
  300. font-size: 12px;
  301. }
  302. .btn-ghost {
  303. background: transparent;
  304. border-color: rgba(217, 119, 6, 0.35);
  305. color: #92400e;
  306. height: 28px;
  307. padding: 0 10px;
  308. font-size: 12px;
  309. }
  310. /* —— C:右下角通知 —— */
  311. .toast {
  312. position: absolute;
  313. right: 20px;
  314. bottom: 20px;
  315. width: 360px;
  316. max-width: calc(100% - 40px);
  317. background: var(--surface);
  318. border: 1px solid var(--border);
  319. border-radius: var(--radius);
  320. box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  321. padding: 14px 16px;
  322. display: none;
  323. z-index: 35;
  324. animation: slideUp .22s ease-out;
  325. }
  326. .toast.is-on { display: block; }
  327. @keyframes slideUp {
  328. from { opacity: 0; transform: translateY(12px); }
  329. to { opacity: 1; transform: none; }
  330. }
  331. .toast-top {
  332. display: flex;
  333. align-items: flex-start;
  334. gap: 10px;
  335. margin-bottom: 10px;
  336. }
  337. .toast-icon {
  338. width: 32px;
  339. height: 32px;
  340. border-radius: 8px;
  341. background: var(--primary-bg);
  342. color: var(--primary-dark);
  343. display: flex;
  344. align-items: center;
  345. justify-content: center;
  346. flex-shrink: 0;
  347. font-size: 16px;
  348. }
  349. .toast h4 { font-size: 14px; font-weight: 600; }
  350. .toast p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
  351. .toast-actions {
  352. display: flex;
  353. justify-content: flex-end;
  354. gap: 8px;
  355. }
  356. .toast .btn { height: 28px; font-size: 12px; padding: 0 10px; }
  357. .legend {
  358. max-width: 1100px;
  359. margin: 18px auto 0;
  360. color: #94a3b8;
  361. font-size: 12px;
  362. line-height: 1.7;
  363. text-align: center;
  364. }
  365. .legend code {
  366. background: #1e293b;
  367. color: #cbd5e1;
  368. padding: 1px 6px;
  369. border-radius: 4px;
  370. font-size: 11px;
  371. }
  372. @media (max-width: 800px) {
  373. .sidebar { display: none; }
  374. .banner { flex-wrap: wrap; }
  375. }
  376. </style>
  377. </head>
  378. <body>
  379. <div class="page-head">
  380. <h1>web-admin · 发版后「请刷新」交互 Demo</h1>
  381. <p>
  382. 模拟客户长时间不关标签页、仍跑旧前端的场景。下面三种提示样式可切换对比;
  383. Token 对齐 Fresh Mint(<code style="color:#a7f3d0">#10b981</code>)。
  384. </p>
  385. </div>
  386. <div class="controls" role="tablist" aria-label="提示样式">
  387. <button type="button" class="is-active" data-mode="force" aria-pressed="true">A · 强制弹窗(推荐)</button>
  388. <button type="button" data-mode="banner" aria-pressed="false">B · 顶部横幅(可稍后)</button>
  389. <button type="button" data-mode="toast" aria-pressed="false">C · 右下角通知</button>
  390. <button type="button" data-mode="none" aria-pressed="false">隐藏提示</button>
  391. </div>
  392. <div class="stage-wrap" id="stage">
  393. <!-- B: banner sits above shell content -->
  394. <div class="banner" id="banner" role="status">
  395. <span class="dot" aria-hidden="true"></span>
  396. <div class="msg">
  397. <strong>系统已更新</strong>
  398. — 检测到新版本 <strong>3.0.3</strong>(当前页面仍为 3.0.2),请刷新以使用最新功能。
  399. </div>
  400. <div class="actions">
  401. <button type="button" class="btn btn-ghost" data-action="later">稍后</button>
  402. <button type="button" class="btn btn-warn" data-action="reload">立即刷新</button>
  403. </div>
  404. </div>
  405. <div class="shell">
  406. <aside class="sidebar">
  407. <div class="brand">山峡化工 · 门户</div>
  408. <div class="nav-item is-active">订单列表</div>
  409. <div class="nav-item">商品管理</div>
  410. <div class="nav-item">单位管理</div>
  411. <div class="nav-item">系统用户</div>
  412. </aside>
  413. <div class="main">
  414. <header class="topbar">
  415. <span>工作台 / 订单列表</span>
  416. <span>
  417. <span class="version-chip" title="页面内嵌版本">页面 v3.0.2</span>
  418. &nbsp;&nbsp;
  419. <span class="user">张三</span>
  420. </span>
  421. </header>
  422. <div class="content">
  423. <div class="panel">
  424. <div class="panel-top"><h2>订单列表</h2></div>
  425. <div class="toolbar">
  426. <span>已选 0 项</span>
  427. <button type="button" class="btn btn-main">新增订单</button>
  428. <button type="button" class="btn">导出</button>
  429. </div>
  430. <table>
  431. <thead>
  432. <tr>
  433. <th>订单号</th>
  434. <th>客户</th>
  435. <th>状态</th>
  436. <th>金额</th>
  437. </tr>
  438. </thead>
  439. <tbody>
  440. <tr>
  441. <td>SO20261016001</td>
  442. <td>华中物流</td>
  443. <td><span class="tag">配送中</span></td>
  444. <td>¥12,800</td>
  445. </tr>
  446. <tr>
  447. <td>SO20261016002</td>
  448. <td>海河化工</td>
  449. <td><span class="tag">已完成</span></td>
  450. <td>¥6,420</td>
  451. </tr>
  452. <tr>
  453. <td>SO20261015088</td>
  454. <td>金桥供应链</td>
  455. <td><span class="tag">待发货</span></td>
  456. <td>¥9,150</td>
  457. </tr>
  458. </tbody>
  459. </table>
  460. </div>
  461. </div>
  462. </div>
  463. </div>
  464. <!-- A: force modal -->
  465. <div class="overlay is-on" id="overlay" role="dialog" aria-modal="true" aria-labelledby="dlg-title">
  466. <div class="dialog">
  467. <div class="dialog-body">
  468. <div class="dialog-icon" aria-hidden="true">↻</div>
  469. <h3 id="dlg-title">发现新版本</h3>
  470. <p>系统已发布更新,当前页面仍在使用旧功能。请刷新后继续操作,避免数据与界面不一致。</p>
  471. <div class="dialog-meta">
  472. <span>当前:<strong>v3.0.2</strong></span>
  473. <span>最新:<strong>v3.0.3</strong></span>
  474. </div>
  475. </div>
  476. <div class="dialog-footer">
  477. <!-- 强制模式:无「取消 / 稍后」 -->
  478. <button type="button" class="btn btn-main" data-action="reload">立即刷新</button>
  479. </div>
  480. </div>
  481. </div>
  482. <!-- C: corner toast -->
  483. <div class="toast" id="toast" role="status">
  484. <div class="toast-top">
  485. <div class="toast-icon" aria-hidden="true">↻</div>
  486. <div>
  487. <h4>有可用更新</h4>
  488. <p>新版本 v3.0.3 已上线,刷新即可使用最新功能。</p>
  489. </div>
  490. </div>
  491. <div class="toast-actions">
  492. <button type="button" class="btn" data-action="later">稍后</button>
  493. <button type="button" class="btn btn-main" data-action="reload">立即刷新</button>
  494. </div>
  495. </div>
  496. </div>
  497. <p class="legend">
  498. <strong style="color:#e2e8f0">对比要点</strong>:
  499. A 强制弹窗不可稍后(与小程序强制更新一致,适合破坏性发版);
  500. B 顶部横幅不打断当前填表,适合非紧急;
  501. C 右下角最轻,容易被忽略。
  502. 检测侧通常对比本地 <code>__APP_VERSION__</code> / 构建产物 hash 与服务器上的 <code>version.json</code>。
  503. </p>
  504. <script>
  505. (function () {
  506. var overlay = document.getElementById('overlay')
  507. var banner = document.getElementById('banner')
  508. var toast = document.getElementById('toast')
  509. var buttons = document.querySelectorAll('.controls button[data-mode]')
  510. function setMode(mode) {
  511. overlay.classList.toggle('is-on', mode === 'force')
  512. banner.classList.toggle('is-on', mode === 'banner')
  513. toast.classList.toggle('is-on', mode === 'toast')
  514. buttons.forEach(function (btn) {
  515. var on = btn.getAttribute('data-mode') === mode
  516. btn.classList.toggle('is-active', on)
  517. btn.setAttribute('aria-pressed', on ? 'true' : 'false')
  518. })
  519. }
  520. buttons.forEach(function (btn) {
  521. btn.addEventListener('click', function () {
  522. setMode(btn.getAttribute('data-mode'))
  523. })
  524. })
  525. document.getElementById('stage').addEventListener('click', function (e) {
  526. var t = e.target
  527. if (!(t instanceof HTMLElement)) return
  528. var action = t.getAttribute('data-action')
  529. if (action === 'reload') {
  530. alert('Demo:实际实现会执行 location.reload()(或带 cache-bust 的硬刷新)')
  531. }
  532. if (action === 'later') {
  533. setMode('none')
  534. }
  535. })
  536. })()
  537. </script>
  538. </body>
  539. </html>