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()