diff --git a/patch_v2/meowpanel/meowpanel.c b/patch_v2/meowpanel/meowpanel.c index 4f7a0da..2d4df50 100644 --- a/patch_v2/meowpanel/meowpanel.c +++ b/patch_v2/meowpanel/meowpanel.c @@ -3493,6 +3493,17 @@ static int api_system(int sock) return ret; } +/* ---------------- 锁屏一次性解锁(写 /tmp/meow_pin_unlock_once,launcher 锁屏页消费) ---------------- */ +static int api_pin_unlock_once(int sock) +{ + const char *path = "/tmp/meow_pin_unlock_once"; + FILE *f = fopen(path, "w"); + if (!f) return send_err(sock, 500, "INTERNAL", "无法写入一次性解锁标志"); + fputs("1\n", f); + fclose(f); + return send_json(sock, 200, "{\"unlock_once\":true}"); +} + /* ---------------- 系统动作(经 meow_svc_power IPC) ---------------- */ static int api_system_action(int sock, const char *which, const req_t *r) { @@ -5397,6 +5408,7 @@ static int handle(int sock, req_t *r) if (!strcmp(p, "/api/system/reboot")) return api_system_action(sock, "reboot", r); if (!strcmp(p, "/api/system/shutdown")) return api_system_action(sock, "shutdown", r); if (!strcmp(p, "/api/system/ota")) return api_system_action(sock, "ota", r); + if (!strcmp(p, "/api/system/pin-unlock-once")) return api_pin_unlock_once(sock); if (!strcmp(p, "/api/settings")) return api_settings_batch(sock, r); if (!strcmp(p, "/api/settings/restore")) return api_settings_restore(sock); if (!strcmp(p, "/api/theme")) return api_theme_put(sock, r); diff --git a/patch_v2/meowpanel/web/meowpanel.js b/patch_v2/meowpanel/web/meowpanel.js index 3964398..95625eb 100644 --- a/patch_v2/meowpanel/web/meowpanel.js +++ b/patch_v2/meowpanel/web/meowpanel.js @@ -1681,6 +1681,9 @@ '' + (st.locked ? '锁定期间不可修改/清空' : '修改/清空需先验证当前 PIN') + ''; + h += '
4 位数字 PIN,纯加盐哈希存储(不落明文);未设 PIN 时写端点一律拒绝。
'; box.innerHTML = h; } @@ -1736,9 +1739,16 @@ } function bindPin() { const c = $('#content'); - c.addEventListener('click', function (e) { + c.addEventListener('click', async function (e) { if (e.target.closest('#pin-change')) { pinEdit('change'); return; } if (e.target.closest('#pin-clear')) { pinEdit('clear'); return; } + if (e.target.closest('#pin-unlock-once')) { + try { + await api('POST', '/api/system/pin-unlock-once', {}); + toast('已下发:设备下次亮屏免 PIN 进入一次'); + } catch (err) { toast('下发失败:' + errText(err)); } + return; + } }); ['#pindlg-old', '#pindlg-new', '#pindlg-new2'].forEach(function (sel) { const el = $(sel);