merge(nsfw): 发布登录账号成人内容偏好

合入已验证的 NSFW 账号偏好改动,游客登录限制保持不变。
This commit is contained in:
2026-10-27 12:39:16 +00:00
4 changed files with 87 additions and 7 deletions
+4
View File
@@ -157,3 +157,7 @@ NPC 尚未出字就停止或失败时,“继续”仍可接续此前已完成
前台通过 `/api/auth/digital/login` 使用独立 C 端账号,由后台「用户管理」开通;不再使用管理员/员工身份。已有数字人业务账号由迁移复制密码哈希并保留会话,之后两套账号密码和状态独立。登录令牌保存在 HttpOnly Cookie,密码重置/账号停用会撤销旧登录状态。 前台通过 `/api/auth/digital/login` 使用独立 C 端账号,由后台「用户管理」开通;不再使用管理员/员工身份。已有数字人业务账号由迁移复制密码哈希并保留会话,之后两套账号密码和状态独立。登录令牌保存在 HttpOnly Cookie,密码重置/账号停用会撤销旧登录状态。
对话设置的世界书与叙事风格使用平面列表;选中只保留轻底色和一个勾选标记,键盘焦点仍显示明确轮廓。 对话设置的世界书与叙事风格使用平面列表;选中只保留轻底色和一个勾选标记,键盘焦点仍显示明确轮廓。
### NSFW 账号偏好
「我的」提供 NSFW 成人内容开关,登录账号未保存偏好时默认开启,已保存的关闭选择继续保留。保存后对已有及新会话的后续回复生效,包括发送、继续、重生成与回复灵感;游客仍须先登录。偏好由 `access-manage` 保存在本人资料中,前台不使用本地存储伪造保存结果。前后端需配套发布。
+34 -7
View File
@@ -1,6 +1,6 @@
"use client"; "use client";
/* eslint-disable @next/next/no-img-element -- 本地封面直接读取,避免在小型服务器上运行图片转换。 */ /* eslint-disable @next/next/no-img-element -- 本地封面直接读取,避免在小型服务器上运行图片转换。 */
/** 星港数字人空间:探索、会话、世界书和身份资料的响应式入口。 */ /** 星港数字人空间:探索、会话、世界书、身份资料和账号内容偏好。 */
import Link from "next/link"; import Link from "next/link";
import { import {
useCallback, useCallback,
@@ -502,8 +502,13 @@ export function DigitalHome({
: [...profile.favorites, card.id], : [...profile.favorites, card.id],
}; };
try { try {
await digital("profile", "PUT", next); // 收藏不写内容开关,避免旧页面状态覆盖管理员刚保存的账号偏好。
setProfile(next); const saved = await digital<Profile>("profile", "PUT", {
favorites: next.favorites,
persona: next.persona,
userName: next.userName,
});
setProfile(saved);
} catch (e) { } catch (e) {
reportError(e); reportError(e);
} finally { } finally {
@@ -874,11 +879,15 @@ export function DigitalHome({
...profile, ...profile,
userName: profileDraft.userName, userName: profileDraft.userName,
persona: profileDraft.persona, persona: profileDraft.persona,
nsfwEnabled: profileDraft.nsfwEnabled ?? true,
}; };
try { try {
await digital("profile", "PUT", next); const saved = await digital<Profile>("profile", "PUT", next);
setProfile(next); if (saved.nsfwEnabled !== next.nsfwEnabled)
setNotice("身份资料已保存"); throw new Error("内容偏好未保存,请稍后重试");
setProfile(saved);
setProfileDraft(saved);
setNotice("身份与内容偏好已保存");
} catch (e) { } catch (e) {
reportError(e); reportError(e);
} }
@@ -917,6 +926,7 @@ export function DigitalHome({
} }
setConversation(null); setConversation(null);
currentId.current = null; currentId.current = null;
if (value === "me" && tab !== "me" && profile) setProfileDraft(profile);
setTab(value); setTab(value);
setError(""); setError("");
} }
@@ -1763,9 +1773,26 @@ export function DigitalHome({
<p className="dh-form-note"> <p className="dh-form-note">
此资料可在新会话的「对话设定」中使用。每个会话的设定相互独立。 此资料可在新会话的「对话设定」中使用。每个会话的设定相互独立。
</p> </p>
<label className="dh-content-preference">
<span>
<strong>NSFW 成人内容</strong>
<small>登录账号默认开启,可随时关闭;保存后用于后续回复。</small>
</span>
<input
type="checkbox"
role="switch"
checked={profileDraft.nsfwEnabled ?? true}
onChange={(event) =>
setProfileDraft({
...profileDraft,
nsfwEnabled: event.target.checked,
})
}
/>
</label>
<button className="dh-primary" type="submit"> <button className="dh-primary" type="submit">
<Check size={16} /> <Check size={16} />
保存身份 保存身份与偏好
</button> </button>
<div className="dh-profile-stats"> <div className="dh-profile-stats">
<div> <div>
+47
View File
@@ -990,6 +990,53 @@
line-height: 1.9; line-height: 1.9;
margin: 8px 0 20px !important; margin: 8px 0 20px !important;
} }
.dh-profile-form > .dh-content-preference {
flex-direction: row;
align-items: center;
justify-content: space-between;
gap: 18px;
padding: 16px 0;
border-top: 1px solid var(--dh-line);
border-bottom: 1px solid var(--dh-line);
}
.dh-content-preference span {
min-width: 0;
}
.dh-content-preference small {
display: block;
margin-top: 6px;
color: var(--dh-muted);
line-height: 1.7;
}
.dh-content-preference input[type="checkbox"] {
appearance: none;
flex: none;
width: 44px;
height: 26px;
padding: 3px;
border: 1px solid var(--dh-line);
border-radius: 20px;
background: var(--dh-panel);
cursor: pointer;
}
.dh-content-preference input::before {
display: block;
width: 18px;
height: 18px;
border-radius: 50%;
background: #fff;
content: "";
}
.dh-content-preference input:checked {
background: var(--dh-accent);
}
.dh-content-preference input:checked::before {
transform: translateX(18px);
}
.dh-content-preference input:focus-visible {
outline: 2px solid var(--dh-accent);
outline-offset: 3px;
}
.dh-profile-stats { .dh-profile-stats {
display: flex; display: flex;
border-top: 1px solid var(--dh-line); border-top: 1px solid var(--dh-line);
+2
View File
@@ -20,6 +20,8 @@ export type Profile = {
favorites: string[]; favorites: string[];
persona: string; persona: string;
userName: string; userName: string;
/** 登录账号的成人内容偏好;旧服务未返回时沿用默认开启。 */
nsfwEnabled?: boolean;
}; };
/** 会话消息拥有持久化 id,避免流式刷新时重复插入。 */ /** 会话消息拥有持久化 id,避免流式刷新时重复插入。 */
export type Message = { export type Message = {