ARTEX — AI 自主渗透测试系统(Go 后端 + Next.js 前端,单二进制内嵌)。 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
28 lines
709 B
TypeScript
28 lines
709 B
TypeScript
"use client";
|
|
|
|
import { setClientCookie } from "../cookie.client";
|
|
import { setLocalStorageValue } from "../local-storage.client";
|
|
import { PREFERENCE_PERSISTENCE, type PreferenceKey } from "./preferences-config";
|
|
|
|
export async function persistPreference(key: PreferenceKey, value: string) {
|
|
const mode = PREFERENCE_PERSISTENCE[key];
|
|
|
|
switch (mode) {
|
|
case "none":
|
|
return;
|
|
|
|
// 静态导出无 Node 服务端,server-cookie 退化为浏览器 cookie(写入语义等价)。
|
|
case "server-cookie":
|
|
case "client-cookie":
|
|
setClientCookie(key, value);
|
|
return;
|
|
|
|
case "localStorage":
|
|
setLocalStorageValue(key, value);
|
|
return;
|
|
|
|
default:
|
|
return;
|
|
}
|
|
}
|