portal-worktab-style-demo.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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" />
  6. <title>门户 WorkTab 样式对比 Demo</title>
  7. <style>
  8. :root {
  9. --primary: #10b981;
  10. --primary-dark: #059669;
  11. --primary-bg: #ecfdf5;
  12. --header: #1ca851;
  13. --text: #0f172a;
  14. --muted: #64748b;
  15. --border: #e2e8f0;
  16. --surface: #ffffff;
  17. --bg: #f1f5f9;
  18. --row-alt: #f8fafc;
  19. }
  20. * { box-sizing: border-box; }
  21. body {
  22. margin: 0;
  23. font-family: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  24. color: var(--text);
  25. background: #f8fafc;
  26. line-height: 1.5;
  27. }
  28. .page { padding: 20px 24px 64px; max-width: 1180px; margin: 0 auto; }
  29. h1 { font-size: 22px; margin: 0 0 6px; }
  30. .lead { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
  31. .ok {
  32. background: var(--primary-bg);
  33. border: 1px solid #a7f3d0;
  34. color: #065f46;
  35. border-radius: 10px;
  36. padding: 10px 14px;
  37. font-size: 13px;
  38. margin-bottom: 16px;
  39. }
  40. .picker {
  41. display: flex;
  42. flex-wrap: wrap;
  43. gap: 8px;
  44. margin-bottom: 18px;
  45. }
  46. .picker button {
  47. appearance: none;
  48. border: 1px solid var(--border);
  49. background: #fff;
  50. color: var(--text);
  51. border-radius: 999px;
  52. padding: 7px 14px;
  53. font-size: 13px;
  54. font-weight: 600;
  55. cursor: pointer;
  56. }
  57. .picker button.is-on {
  58. background: var(--primary-bg);
  59. border-color: #a7f3d0;
  60. color: var(--primary-dark);
  61. }
  62. .stage-meta {
  63. display: flex;
  64. justify-content: space-between;
  65. gap: 12px;
  66. align-items: baseline;
  67. margin: 0 0 8px;
  68. }
  69. .stage-meta h2 { margin: 0; font-size: 16px; }
  70. .stage-meta span { font-size: 12px; color: var(--muted); }
  71. .frame {
  72. border: 1px solid var(--border);
  73. border-radius: 12px;
  74. overflow: hidden;
  75. background: var(--bg);
  76. box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  77. margin-bottom: 28px;
  78. }
  79. /* 共用门户顶栏 */
  80. .portal-header {
  81. display: flex;
  82. align-items: center;
  83. gap: 10px;
  84. height: 56px;
  85. padding: 0 20px;
  86. background: var(--header);
  87. color: #fff;
  88. }
  89. .brand {
  90. display: flex;
  91. align-items: center;
  92. gap: 10px;
  93. font-weight: 600;
  94. font-size: 16px;
  95. }
  96. .brand-mark {
  97. width: 28px;
  98. height: 28px;
  99. border-radius: 8px;
  100. background: rgba(255,255,255,0.2);
  101. display: grid;
  102. place-items: center;
  103. font-size: 12px;
  104. font-weight: 700;
  105. }
  106. .spacer { flex: 1; }
  107. .user-chip {
  108. width: 32px;
  109. height: 32px;
  110. border-radius: 999px;
  111. background: rgba(255,255,255,0.22);
  112. display: grid;
  113. place-items: center;
  114. font-size: 12px;
  115. font-weight: 600;
  116. }
  117. .workspace {
  118. min-height: 220px;
  119. padding: 16px 20px 20px;
  120. }
  121. .fake-panel {
  122. background: #fff;
  123. border: 1px solid var(--border);
  124. border-radius: 10px;
  125. padding: 16px 18px;
  126. min-height: 140px;
  127. }
  128. .fake-panel h3 {
  129. margin: 0 0 6px;
  130. font-size: 16px;
  131. }
  132. .fake-panel p {
  133. margin: 0;
  134. color: var(--muted);
  135. font-size: 13px;
  136. }
  137. /* ========== 方案 A:文件夹页签(现状 / Fresh Mint 原文) ========== */
  138. .a-strip {
  139. display: flex;
  140. align-items: flex-end;
  141. gap: 8px;
  142. padding: 8px 20px 0;
  143. background: #fff;
  144. border-bottom: 1px solid var(--border);
  145. }
  146. .a-tabs {
  147. display: flex;
  148. flex: 1;
  149. align-items: flex-end;
  150. gap: 4px;
  151. padding: 0 2px 10px;
  152. overflow: hidden;
  153. }
  154. .a-chip {
  155. appearance: none;
  156. border: 1px solid var(--border);
  157. background: #fff;
  158. color: var(--muted);
  159. font-size: 13px;
  160. font-weight: 600;
  161. padding: 8px 14px;
  162. border-radius: 8px 8px 0 0;
  163. cursor: pointer;
  164. margin-bottom: -11px;
  165. max-width: 180px;
  166. display: inline-flex;
  167. align-items: center;
  168. gap: 6px;
  169. white-space: nowrap;
  170. }
  171. .a-chip:hover { color: var(--text); background: var(--row-alt); }
  172. .a-chip.is-active {
  173. color: var(--primary-dark);
  174. border-bottom-color: #fff;
  175. box-shadow: 0 -2px 0 var(--primary) inset;
  176. z-index: 2;
  177. }
  178. .a-x {
  179. appearance: none;
  180. border: 0;
  181. background: transparent;
  182. color: inherit;
  183. opacity: 0.55;
  184. cursor: pointer;
  185. border-radius: 999px;
  186. width: 18px;
  187. height: 18px;
  188. line-height: 1;
  189. font-size: 14px;
  190. padding: 0;
  191. }
  192. .a-x:hover { opacity: 1; background: var(--row-alt); }
  193. .a-more {
  194. width: 32px;
  195. height: 32px;
  196. margin-bottom: 8px;
  197. border: 1px solid var(--border);
  198. border-radius: 8px;
  199. background: #fff;
  200. color: var(--muted);
  201. cursor: pointer;
  202. }
  203. /* ========== 方案 B:浅底胶囊(推荐) ========== */
  204. .b-strip {
  205. display: flex;
  206. align-items: center;
  207. gap: 8px;
  208. min-height: 44px;
  209. padding: 6px 16px;
  210. background: #f8fafc;
  211. border-bottom: 1px solid var(--border);
  212. }
  213. .b-tabs {
  214. display: flex;
  215. flex: 1;
  216. align-items: center;
  217. gap: 6px;
  218. overflow: hidden;
  219. min-width: 0;
  220. }
  221. .b-chip {
  222. appearance: none;
  223. border: 1px solid transparent;
  224. background: transparent;
  225. color: var(--muted);
  226. font-size: 13px;
  227. font-weight: 500;
  228. padding: 6px 10px 6px 12px;
  229. border-radius: 8px;
  230. cursor: pointer;
  231. max-width: 180px;
  232. display: inline-flex;
  233. align-items: center;
  234. gap: 6px;
  235. white-space: nowrap;
  236. transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  237. }
  238. .b-chip:hover {
  239. color: var(--text);
  240. background: #fff;
  241. border-color: var(--border);
  242. }
  243. .b-chip.is-active {
  244. color: var(--primary-dark);
  245. background: #fff;
  246. border-color: #a7f3d0;
  247. box-shadow: 0 1px 2px rgba(16, 185, 129, 0.08);
  248. font-weight: 600;
  249. }
  250. .b-chip.is-home.is-active {
  251. background: var(--primary-bg);
  252. }
  253. .b-x {
  254. appearance: none;
  255. border: 0;
  256. background: transparent;
  257. width: 18px;
  258. height: 18px;
  259. border-radius: 999px;
  260. color: var(--muted);
  261. cursor: pointer;
  262. font-size: 14px;
  263. line-height: 1;
  264. padding: 0;
  265. opacity: 0;
  266. }
  267. .b-chip:hover .b-x,
  268. .b-chip.is-active .b-x { opacity: 0.75; }
  269. .b-x:hover { opacity: 1 !important; background: var(--row-alt); color: var(--text); }
  270. .b-more {
  271. width: 30px;
  272. height: 30px;
  273. border: 1px solid var(--border);
  274. border-radius: 8px;
  275. background: #fff;
  276. color: var(--muted);
  277. cursor: pointer;
  278. flex-shrink: 0;
  279. }
  280. .b-more:hover {
  281. color: var(--primary-dark);
  282. border-color: #a7f3d0;
  283. background: var(--primary-bg);
  284. }
  285. /* ========== 方案 C:底线指示(极简) ========== */
  286. .c-strip {
  287. display: flex;
  288. align-items: stretch;
  289. gap: 4px;
  290. min-height: 42px;
  291. padding: 0 12px;
  292. background: #fff;
  293. border-bottom: 1px solid var(--border);
  294. }
  295. .c-tabs {
  296. display: flex;
  297. flex: 1;
  298. align-items: stretch;
  299. gap: 2px;
  300. overflow: hidden;
  301. min-width: 0;
  302. }
  303. .c-chip {
  304. appearance: none;
  305. border: 0;
  306. background: transparent;
  307. color: var(--muted);
  308. font-size: 13px;
  309. font-weight: 500;
  310. padding: 0 12px;
  311. cursor: pointer;
  312. max-width: 180px;
  313. display: inline-flex;
  314. align-items: center;
  315. gap: 8px;
  316. white-space: nowrap;
  317. position: relative;
  318. border-radius: 0;
  319. }
  320. .c-chip:hover { color: var(--text); background: var(--row-alt); }
  321. .c-chip.is-active {
  322. color: var(--primary-dark);
  323. font-weight: 600;
  324. }
  325. .c-chip.is-active::after {
  326. content: "";
  327. position: absolute;
  328. left: 10px;
  329. right: 10px;
  330. bottom: 0;
  331. height: 2px;
  332. border-radius: 2px 2px 0 0;
  333. background: var(--primary);
  334. }
  335. .c-x {
  336. appearance: none;
  337. border: 0;
  338. background: transparent;
  339. width: 16px;
  340. height: 16px;
  341. border-radius: 999px;
  342. color: inherit;
  343. cursor: pointer;
  344. opacity: 0;
  345. font-size: 13px;
  346. padding: 0;
  347. }
  348. .c-chip:hover .c-x { opacity: 0.7; }
  349. .c-x:hover { opacity: 1; background: #e2e8f0; }
  350. .c-more {
  351. align-self: center;
  352. width: 30px;
  353. height: 30px;
  354. border: 0;
  355. border-radius: 8px;
  356. background: transparent;
  357. color: var(--muted);
  358. cursor: pointer;
  359. }
  360. .c-more:hover { background: var(--row-alt); color: var(--text); }
  361. /* ========== 方案 D:分段条(工具栏感) ========== */
  362. .d-strip {
  363. display: flex;
  364. align-items: center;
  365. gap: 10px;
  366. padding: 8px 16px;
  367. background: #fff;
  368. border-bottom: 1px solid var(--border);
  369. }
  370. .d-tabs {
  371. display: flex;
  372. flex: 1;
  373. align-items: center;
  374. gap: 0;
  375. min-width: 0;
  376. overflow: hidden;
  377. padding: 3px;
  378. background: #f1f5f9;
  379. border-radius: 10px;
  380. border: 1px solid var(--border);
  381. }
  382. .d-chip {
  383. appearance: none;
  384. border: 0;
  385. background: transparent;
  386. color: var(--muted);
  387. font-size: 13px;
  388. font-weight: 500;
  389. padding: 7px 12px;
  390. border-radius: 8px;
  391. cursor: pointer;
  392. max-width: 160px;
  393. display: inline-flex;
  394. align-items: center;
  395. gap: 6px;
  396. white-space: nowrap;
  397. }
  398. .d-chip:hover { color: var(--text); }
  399. .d-chip.is-active {
  400. color: var(--primary-dark);
  401. background: #fff;
  402. font-weight: 600;
  403. box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  404. }
  405. .d-x {
  406. appearance: none;
  407. border: 0;
  408. background: transparent;
  409. width: 16px;
  410. height: 16px;
  411. border-radius: 999px;
  412. color: inherit;
  413. cursor: pointer;
  414. opacity: 0;
  415. font-size: 13px;
  416. padding: 0;
  417. }
  418. .d-chip:hover .d-x,
  419. .d-chip.is-active .d-x { opacity: 0.7; }
  420. .d-x:hover { opacity: 1; background: var(--row-alt); }
  421. .d-more {
  422. width: 32px;
  423. height: 32px;
  424. border: 1px solid var(--border);
  425. border-radius: 8px;
  426. background: #fff;
  427. color: var(--muted);
  428. cursor: pointer;
  429. flex-shrink: 0;
  430. }
  431. .hidden { display: none !important; }
  432. .pros {
  433. margin: 0;
  434. padding-left: 18px;
  435. font-size: 13px;
  436. color: var(--muted);
  437. }
  438. .pros li { margin: 4px 0; }
  439. .rec {
  440. display: inline-block;
  441. margin-left: 8px;
  442. padding: 1px 8px;
  443. border-radius: 999px;
  444. background: var(--primary-bg);
  445. color: var(--primary-dark);
  446. font-size: 11px;
  447. font-weight: 700;
  448. vertical-align: middle;
  449. }
  450. </style>
  451. </head>
  452. <body>
  453. <div class="page">
  454. <h1>门户 WorkTab 样式对比</h1>
  455. <p class="lead">
  456. 绿顶栏下方的「已打开菜单」页签。点击下方方案切换预览;页签可点选,关闭钮仅示意。
  457. 色值仍用 Fresh Mint(主色 <code>#10b981</code> / 顶栏 <code>#1ca851</code>)。
  458. </p>
  459. <div class="ok">
  460. <strong>已采用方案 B(浅底胶囊)</strong>:已落地
  461. <code>web-admin/.../art-work-tab/index.vue</code>。灰底条分层、激活白底+薄荷绿边、关闭钮 hover 才显。
  462. </div>
  463. <div class="picker" id="picker">
  464. <button type="button" data-style="a">A · 文件夹页签</button>
  465. <button type="button" data-style="b" class="is-on">B · 浅底胶囊 <span class="rec">推荐</span></button>
  466. <button type="button" data-style="c">C · 底线指示</button>
  467. <button type="button" data-style="d">D · 分段条</button>
  468. </div>
  469. <div class="stage-meta">
  470. <h2 id="styleTitle">B · 浅底胶囊</h2>
  471. <span>门户壳:顶栏 56px + Tab 条 + 内容区</span>
  472. </div>
  473. <div class="frame" id="stage">
  474. <header class="portal-header">
  475. <div class="brand">
  476. <div class="brand-mark">SX</div>
  477. <span>山峡化工一体化门户</span>
  478. </div>
  479. <div class="spacer"></div>
  480. <div class="user-chip">管</div>
  481. </header>
  482. <!-- A -->
  483. <div class="a-strip style-panel" data-panel="a">
  484. <div class="a-tabs" data-tabs></div>
  485. <button type="button" class="a-more" title="更多">▾</button>
  486. </div>
  487. <!-- B -->
  488. <div class="b-strip style-panel" data-panel="b">
  489. <div class="b-tabs" data-tabs></div>
  490. <button type="button" class="b-more" title="更多">▾</button>
  491. </div>
  492. <!-- C -->
  493. <div class="c-strip style-panel hidden" data-panel="c">
  494. <div class="c-tabs" data-tabs></div>
  495. <button type="button" class="c-more" title="更多">▾</button>
  496. </div>
  497. <!-- D -->
  498. <div class="d-strip style-panel hidden" data-panel="d">
  499. <div class="d-tabs" data-tabs></div>
  500. <button type="button" class="d-more" title="更多">▾</button>
  501. </div>
  502. <div class="workspace">
  503. <div class="fake-panel">
  504. <h3 id="pageTitle">首页</h3>
  505. <p id="pageDesc">当前为菜单启动器 / 业务页占位。切换上方 Tab 查看激活态。</p>
  506. </div>
  507. </div>
  508. </div>
  509. <ul class="pros" id="pros">
  510. <li>灰底条与绿顶栏分层清楚,不抢主色</li>
  511. <li>激活:白底 + 薄荷绿边,轻阴影,信息密度适中</li>
  512. <li>关闭钮默认隐藏,hover / 激活才出现,条面更干净</li>
  513. </ul>
  514. </div>
  515. <script>
  516. var TABS = [
  517. { id: 'home', title: '首页', fixed: true },
  518. { id: 'customer', title: '客户管理', fixed: false },
  519. { id: 'contract', title: '合同管理', fixed: false },
  520. { id: 'product', title: '产品管理', fixed: false },
  521. { id: 'plan', title: '运输计划', fixed: false },
  522. { id: 'weigh', title: '地磅过磅', fixed: false }
  523. ]
  524. var META = {
  525. a: {
  526. title: 'A · 文件夹页签',
  527. pros: [
  528. '与 Fresh Mint HTML demo 原文一致',
  529. '「页签叠在内容上」的隐喻强',
  530. '缺点:在绿顶栏下容易显得厚重、像假浏览器'
  531. ]
  532. },
  533. b: {
  534. title: 'B · 浅底胶囊',
  535. pros: [
  536. '灰底条与绿顶栏分层清楚,不抢主色',
  537. '激活:白底 + 薄荷绿边,轻阴影,信息密度适中',
  538. '关闭钮默认隐藏,hover / 激活才出现,条面更干净'
  539. ]
  540. },
  541. c: {
  542. title: 'C · 底线指示',
  543. pros: [
  544. '最轻:几乎无边框,高度更省',
  545. '适合菜单标题较短、同时打开不多的场景',
  546. '缺点:可点击区域边界弱,密集时辨识度一般'
  547. ]
  548. },
  549. d: {
  550. title: 'D · 分段条',
  551. pros: [
  552. '整组 Tab 收进灰底槽,工具栏感强',
  553. '激活块白底浮起,和筛选分段按钮同语汇',
  554. '缺点:打开很多时槽内容易拥挤'
  555. ]
  556. }
  557. }
  558. var activeStyle = 'b'
  559. var activeId = 'home'
  560. function renderTabs() {
  561. document.querySelectorAll('[data-tabs]').forEach(function (el) {
  562. var style = el.closest('[data-panel]').getAttribute('data-panel')
  563. el.innerHTML = ''
  564. TABS.forEach(function (tab) {
  565. var chip = document.createElement('button')
  566. chip.type = 'button'
  567. chip.className = style + '-chip' + (tab.id === activeId ? ' is-active' : '') + (tab.fixed ? ' is-home' : '')
  568. chip.setAttribute('data-id', tab.id)
  569. var label = document.createElement('span')
  570. label.textContent = tab.title
  571. chip.appendChild(label)
  572. if (!tab.fixed) {
  573. var x = document.createElement('button')
  574. x.type = 'button'
  575. x.className = style + '-x'
  576. x.setAttribute('aria-label', '关闭')
  577. x.textContent = '×'
  578. x.addEventListener('click', function (e) {
  579. e.stopPropagation()
  580. // demo: 关闭后切到首页
  581. if (activeId === tab.id) activeId = 'home'
  582. TABS = TABS.filter(function (t) { return t.id !== tab.id })
  583. renderTabs()
  584. syncPage()
  585. })
  586. chip.appendChild(x)
  587. }
  588. chip.addEventListener('click', function () {
  589. activeId = tab.id
  590. renderTabs()
  591. syncPage()
  592. })
  593. el.appendChild(chip)
  594. })
  595. })
  596. }
  597. function syncPage() {
  598. var tab = TABS.find(function (t) { return t.id === activeId }) || TABS[0]
  599. document.getElementById('pageTitle').textContent = tab.title
  600. document.getElementById('pageDesc').textContent =
  601. tab.fixed
  602. ? '首页启动器:一级标题 + 菜单卡片 + 收藏区(示意)。'
  603. : '业务页占位:列表 / 表单等内容区。'
  604. }
  605. function setStyle(style) {
  606. activeStyle = style
  607. document.querySelectorAll('.picker button').forEach(function (btn) {
  608. btn.classList.toggle('is-on', btn.getAttribute('data-style') === style)
  609. })
  610. document.querySelectorAll('.style-panel').forEach(function (panel) {
  611. panel.classList.toggle('hidden', panel.getAttribute('data-panel') !== style)
  612. })
  613. var meta = META[style]
  614. document.getElementById('styleTitle').textContent = meta.title
  615. document.getElementById('pros').innerHTML = meta.pros
  616. .map(function (p) { return '<li>' + p + '</li>' })
  617. .join('')
  618. }
  619. document.getElementById('picker').addEventListener('click', function (e) {
  620. var btn = e.target.closest('button[data-style]')
  621. if (!btn) return
  622. setStyle(btn.getAttribute('data-style'))
  623. })
  624. setStyle('b')
  625. renderTabs()
  626. syncPage()
  627. </script>
  628. </body>
  629. </html>