index.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. /* 协同状态灯(常驻):绿=已最新 红=有待同步 灰=hub未连通;点击弹详情面板 */
  30. .hub-wrap { position:relative; }
  31. .hub-dot { display:inline-flex; align-items:center; gap:6px; height:30px; padding:0 10px; border:1px solid #dcdfe6;
  32. border-radius:15px; background:#fff; cursor:pointer; font-size:12px; color:#606266; white-space:nowrap; }
  33. .hub-dot:hover { border-color:#93c5fd; }
  34. .hub-dot .led { width:9px; height:9px; border-radius:50%; background:#c0c4cc; transition:background .3s; }
  35. .hub-dot.s-green .led { background:#22c55e; box-shadow:0 0 5px rgba(34,197,94,.7); }
  36. .hub-dot.s-red .led { background:#ef4444; box-shadow:0 0 5px rgba(239,68,68,.8); animation:hubPulse 1.2s infinite; }
  37. .hub-dot.s-gray .led { background:#c0c4cc; }
  38. @keyframes hubPulse { 50% { opacity:.45; } }
  39. .hub-pop { display:none; position:absolute; right:0; top:36px; width:360px; background:#fff; border:1px solid #e4e7ed;
  40. border-radius:8px; box-shadow:0 6px 24px rgba(31,45,61,.16); z-index:50; overflow:hidden; }
  41. .hub-pop.show { display:block; }
  42. .hub-pop .hp-head { padding:10px 14px; border-bottom:1px solid #f2f4f7; font-size:12.5px; display:flex; align-items:center; gap:8px; }
  43. .hub-pop .hp-head .st-green { color:#16a34a; } .hub-pop .hp-head .st-red { color:#dc2626; } .hub-pop .hp-head .st-gray { color:#909399; }
  44. .hub-pop .hp-head .btn-ok { margin-left:auto; height:24px; padding:0 10px; line-height:22px; border-radius:4px;
  45. border:1px solid #fdba74; background:#fff; color:#b45309; cursor:pointer; font-size:11.5px; white-space:nowrap; }
  46. .hub-pop ul { list-style:none; max-height:240px; overflow-y:auto; }
  47. .hub-pop li { padding:8px 14px; border-bottom:1px solid #f7f8fa; font-size:12px; line-height:1.6; }
  48. .hub-pop li .u { color:#2563eb; font-weight:600; }
  49. .hub-pop li .t { color:#c0c4cc; font-size:11px; margin-left:6px; }
  50. .hub-pop li.pending { background:#fff7ed; }
  51. .hub-pop .hp-empty { padding:18px 14px; color:#909399; font-size:12px; text-align:center; }
  52. .topbar input { height:32px; border:1px solid #dcdfe6; border-radius:4px; padding:0 10px; width:220px; outline:none; }
  53. .topbar input:focus { border-color:#2563eb; }
  54. .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; }
  55. .list { flex:1; overflow-y:auto; padding:16px 20px; }
  56. .cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:14px; }
  57. .card { background:#fff; border:1px solid #ebeef5; border-radius:8px; padding:14px 16px; cursor:pointer; transition:box-shadow .15s,border-color .15s; }
  58. .card:hover { border-color:#93c5fd; box-shadow:0 2px 10px rgba(37,99,235,.12); }
  59. .card.sel { border-color:#2563eb; box-shadow:0 0 0 2px rgba(37,99,235,.18); }
  60. .card h3 { font-size:14px; margin-bottom:6px; display:flex; align-items:center; gap:8px; }
  61. .card h3 .st { font-size:11px; font-weight:400; color:#2563eb; background:#eff6ff; padding:1px 7px; border-radius:3px; }
  62. .meta-row { color:#909399; font-size:12px; line-height:1.8; }
  63. .meta-row .src { color:#0e7490; cursor:pointer; }
  64. .meta-row a { color:#2563eb; text-decoration:none; }
  65. .meta-row .pend { color:#c0c4cc; }
  66. .card .ops { margin-top:8px; display:flex; gap:8px; }
  67. .card .ops span { font-size:12px; color:#2563eb; }
  68. .card .ops .off { color:#c0c4cc; cursor:default; }
  69. .empty-tip { text-align:center; color:#909399; padding:60px 0; grid-column:1/-1; }
  70. /* 右侧预览 */
  71. .preview { width:46%; min-width:420px; flex-shrink:0; background:#fff; border-left:1px solid #e4e7ed; display:flex; flex-direction:column; }
  72. .preview.off { display:none; }
  73. .pv-head { height:56px; border-bottom:1px solid #ebeef5; display:flex; align-items:center; padding:0 16px; gap:10px; }
  74. .pv-head b { flex:1; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  75. .pv-head .x { cursor:pointer; color:#909399; font-size:17px; padding:0 4px; }
  76. .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; }
  77. .pv-bar a { color:#2563eb; text-decoration:none; }
  78. .pv-bar .ph { color:#c0c4cc; }
  79. iframe { flex:1; border:none; width:100%; background:#fff; }
  80. .pv-empty { flex:1; display:flex; align-items:center; justify-content:center; color:#c0c4cc; flex-direction:column; gap:10px; }
  81. </style>
  82. </head>
  83. <body>
  84. <div class="nav">
  85. <div class="logo">恒隆原型库<br><span style="font-size:10px;font-weight:400;color:#7f95ad">补充重构·二开</span></div>
  86. <div class="group-title">全部模块</div>
  87. <div class="item active" data-d="全部">全部 <span class="cnt" id="cntAll"></span></div>
  88. <div class="group-title">业务域</div>
  89. <div id="domains"></div>
  90. </div>
  91. <div class="mid">
  92. <div class="topbar">
  93. <b>原型门户</b>
  94. <span class="sub" id="subTitle"></span>
  95. <input id="kw" placeholder="搜索页面名称/状态…">
  96. <span class="hub-wrap">
  97. <span class="hub-dot s-gray" id="hubDot" title="协同状态,点击查看详情">
  98. <span class="led"></span><span id="hubLabel">协同…</span>
  99. </span>
  100. <div class="hub-pop" id="hubPop">
  101. <div class="hp-head"><span id="hubState"></span>
  102. <button class="btn-ok" id="hubAck" onclick="ackSync()">✔ 我已同步(proto_sync)</button>
  103. </div>
  104. <ul id="hubList"></ul>
  105. </div>
  106. </span>
  107. <a class="btn" id="liveBtn" target="_blank">🖥 线上系统</a>
  108. <a class="btn" id="repoBtn" target="_blank">📦 Gogs 仓库</a>
  109. </div>
  110. <div class="list"><div class="cards" id="cards"></div></div>
  111. </div>
  112. <div class="preview off" id="preview">
  113. <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>
  114. <div class="pv-bar" id="pvBar"></div>
  115. <iframe id="pvFrame"></iframe>
  116. <div class="pv-empty" id="pvEmpty"><div style="font-size:36px">👁</div>点击左侧卡片在此预览原型<br><span style="font-size:12px">原型内「ⓘ 逻辑标注」等交互均可在预览中操作</span></div>
  117. </div>
  118. <script src="_meta.js"></script>
  119. <script>
  120. var M = window.PROTO_META, curDomain = "全部", curPage = null;
  121. document.getElementById("subTitle").textContent = M.system + " · " + M.repo.desc;
  122. document.getElementById("repoBtn").href = M.repo.url;
  123. var liveBtn = document.getElementById("liveBtn");
  124. 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; }; }
  125. /* 域导航 */
  126. var dbox = document.getElementById("domains");
  127. M.domains.forEach(function (d) {
  128. var n = M.pages.filter(function (p) { return p.domain === d; }).length;
  129. var el = document.createElement("div"); el.className = "item"; el.dataset.d = d;
  130. el.innerHTML = d + (n ? ' <span class="cnt">' + n + "</span>" : "");
  131. if (!n) { el.style.color = "#5b6b7d"; el.title = "暂无原型,欢迎补充"; }
  132. dbox.appendChild(el);
  133. });
  134. document.getElementById("cntAll").textContent = M.pages.length;
  135. document.querySelector(".nav").addEventListener("click", function (e) {
  136. var it = e.target.closest(".item"); if (!it) return;
  137. document.querySelectorAll(".nav .item").forEach(function (x) { x.classList.remove("active"); });
  138. it.classList.add("active"); curDomain = it.dataset.d; render();
  139. });
  140. document.getElementById("kw").addEventListener("input", render);
  141. function typeBadge(t) {
  142. var c = { "墨刀": "#7c3aed", "线上系统": "#0e7490", "需求文档": "#b45309", "新设计": "#16a34a" }[t] || "#909399";
  143. return '<b style="color:' + c + ';font-weight:600">[' + t + ']</b>';
  144. }
  145. function render() {
  146. var kw = (document.getElementById("kw").value || "").trim();
  147. var box = document.getElementById("cards"); box.innerHTML = "";
  148. var list = M.pages.filter(function (p) {
  149. if (curDomain !== "全部" && p.domain !== curDomain) return false;
  150. if (kw && !(p.name + p.status + p.domain).includes(kw)) return false;
  151. return true;
  152. });
  153. if (!list.length) { box.innerHTML = '<div class="empty-tip">该模块暂无原型<br><span style="font-size:12px">用 reproto 流程重构后收录,并更新 _meta.js</span></div>'; return; }
  154. list.forEach(function (p) {
  155. var c = document.createElement("div");
  156. c.className = "card" + (curPage === p.file ? " sel" : "");
  157. var src = p.initialSource;
  158. c.innerHTML =
  159. "<h3>" + p.domain + " · " + p.name + ' <span class="st">' + p.status + "</span></h3>" +
  160. '<div class="meta-row">初始版本:' + typeBadge(src.type) +
  161. (src.url ? ' <a href="' + src.url + '" target="_blank" onclick="event.stopPropagation()">' + (src.desc || "查看来源") + "</a>" : " " + (src.desc || "")) + "</div>" +
  162. '<div class="meta-row">线上对照:' + (p.liveUrl ? ' <a href="' + p.liveUrl + '" target="_blank" onclick="event.stopPropagation()">打开线上页面</a>' : ' <span class="pend">待登记(_meta.js liveUrl)</span>') +
  163. ' · 更新:' + p.updated + "</div>" +
  164. (p.related ? '<div class="meta-row" style="white-space:normal;color:#b0b6bf">' + p.related + "</div>" : "") +
  165. '<div class="ops"><span>👁 点击预览</span></div>';
  166. c.onclick = function () { openPv(p); };
  167. box.appendChild(c);
  168. });
  169. }
  170. function openPv(p) {
  171. curPage = p.file; render();
  172. document.getElementById("preview").classList.remove("off");
  173. document.getElementById("pvEmpty").style.display = "none";
  174. document.getElementById("pvFrame").style.display = "block";
  175. document.getElementById("pvTitle").textContent = p.domain + " · " + p.name + "(" + p.status + ")";
  176. document.getElementById("pvOpen").href = p.file;
  177. document.getElementById("pvBar").innerHTML =
  178. "本地: " + p.file + " · 线上: " + (p.liveUrl ? '<a href="' + p.liveUrl + '" target="_blank">' + p.liveUrl + "</a>" : '<span class="ph">待登记</span>');
  179. document.getElementById("pvFrame").src = p.file;
  180. }
  181. function closePv() {
  182. document.getElementById("preview").classList.add("off");
  183. document.getElementById("pvFrame").src = "about:blank";
  184. document.getElementById("pvFrame").style.display = "none";
  185. document.getElementById("pvEmpty").style.display = "flex";
  186. curPage = null; render();
  187. }
  188. render();
  189. /* ── 协同状态灯(常驻):绿=已最新 红=有待同步 灰=hub未连通;点击弹详情面板,同步动作交给AI/MCP ── */
  190. (function () {
  191. var H = window.PROTO_META.hub;
  192. var dot = document.getElementById("hubDot"), pop = document.getElementById("hubPop");
  193. if (!H || !H.url) { dot.classList.add("s-gray"); document.getElementById("hubLabel").textContent = "协同未配置"; return; }
  194. var LS = "wedo_lastSynced_" + (H.repo || "default");
  195. var lastEvs = []; /* 最近一次轮询到的事件(详情面板渲染用) */
  196. function fetchAll() {
  197. return fetch(H.url.replace(/\/$/, "") + "/events?repo=" + encodeURIComponent(H.repo || "") + "&since=0",
  198. { headers: H.token ? { "x-wedo-token": H.token } : {} }).then(function (r) { return r.json(); });
  199. }
  200. function fmtTs(ts) {
  201. var t = new Date(ts);
  202. return ("0" + t.getHours()).slice(-2) + ":" + ("0" + t.getMinutes()).slice(-2);
  203. }
  204. function setState(st, label) { /* st: green|red|gray */
  205. dot.classList.remove("s-green", "s-red", "s-gray");
  206. dot.classList.add("s-" + st);
  207. document.getElementById("hubLabel").textContent = label;
  208. var head = document.getElementById("hubState");
  209. head.className = "st-" + st;
  210. head.textContent = st === "green" ? "✓ 已是最新,无待同步改动"
  211. : st === "red" ? "🔔 有待同步的原型更新(下方橙色条目)" : "⚠ hub 未连通(检查网络/服务)";
  212. document.getElementById("hubAck").style.display = st === "red" ? "" : "none";
  213. }
  214. function renderPop(pendingTs) {
  215. var ul = document.getElementById("hubList");
  216. if (!lastEvs.length) { ul.innerHTML = '<div class="hp-empty">暂无协同事件</div>'; return; }
  217. ul.innerHTML = lastEvs.slice(-8).reverse().map(function (e) {
  218. return '<li class="' + (e.ts > pendingTs ? "pending" : "") + '"><span class="u">' + e.user + '</span><span class="t">' + fmtTs(e.ts) + '</span><br>' + e.message + "</li>";
  219. }).join("");
  220. }
  221. function check() {
  222. fetchAll().then(function (d) {
  223. lastEvs = (d && d.events) || [];
  224. if (!lastEvs.length) { setState("green", "协同·无事件"); renderPop(Infinity); return; }
  225. var last = lastEvs[lastEvs.length - 1];
  226. var mine = localStorage.getItem(LS);
  227. if (mine === null) { localStorage.setItem(LS, String(last.ts)); mine = String(last.ts); } /* 首访以最新为基线,不误报 */
  228. if (last.ts > Number(mine)) { setState("red", "有更新待同步"); renderPop(Number(mine)); }
  229. else { setState("green", "协同·已最新"); renderPop(Infinity); }
  230. }).catch(function () { setState("gray", "协同·未连通"); });
  231. }
  232. dot.addEventListener("click", function (e) {
  233. e.stopPropagation();
  234. pop.classList.toggle("show");
  235. });
  236. document.addEventListener("click", function (e) {
  237. if (!e.target.closest(".hub-wrap")) pop.classList.remove("show");
  238. });
  239. window.ackSync = function () {
  240. fetchAll().then(function (d) {
  241. var evs = (d && d.events) || [];
  242. if (evs.length) localStorage.setItem(LS, String(evs[evs.length - 1].ts));
  243. setState("green", "协同·已最新"); renderPop(Infinity);
  244. }).catch(function () { setState("gray", "协同·未连通"); });
  245. };
  246. check();
  247. setInterval(check, 2 * 60 * 1000);
  248. })();
  249. </script>
  250. </body>
  251. </html>