feat(panel): 锁屏一次性解锁端点 POST /api/system/pin-unlock-once(写 /tmp/meow_pin_unlock_once,launcher 锁屏页消费放行一次)+ 设置页 PIN 卡「一次性解锁设备」按钮
This commit is contained in:
1 parent
54d2791f48
commit
85e1d03157
2 files changed
+23
-1
No files matched your search
@@ -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);
|
||||
|
||||
@@ -1681,6 +1681,9 @@
|
||||
'<button class="btn btn-danger" id="pin-clear" ' + (canEdit ? '' : 'disabled') + '>清空 PIN</button>' +
|
||||
(st.locked ? '<span class="muted">锁定期间不可修改/清空</span>' : '<span class="muted">修改/清空需先验证当前 PIN</span>') +
|
||||
'</div>';
|
||||
h += '<div class="field-row" style="margin-top:6px">' +
|
||||
'<button class="btn" id="pin-unlock-once" ' + (st.session ? '' : 'disabled') + '>一次性解锁设备</button>' +
|
||||
'<span class="muted">设备下次亮屏免 PIN 进入一次(不清除 PIN)</span></div>';
|
||||
h += '<p class="muted" style="margin-top:6px">4 位数字 PIN,纯加盐哈希存储(不落明文);未设 PIN 时写端点一律拒绝。</p>';
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user