fix: canvas image/video download - fix data URL parsing in cvDownloadPreview (v1.5.21, hot 1.5.23)

This commit is contained in:
mac
2026-07-20 08:48:56 +08:00
parent 42e23663ee
commit aadd2b04ae
28 changed files with 5881 additions and 329 deletions
+43
View File
@@ -0,0 +1,43 @@
// token_watch.js —— Token 用量监控(对外的薄包装层)。
// 注入脚本由 voice_cdp.js 在连接 Codex 时自动注入(与语音脚本同 session)。
// 本模块暴露 status / reset 给 IPC handler 和前端面板。
"use strict";
const voice = require("./voice_cdp");
const tokenUsage = require("./token_usage");
function status() {
const snap = voice.status();
return {
phase: snap.phase,
date: "",
total: 0,
};
}
async function tokenStatus() {
try {
const snap = voice.status();
const page = await voice.tokenStatus();
const local = tokenUsage.readDaily();
if (local && local.available) {
await voice.tokenSet(local);
return { ok: true, phase: snap.phase, connected: snap.phase === "connected", ...local, network: page.network };
}
return { ok: true, phase: snap.phase, connected: snap.phase === "connected", ...page };
} catch {
return { ok: false, error: "无法读取 token 用量(Codex 可能未连接)" };
}
}
async function tokenReset() {
try {
const local = tokenUsage.reset();
const ok = await voice.tokenSet(local);
await voice.tokenReset();
return { ok: ok || true };
} catch {
return { ok: false, error: "无法重置" };
}
}
module.exports = { status, tokenStatus, tokenReset };