Forráskód Böngészése

[门户] 更新: 集成协同状态提醒(轮询wedo-hub,他人更新弹横幅提示proto_sync)

lio 2 hónapja
szülő
commit
56ef8b51a2
2 módosított fájl, 47 hozzáadás és 0 törlés
  1. 2 0
      _meta.js
  2. 45 0
      index.html

+ 2 - 0
_meta.js

@@ -7,6 +7,8 @@ window.PROTO_META = {
   system: "恒隆公寓AMS(租赁管理平台)",
   repo: { url: "https://gitlab.wxapp.info/lio/hanglung", desc: "基于恒隆现有原型设计进行补充的二开,仅供开发测试人员业务逻辑补充使用" },
   live: { name: "恒隆府RT租赁管理平台", url: "", note: "线上/测试环境入口,待登记" },
+  /* 协同提醒:门户轮询 wedo-hub,检测到他人更新时弹横幅提示同步(token为团队内部口令) */
+  hub: { url: "https://gogs.wxapp.info/wedo-hub", token: "d2fcf3469a29f2fcfca96d1e75b5585b", repo: "hanglung" },
   domains: ["资源规划","招商管理","租控管理","预定管理","合同管理","入住管理","财务管理","能源管理","清洁维修管理","财务中心","系统工作台"],
   pages: [
     {

+ 45 - 0
index.html

@@ -19,6 +19,13 @@
   .topbar { height:56px; background:#fff; border-bottom:1px solid #e4e7ed; display:flex; align-items:center; padding:0 20px; gap:14px; }
   .topbar b { font-size:14px; }
   .topbar .sub { color:#909399; font-size:12px; flex:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
+  .upd-banner { display:none; align-items:center; gap:10px; background:#fff7ed; border-bottom:1px solid #fdba74;
+          color:#9a3412; padding:8px 20px; font-size:12.5px; }
+  .upd-banner.show { display:flex; }
+  .upd-banner b { color:#c2410c; }
+  .upd-banner .btn-ok { margin-left:auto; height:26px; padding:0 12px; line-height:24px; border-radius:4px;
+          border:1px solid #fdba74; background:#fff; color:#b45309; cursor:pointer; font-size:12px; white-space:nowrap; }
+  .upd-banner .btn-ok:hover { background:#fef3c7; }
   .topbar input { height:32px; border:1px solid #dcdfe6; border-radius:4px; padding:0 10px; width:220px; outline:none; }
   .topbar input:focus { border-color:#2563eb; }
   .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; }
@@ -59,6 +66,10 @@
     <div id="domains"></div>
   </div>
   <div class="mid">
+    <div class="upd-banner" id="updBanner">
+      🔔 <b>原型有更新:</b><span id="updText"></span>
+      <button class="btn-ok" onclick="ackSync()">✔ 我已同步(proto_sync)</button>
+    </div>
     <div class="topbar">
       <b>原型门户</b>
       <span class="sub" id="subTitle"></span>
@@ -145,6 +156,40 @@ function closePv() {
   curPage = null; render();
 }
 render();
+/* ── 协同提醒:轮询 wedo-hub,他人有新改动时横幅提示(本页无法执行git,同步动作交给AI/MCP) ── */
+(function () {
+  var H = window.PROTO_META.hub;
+  if (!H || !H.url) return;
+  var LS = "wedo_lastSynced_" + (H.repo || "default");
+  function fetchAll() {
+    return fetch(H.url.replace(/\/$/, "") + "/events?repo=" + encodeURIComponent(H.repo || "") + "&since=0",
+      { headers: H.token ? { "x-wedo-token": H.token } : {} }).then(function (r) { return r.json(); });
+  }
+  function check() {
+    fetchAll().then(function (d) {
+      var evs = (d && d.events) || [];
+      if (!evs.length) return;
+      var last = evs[evs.length - 1];
+      var mine = localStorage.getItem(LS);
+      if (mine === null) { localStorage.setItem(LS, String(last.ts)); return; }  /* 首访以最新为基线,不误报 */
+      if (last.ts > Number(mine)) {
+        var t = new Date(last.ts), hh = ("0" + t.getHours()).slice(-2) + ":" + ("0" + t.getMinutes()).slice(-2);
+        document.getElementById("updText").textContent =
+          last.user + " 于 " + hh + " " + last.message + " —— 请让 AI 执行 proto_sync {pull:true} 同步后刷新本页";
+        document.getElementById("updBanner").classList.add("show");
+      }
+    }).catch(function () { /* hub不可达:静默,不影响浏览 */ });
+  }
+  window.ackSync = function () {
+    document.getElementById("updBanner").classList.remove("show");
+    fetchAll().then(function (d) {
+      var evs = (d && d.events) || [];
+      if (evs.length) localStorage.setItem(LS, String(evs[evs.length - 1].ts));
+    }).catch(function () { });
+  };
+  check();
+  setInterval(check, 2 * 60 * 1000);
+})();
 </script>
 </body>
 </html>