This commit is contained in:
tao.chen
2026-08-14 12:40:36 +08:00
parent 604e66ffe0
commit 518853cbb0
@@ -146,7 +146,12 @@ function ownedScriptPath(item: ScriptItem) {
function pushToast(tone: "success" | "error" | "info", message: string) {
useUiStore.getState().pushToast({ tone, message });
}
async function sha256Hex(buffer: ArrayBuffer): Promise<string> {
async function sha256Hex(buffer: ArrayBuffer): Promise<string | null> {
// `crypto.subtle` 仅在 secure contextHTTPS / localhost)下可用;不可用时
// 跳过 hash 计算,让后端走非校验路径。
if (typeof crypto === "undefined" || !crypto.subtle?.digest) {
return null;
}
const digest = await crypto.subtle.digest("SHA-256", buffer);
return Array.from(new Uint8Array(digest))
.map((byte) => byte.toString(16).padStart(2, "0"))