feat(draft): /draft/history 返回 curTs——前端按它判定「当前草稿」徽标(丢弃后为0不标)
This commit is contained in:
1 parent
b8138151ec
commit
3ee96dd741
1 file changed
+11
-1
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user