From 3ee96dd7416ea78543ef05782aadde1113a5afd5 Mon Sep 17 00:00:00 2001 From: jinghui Date: Sun, 15 Nov 2026 15:08:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(draft):=20/draft/history=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20curTs=E2=80=94=E2=80=94=E5=89=8D=E7=AB=AF=E6=8C=89?= =?UTF-8?q?=E5=AE=83=E5=88=A4=E5=AE=9A=E3=80=8C=E5=BD=93=E5=89=8D=E8=8D=89?= =?UTF-8?q?=E7=A8=BF=E3=80=8D=E5=BE=BD=E6=A0=87=EF=BC=88=E4=B8=A2=E5=BC=83?= =?UTF-8?q?=E5=90=8E=E4=B8=BA0=E4=B8=8D=E6=A0=87=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index d34f23b..d50bfc3 100644 --- a/server.py +++ b/server.py @@ -3989,7 +3989,17 @@ class Handler(BaseHTTPRequestHandler): items.append({"ts": int(h.get("ts") or 0), "bytes": b}) except (OSError, ValueError): items = [] - self._reply(200, json.dumps({"code": 200, "message": "ok", "data": {"items": items}}, ensure_ascii=False).encode("utf-8"), "application/json") + # 当前草稿(draft 文件)的时间戳:>0 表示草稿仍在,历史列表首项若同 ts + # 才有资格标「当前草稿」徽标(丢弃后 draft 删除、hist 保留,此时 curTs=0 不标) + cur_ts = 0 + if os.path.isfile(path): + try: + with open(path, "r", encoding="utf-8") as f: + rec = json.load(f) + cur_ts = int(rec.get("ts") or 0) + except (OSError, ValueError, TypeError): + cur_ts = 0 + self._reply(200, json.dumps({"code": 200, "message": "ok", "data": {"items": items, "curTs": cur_ts}}, ensure_ascii=False).encode("utf-8"), "application/json") def _handle_draft_delete(self): payload = self._read_payload()