Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 16e989859c | |||
| cb5e004eb9 | |||
| fb46c0fdb5 | |||
| 3530219123 |
@@ -34,7 +34,7 @@ PORT=3210
|
|||||||
HOSTNAME=0.0.0.0
|
HOSTNAME=0.0.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
`ACCESS_MANAGE_API_BASE_URL` 指向 `access-manage` 服务端 API 根路径。数字人登录调用后端 `POST /api/auth/digital/login`,接受现有超级管理员或员工账号,登录成功后只把 JWT 写入 Next.js 服务端 HttpOnly Cookie,不写入 `localStorage`。
|
`ACCESS_MANAGE_API_BASE_URL` 指向 `access-manage` 服务端 API 根路径。数字人登录调用后端 `POST /api/auth/digital/login`,仅接受后台开通的独立 C 端账号,登录成功后只把 JWT 写入 Next.js 服务端 HttpOnly Cookie,不写入 `localStorage`。
|
||||||
|
|
||||||
环境标识按 `APP_ENV` 区分:
|
环境标识按 `APP_ENV` 区分:
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ pnpm start:prod
|
|||||||
|
|
||||||
## 数字人空间
|
## 数字人空间
|
||||||
|
|
||||||
- `/discover` 为默认入口,复用原登录账户和 HttpOnly Cookie。
|
- `/discover` 为默认入口,使用独立 C 端账号和 HttpOnly Cookie。
|
||||||
- `src/components/digital-home.tsx`、`digital.css`:深色双 UI、移动/桌面适配、探索、流式对话、停止、重生成、分支、固定记忆、世界书与用户身份。
|
- `src/components/digital-home.tsx`、`digital.css`:深色双 UI、移动/桌面适配、探索、流式对话、停止、重生成、分支、固定记忆、世界书与用户身份。
|
||||||
- `src/lib/digital.ts`:前台协议、请求和 SSE 解码。
|
- `src/lib/digital.ts`:前台协议、请求和 SSE 解码。
|
||||||
- `src/app/api/digital/[...path]/route.ts`:白名单 BFF,只转发前台接口,禁止访问后台实验管理,写入校验同源。
|
- `src/app/api/digital/[...path]/route.ts`:白名单 BFF,只转发前台接口,禁止访问后台实验管理,写入校验同源。
|
||||||
@@ -150,3 +150,14 @@ pnpm start:prod
|
|||||||
聊天输入区“继续”让 NPC 基于上一段内容继续说话,不发送或清空输入框草稿,也不插入用户气泡;可连续点击生成多段,生成时沿用停止按钮。角色尚无可接续内容时按钮不可用。
|
聊天输入区“继续”让 NPC 基于上一段内容继续说话,不发送或清空输入框草稿,也不插入用户气泡;可连续点击生成多段,生成时沿用停止按钮。角色尚无可接续内容时按钮不可用。
|
||||||
|
|
||||||
NPC 尚未出字就停止或失败时,“继续”仍可接续此前已完成的角色内容,输入草稿保持不变。
|
NPC 尚未出字就停止或失败时,“继续”仍可接续此前已完成的角色内容,输入草稿保持不变。
|
||||||
|
|
||||||
|
|
||||||
|
### 独立 C 端登录
|
||||||
|
|
||||||
|
前台通过 `/api/auth/digital/login` 使用独立 C 端账号,由后台「用户管理」开通;不再使用管理员/员工身份。已有数字人业务账号由迁移复制密码哈希并保留会话,之后两套账号密码和状态独立。登录令牌保存在 HttpOnly Cookie,密码重置/账号停用会撤销旧登录状态。
|
||||||
|
|
||||||
|
对话设置的世界书与叙事风格使用平面列表;选中只保留轻底色和一个勾选标记,键盘焦点仍显示明确轮廓。
|
||||||
|
|
||||||
|
### NSFW 账号偏好
|
||||||
|
|
||||||
|
「我的」提供 NSFW 成人内容开关,登录账号未保存偏好时默认开启,已保存的关闭选择继续保留。保存后对已有及新会话的后续回复生效,包括发送、继续、重生成与回复灵感;游客仍须先登录。偏好由 `access-manage` 保存在本人资料中,前台不使用本地存储伪造保存结果。前后端需配套发布。
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/** 星港登录页,沿用既有账号,无公开注册。 */
|
/** 星港登录页,使用独立用户账号,无公开注册。 */
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { LoginForm } from "@/components/login-form";
|
import { LoginForm } from "@/components/login-form";
|
||||||
import "@/components/digital-login.css";
|
import "@/components/digital-login.css";
|
||||||
@@ -31,9 +31,9 @@ export default function LoginPage() {
|
|||||||
<section className="stellar-login-panel">
|
<section className="stellar-login-panel">
|
||||||
<span className="stellar-login-star">✧</span>
|
<span className="stellar-login-star">✧</span>
|
||||||
<h2>欢迎回到星港</h2>
|
<h2>欢迎回到星港</h2>
|
||||||
<p>使用你的现有账号,继续未完的故事。</p>
|
<p>使用你的星港账号,继续未完的故事。</p>
|
||||||
<LoginForm />
|
<LoginForm />
|
||||||
<small>私人数字人空间 · 不开放公开注册</small>
|
<small>账号由管理员开通 · 与后台账号独立</small>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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("");
|
||||||
}
|
}
|
||||||
@@ -982,9 +992,6 @@ export function DigitalHome({
|
|||||||
onChange={() => onChange(p.id || undefined)}
|
onChange={() => onChange(p.id || undefined)}
|
||||||
/>
|
/>
|
||||||
<span className="dh-style-card">
|
<span className="dh-style-card">
|
||||||
<span className="dh-style-symbol" aria-hidden="true">
|
|
||||||
{p.id ? <WandSparkles /> : <Sparkles />}
|
|
||||||
</span>
|
|
||||||
<span className="dh-style-copy">
|
<span className="dh-style-copy">
|
||||||
<strong>{p.name}</strong>
|
<strong>{p.name}</strong>
|
||||||
<small>{p.description || "以这套风格继续你们的故事。"}</small>
|
<small>{p.description || "以这套风格继续你们的故事。"}</small>
|
||||||
@@ -1766,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>
|
||||||
|
|||||||
+79
-42
@@ -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);
|
||||||
@@ -1179,8 +1226,8 @@
|
|||||||
}
|
}
|
||||||
.dh-style-options {
|
.dh-style-options {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: minmax(0, 1fr);
|
||||||
gap: 10px;
|
gap: 0;
|
||||||
}
|
}
|
||||||
.dh-style-option {
|
.dh-style-option {
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -1188,10 +1235,6 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
}
|
}
|
||||||
.dh-style-option:first-child,
|
|
||||||
.dh-style-option:last-child:nth-child(even) {
|
|
||||||
grid-column: 1 / -1;
|
|
||||||
}
|
|
||||||
.dh-style-option > input {
|
.dh-style-option > input {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
@@ -1205,41 +1248,26 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
height: 100%;
|
min-height: 72px;
|
||||||
min-height: 88px;
|
padding: 14px 10px;
|
||||||
padding: 15px 13px;
|
border: 0;
|
||||||
border: 1px solid #ffffff17;
|
border-bottom: 1px solid var(--dh-line);
|
||||||
border-radius: 13px;
|
border-radius: 0;
|
||||||
background: color-mix(in srgb, var(--dh-soft) 60%, var(--dh-panel));
|
background: transparent;
|
||||||
transition:
|
transition:
|
||||||
border-color 160ms,
|
border-color 160ms,
|
||||||
background 160ms;
|
background 160ms;
|
||||||
}
|
}
|
||||||
.dh-style-option:hover .dh-style-card {
|
.dh-style-option:hover .dh-style-card {
|
||||||
border-color: color-mix(in srgb, var(--dh-accent) 55%, transparent);
|
background: #ffffff04;
|
||||||
}
|
}
|
||||||
.dh-style-option > input:checked + .dh-style-card {
|
.dh-style-option > input:checked + .dh-style-card {
|
||||||
border-color: var(--dh-accent);
|
background: color-mix(in srgb, var(--dh-accent) 7%, transparent);
|
||||||
background: color-mix(in srgb, var(--dh-accent) 9%, var(--dh-panel));
|
|
||||||
}
|
}
|
||||||
.dh-style-option > input:focus-visible + .dh-style-card {
|
.dh-style-option > input:focus-visible + .dh-style-card {
|
||||||
outline: 2px solid var(--dh-accent);
|
outline: 2px solid var(--dh-accent);
|
||||||
outline-offset: 3px;
|
outline-offset: 3px;
|
||||||
}
|
}
|
||||||
.dh-style-symbol {
|
|
||||||
display: grid;
|
|
||||||
flex: none;
|
|
||||||
place-items: center;
|
|
||||||
width: 29px;
|
|
||||||
height: 29px;
|
|
||||||
color: var(--dh-accent);
|
|
||||||
background: color-mix(in srgb, var(--dh-accent) 10%, transparent);
|
|
||||||
border-radius: 9px;
|
|
||||||
}
|
|
||||||
.dh-style-symbol svg {
|
|
||||||
width: 15px;
|
|
||||||
height: 15px;
|
|
||||||
}
|
|
||||||
.dh-style-copy {
|
.dh-style-copy {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
@@ -1266,8 +1294,7 @@
|
|||||||
height: 17px;
|
height: 17px;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
color: transparent;
|
color: transparent;
|
||||||
border: 1px solid #ffffff30;
|
border: 0;
|
||||||
border-radius: 50%;
|
|
||||||
}
|
}
|
||||||
.dh-style-check svg {
|
.dh-style-check svg {
|
||||||
width: 11px;
|
width: 11px;
|
||||||
@@ -1275,9 +1302,8 @@
|
|||||||
stroke-width: 3;
|
stroke-width: 3;
|
||||||
}
|
}
|
||||||
.dh-style-option > input:checked + .dh-style-card .dh-style-check {
|
.dh-style-option > input:checked + .dh-style-card .dh-style-check {
|
||||||
color: var(--dh-accent-ink);
|
color: var(--dh-accent);
|
||||||
background: var(--dh-accent);
|
background: transparent;
|
||||||
border-color: var(--dh-accent);
|
|
||||||
}
|
}
|
||||||
@media (width <= 600px) {
|
@media (width <= 600px) {
|
||||||
.dh-style-options {
|
.dh-style-options {
|
||||||
@@ -1367,18 +1393,18 @@
|
|||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
.dh-selection-sheet .dh-checkbox {
|
.dh-selection-sheet .dh-checkbox {
|
||||||
min-height: 74px;
|
min-height: 70px;
|
||||||
padding: 14px;
|
padding: 14px 10px;
|
||||||
margin: 0 0 10px;
|
margin: 0;
|
||||||
border: 1px solid #ffffff17;
|
border: 0;
|
||||||
border-radius: 13px;
|
border-bottom: 1px solid var(--dh-line);
|
||||||
|
border-radius: 0;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.dh-selection-sheet .dh-checkbox.is-selected {
|
.dh-selection-sheet .dh-checkbox.is-selected {
|
||||||
background: color-mix(in srgb, var(--dh-accent) 9%, var(--dh-panel));
|
background: color-mix(in srgb, var(--dh-accent) 7%, transparent);
|
||||||
border-color: var(--dh-accent);
|
|
||||||
}
|
}
|
||||||
.dh-selection-sheet .dh-checkbox:focus-within {
|
.dh-selection-sheet .dh-checkbox:has(input:focus-visible) {
|
||||||
outline: 2px solid var(--dh-accent);
|
outline: 2px solid var(--dh-accent);
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
@@ -2333,3 +2359,14 @@ body:has(.dh-app) .environment-badge {
|
|||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 世界书与风格统一使用平面列表,选中只保留轻底色和一个勾选标记。 */
|
||||||
|
.dh-settings .dh-book-picker {
|
||||||
|
border: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.dh-checkbox input {
|
||||||
|
flex: none;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
/** 复用原有账号登录,成功后进入数字人空间。 */
|
/** 独立星港用户账号登录,成功后进入数字人空间。 */
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { Eye, EyeOff, LockKeyhole, Smartphone } from "lucide-react";
|
import { Eye, EyeOff, LockKeyhole, Smartphone } from "lucide-react";
|
||||||
import { FormEvent, useState } from "react";
|
import { FormEvent, useState } from "react";
|
||||||
|
|
||||||
/** 现有账号的登录表单,不保存明文密码。 */
|
/** 独立用户的登录表单,不保存明文密码。 */
|
||||||
export function LoginForm() {
|
export function LoginForm() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
|||||||
@@ -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 = {
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
export type AccountType = "SUPER_ADMIN" | "EMPLOYEE";
|
/** 前台身份与业务协议,数字人账号使用独立 DIGITAL_USER 类型。 */
|
||||||
|
export type AccountType = "SUPER_ADMIN" | "EMPLOYEE" | "DIGITAL_USER";
|
||||||
|
|
||||||
export type Role = {
|
export type Role = {
|
||||||
id: number;
|
id: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user