index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>原型门户 - 恒隆公寓AMS</title>
  6. <style>
  7. * { margin:0; padding:0; box-sizing:border-box; }
  8. html { overflow-x:hidden; }
  9. body { font-family:"PingFang SC","Microsoft YaHei",sans-serif; font-size:13px; color:#333; background:#f0f2f5; display:flex; height:100vh; overflow:hidden; }
  10. .nav { width:190px; background:#1f2d3d; color:#bfcbd9; flex-shrink:0; overflow-y:auto; }
  11. .nav .logo { height:56px; display:flex; align-items:center; justify-content:center; color:#fff; font-size:14px; font-weight:600; background:#18222e; text-align:center; line-height:1.3; }
  12. .nav .group-title { padding:10px 16px 4px; font-size:11px; color:#7f95ad; }
  13. .nav .item { padding:8px 16px 8px 22px; cursor:pointer; display:flex; justify-content:space-between; }
  14. .nav .item:hover { color:#fff; }
  15. .nav .item.active { color:#fff; background:#2563eb; }
  16. .nav .item .cnt { font-size:11px; color:#7f95ad; }
  17. .nav .item.active .cnt { color:#dbeafe; }
  18. .mid { flex:1; min-width:340px; display:flex; flex-direction:column; }
  19. .topbar { height:56px; background:#fff; border-bottom:1px solid #e4e7ed; display:flex; align-items:center; padding:0 20px; gap:14px; }
  20. .topbar b { font-size:14px; }
  21. .topbar .sub { color:#909399; font-size:12px; flex:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  22. .upd-banner { display:none; align-items:center; gap:10px; background:#fff7ed; border-bottom:1px solid #fdba74;
  23. color:#9a3412; padding:8px 20px; font-size:12.5px; }
  24. .upd-banner.show { display:flex; }
  25. .upd-banner b { color:#c2410c; }
  26. .upd-banner .btn-ok { margin-left:auto; height:26px; padding:0 12px; line-height:24px; border-radius:4px;
  27. border:1px solid #fdba74; background:#fff; color:#b45309; cursor:pointer; font-size:12px; white-space:nowrap; }
  28. .upd-banner .btn-ok:hover { background:#fef3c7; }
  29. .topbar input { height:32px; border:1px solid #dcdfe6; border-radius:4px; padding:0 10px; width:220px; outline:none; }
  30. .topbar input:focus { border-color:#2563eb; }
  31. .topbar a.btn, .topbar .btn { height:30px; padding:0 12px; line-height:28px; border-radius:4px; font-size:12px; cursor:pointer; text-decoration:none; border:1px solid #dcdfe6; color:#606266; background:#fff; white-space:nowrap; }
  32. .list { flex:1; overflow-y:auto; padding:16px 20px; }
  33. .cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:14px; }
  34. .card { background:#fff; border:1px solid #ebeef5; border-radius:8px; padding:14px 16px; cursor:pointer; transition:box-shadow .15s,border-color .15s; }
  35. .card:hover { border-color:#93c5fd; box-shadow:0 2px 10px rgba(37,99,235,.12); }
  36. .card.sel { border-color:#2563eb; box-shadow:0 0 0 2px rgba(37,99,235,.18); }
  37. .card h3 { font-size:14px; margin-bottom:6px; display:flex; align-items:center; gap:8px; }
  38. .card h3 .st { font-size:11px; font-weight:400; color:#2563eb; background:#eff6ff; padding:1px 7px; border-radius:3px; }
  39. .meta-row { color:#909399; font-size:12px; line-height:1.8; }
  40. .meta-row .src { color:#0e7490; cursor:pointer; }
  41. .meta-row a { color:#2563eb; text-decoration:none; }
  42. .meta-row .pend { color:#c0c4cc; }
  43. .card .ops { margin-top:8px; display:flex; gap:8px; }
  44. .card .ops span { font-size:12px; color:#2563eb; }
  45. .card .ops .off { color:#c0c4cc; cursor:default; }
  46. .empty-tip { text-align:center; color:#909399; padding:60px 0; grid-column:1/-1; }
  47. /* 右侧预览 */
  48. .preview { width:46%; min-width:420px; flex-shrink:0; background:#fff; border-left:1px solid #e4e7ed; display:flex; flex-direction:column; }
  49. .preview.off { display:none; }
  50. .pv-head { height:56px; border-bottom:1px solid #ebeef5; display:flex; align-items:center; padding:0 16px; gap:10px; }
  51. .pv-head b { flex:1; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  52. .pv-head .x { cursor:pointer; color:#909399; font-size:17px; padding:0 4px; }
  53. .pv-bar { height:34px; background:#f5f7fa; display:flex; align-items:center; gap:8px; padding:0 12px; font-size:11px; color:#909399; border-bottom:1px solid #ebeef5; }
  54. .pv-bar a { color:#2563eb; text-decoration:none; }
  55. .pv-bar .ph { color:#c0c4cc; }
  56. iframe { flex:1; border:none; width:100%; background:#fff; }
  57. .pv-empty { flex:1; display:flex; align-items:center; justify-content:center; color:#c0c4cc; flex-direction:column; gap:10px; }
  58. </style>
  59. </head>
  60. <body>
  61. <div class="nav">
  62. <div class="logo">恒隆原型库<br><span style="font-size:10px;font-weight:400;color:#7f95ad">补充重构·二开</span></div>
  63. <div class="group-title">全部模块</div>
  64. <div class="item active" data-d="全部">全部 <span class="cnt" id="cntAll"></span></div>
  65. <div class="group-title">业务域</div>
  66. <div id="domains"></div>
  67. </div>
  68. <div class="mid">
  69. <div class="upd-banner" id="updBanner">
  70. 🔔 <b>原型有更新:</b><span id="updText"></span>
  71. <button class="btn-ok" onclick="ackSync()">✔ 我已同步(proto_sync)</button>
  72. </div>
  73. <div class="topbar">
  74. <b>原型门户</b>
  75. <span class="sub" id="subTitle"></span>
  76. <input id="kw" placeholder="搜索页面名称/状态…">
  77. <a class="btn" id="liveBtn" target="_blank">🖥 线上系统</a>
  78. <a class="btn" id="repoBtn" target="_blank">📦 Gogs 仓库</a>
  79. </div>
  80. <div class="list"><div class="cards" id="cards"></div></div>
  81. </div>
  82. <div class="preview off" id="preview">
  83. <div class="pv-head"><b id="pvTitle"></b><a class="btn" id="pvOpen" target="_blank" style="height:28px;line-height:26px;font-size:12px;padding:0 10px;border:1px solid #dcdfe6;border-radius:4px;color:#2563eb;text-decoration:none">新标签打开</a><span class="x" onclick="closePv()">✕</span></div>
  84. <div class="pv-bar" id="pvBar"></div>
  85. <iframe id="pvFrame"></iframe>
  86. <div class="pv-empty" id="pvEmpty"><div style="font-size:36px">👁</div>点击左侧卡片在此预览原型<br><span style="font-size:12px">原型内「ⓘ 逻辑标注」等交互均可在预览中操作</span></div>
  87. </div>
  88. <script src="_meta.js"></script>
  89. <script>
  90. var M = window.PROTO_META, curDomain = "全部", curPage = null;
  91. document.getElementById("subTitle").textContent = M.system + " · " + M.repo.desc;
  92. document.getElementById("repoBtn").href = M.repo.url;
  93. var liveBtn = document.getElementById("liveBtn");
  94. if (M.live.url) { liveBtn.href = M.live.url; } else { liveBtn.title = M.live.note; liveBtn.style.color = "#c0c4cc"; liveBtn.onclick = function () { alert("线上系统地址待登记:编辑 _meta.js 的 live.url"); return false; }; }
  95. /* 域导航 */
  96. var dbox = document.getElementById("domains");
  97. M.domains.forEach(function (d) {
  98. var n = M.pages.filter(function (p) { return p.domain === d; }).length;
  99. var el = document.createElement("div"); el.className = "item"; el.dataset.d = d;
  100. el.innerHTML = d + (n ? ' <span class="cnt">' + n + "</span>" : "");
  101. if (!n) { el.style.color = "#5b6b7d"; el.title = "暂无原型,欢迎补充"; }
  102. dbox.appendChild(el);
  103. });
  104. document.getElementById("cntAll").textContent = M.pages.length;
  105. document.querySelector(".nav").addEventListener("click", function (e) {
  106. var it = e.target.closest(".item"); if (!it) return;
  107. document.querySelectorAll(".nav .item").forEach(function (x) { x.classList.remove("active"); });
  108. it.classList.add("active"); curDomain = it.dataset.d; render();
  109. });
  110. document.getElementById("kw").addEventListener("input", render);
  111. function typeBadge(t) {
  112. var c = { "墨刀": "#7c3aed", "线上系统": "#0e7490", "需求文档": "#b45309", "新设计": "#16a34a" }[t] || "#909399";
  113. return '<b style="color:' + c + ';font-weight:600">[' + t + ']</b>';
  114. }
  115. function render() {
  116. var kw = (document.getElementById("kw").value || "").trim();
  117. var box = document.getElementById("cards"); box.innerHTML = "";
  118. var list = M.pages.filter(function (p) {
  119. if (curDomain !== "全部" && p.domain !== curDomain) return false;
  120. if (kw && !(p.name + p.status + p.domain).includes(kw)) return false;
  121. return true;
  122. });
  123. if (!list.length) { box.innerHTML = '<div class="empty-tip">该模块暂无原型<br><span style="font-size:12px">用 reproto 流程重构后收录,并更新 _meta.js</span></div>'; return; }
  124. list.forEach(function (p) {
  125. var c = document.createElement("div");
  126. c.className = "card" + (curPage === p.file ? " sel" : "");
  127. var src = p.initialSource;
  128. c.innerHTML =
  129. "<h3>" + p.domain + " · " + p.name + ' <span class="st">' + p.status + "</span></h3>" +
  130. '<div class="meta-row">初始版本:' + typeBadge(src.type) +
  131. (src.url ? ' <a href="' + src.url + '" target="_blank" onclick="event.stopPropagation()">' + (src.desc || "查看来源") + "</a>" : " " + (src.desc || "")) + "</div>" +
  132. '<div class="meta-row">线上对照:' + (p.liveUrl ? ' <a href="' + p.liveUrl + '" target="_blank" onclick="event.stopPropagation()">打开线上页面</a>' : ' <span class="pend">待登记(_meta.js liveUrl)</span>') +
  133. ' · 更新:' + p.updated + "</div>" +
  134. (p.related ? '<div class="meta-row" style="white-space:normal;color:#b0b6bf">' + p.related + "</div>" : "") +
  135. '<div class="ops"><span>👁 点击预览</span></div>';
  136. c.onclick = function () { openPv(p); };
  137. box.appendChild(c);
  138. });
  139. }
  140. function openPv(p) {
  141. curPage = p.file; render();
  142. document.getElementById("preview").classList.remove("off");
  143. document.getElementById("pvEmpty").style.display = "none";
  144. document.getElementById("pvFrame").style.display = "block";
  145. document.getElementById("pvTitle").textContent = p.domain + " · " + p.name + "(" + p.status + ")";
  146. document.getElementById("pvOpen").href = p.file;
  147. document.getElementById("pvBar").innerHTML =
  148. "本地: " + p.file + " · 线上: " + (p.liveUrl ? '<a href="' + p.liveUrl + '" target="_blank">' + p.liveUrl + "</a>" : '<span class="ph">待登记</span>');
  149. document.getElementById("pvFrame").src = p.file;
  150. }
  151. function closePv() {
  152. document.getElementById("preview").classList.add("off");
  153. document.getElementById("pvFrame").src = "about:blank";
  154. document.getElementById("pvFrame").style.display = "none";
  155. document.getElementById("pvEmpty").style.display = "flex";
  156. curPage = null; render();
  157. }
  158. render();
  159. /* ── 协同提醒:轮询 wedo-hub,他人有新改动时横幅提示(本页无法执行git,同步动作交给AI/MCP) ── */
  160. (function () {
  161. var H = window.PROTO_META.hub;
  162. if (!H || !H.url) return;
  163. var LS = "wedo_lastSynced_" + (H.repo || "default");
  164. function fetchAll() {
  165. return fetch(H.url.replace(/\/$/, "") + "/events?repo=" + encodeURIComponent(H.repo || "") + "&since=0",
  166. { headers: H.token ? { "x-wedo-token": H.token } : {} }).then(function (r) { return r.json(); });
  167. }
  168. function check() {
  169. fetchAll().then(function (d) {
  170. var evs = (d && d.events) || [];
  171. if (!evs.length) return;
  172. var last = evs[evs.length - 1];
  173. var mine = localStorage.getItem(LS);
  174. if (mine === null) { localStorage.setItem(LS, String(last.ts)); return; } /* 首访以最新为基线,不误报 */
  175. if (last.ts > Number(mine)) {
  176. var t = new Date(last.ts), hh = ("0" + t.getHours()).slice(-2) + ":" + ("0" + t.getMinutes()).slice(-2);
  177. document.getElementById("updText").textContent =
  178. last.user + " 于 " + hh + " " + last.message + " —— 请让 AI 执行 proto_sync {pull:true} 同步后刷新本页";
  179. document.getElementById("updBanner").classList.add("show");
  180. }
  181. }).catch(function () { /* hub不可达:静默,不影响浏览 */ });
  182. }
  183. window.ackSync = function () {
  184. document.getElementById("updBanner").classList.remove("show");
  185. fetchAll().then(function (d) {
  186. var evs = (d && d.events) || [];
  187. if (evs.length) localStorage.setItem(LS, String(evs[evs.length - 1].ts));
  188. }).catch(function () { });
  189. };
  190. check();
  191. setInterval(check, 2 * 60 * 1000);
  192. })();
  193. </script>
  194. </body>
  195. </html>