Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 098ecee594 | |||
| 6a8407da48 | |||
| b87b2cad73 | |||
| 6a420983f7 | |||
| 30b52b5d73 |
@@ -226,7 +226,7 @@ pnpm build
|
||||
|
||||
标签页图标采用 `public/stellar-icon-v2.svg`,同时提供多尺寸 `favicon.ico`、180/192/512 PNG,覆盖浏览器、Apple 主屏幕和 PWA。版本化资源路径用于刷新旧图标缓存。
|
||||
|
||||
「实验类型」「测试方案」「实验用户分组」是独立菜单。新类型填写自己的稳定标识与数据契约,先接入应用、收到实际调用并人工确认验收,再启动方案;未接入类型可存草稿。系统不预置 UI/对话类型;自建类型需要真实前台接入,不再使用固定业务功能的场景下拉框。方案行可直接跳转该方案的用户管理,用户预览不写分组、不记曝光,人工指定有原因、时效和审计。前台只消费决策。
|
||||
「实验类型」「测试方案」「用户管理」是独立菜单。新类型填写自己的稳定标识与数据契约,先接入应用、收到实际调用并人工确认验收,再启动方案;未接入类型可存草稿。系统不预置 UI/对话类型;自建类型需要真实前台接入,不再使用固定业务功能的场景下拉框。方案行可直接跳转该方案的用户管理,用户预览不写分组、不记曝光,人工指定有原因、时效和审计。前台只消费决策。
|
||||
|
||||
比例统一按百分比输入,50代表50%,保留0.01%精度;既有用户分组保持不变。
|
||||
|
||||
@@ -247,11 +247,3 @@ pnpm build
|
||||
用户分组管理提供独立的方案概况、用户查找和指定入口。列表覆盖全部真实账号,不把只读预计结果称为实际入组;手动指定明确显示草稿待生效、人群不符、已过期等状态。不符合目标人群的账号须明确选择“作为测试账号加入”,不修改其他用户的人群范围。取消指定或到期后沿用原自动分组,否则按当前方案规则计算。
|
||||
|
||||
教程目录固定在阅读区左侧,右侧正文独立滚动并自动高亮当前章节;点击目录平滑定位,目录过长时会自动滚动到当前项。窄屏将目录置于正文上方,保留正文滚动与章节同步。
|
||||
|
||||
### C 端用户管理
|
||||
|
||||
`src/views/digital/users.vue` 对应 `/digital/users`,用于创建独立 C 端账号、搜索用户、修改昵称/状态、重置密码,以及按用户查看数字人会话和原始消息。账号由后台开通,无公开注册;与管理员/员工账号分别鉴权,重置 C 端密码不影响后台。停用保留聊天记录。
|
||||
|
||||
`src/api/access.ts` 定义 C 端用户、会话和消息响应类型。消息记录第1页为最新内容,每页按发送顺序展示,支持刷新、分页和生成状态查看。原实验账号页面 `/digital/experiment-users` 更名为「实验用户分组」,只针对 C 端用户配置实验。
|
||||
|
||||
用户列表展示账号的 NSFW 开关;创建用户默认开启,编辑用户可单独开启或关闭。与前台「我的」读取和修改同一份服务端账号偏好,不覆盖收藏、称呼或身份背景。已有账号未保存该字段时默认开启,游客的登录限制不变;需与 `access-manage` 配套发布。
|
||||
|
||||
@@ -122,7 +122,7 @@ applyUiVersion(decision.value === true ? "new" : "old");
|
||||
|
||||
## 6. 查看账号分组,指定 A/B 做对照
|
||||
|
||||
从方案行进入“实验用户分组”,确认当前方案,再搜索测试账号。
|
||||
从方案行进入“用户管理”,确认当前方案,再搜索测试账号。
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
{
|
||||
"id": "users",
|
||||
"title": "6. 查看账号分组,指定 A/B 做对照",
|
||||
"lead": "从方案行进入“实验用户分组”,确认当前方案,再搜索测试账号。",
|
||||
"lead": "从方案行进入“用户管理”,确认当前方案,再搜索测试账号。",
|
||||
"bullets": [
|
||||
"先选择本次方案,再按账号、姓名或用户名查询;用户列表包含未参与实验的账号。“预计自动分组”只读,首次实际调用后才保存入组,查询不会计曝光。",
|
||||
"点击“指定用户分组”查找账号,或在用户行点击“指定分组/修改指定”。每组直接展示返回值和自动分流比例,0% 组也可手动指定。有效期须在未来30天内,操作原因至少2字。",
|
||||
|
||||
+1
-36
@@ -1091,7 +1091,7 @@ export type Result<T> = { success: boolean; data: T };
|
||||
/** 数字人后台 API,复用已有 JWT 拦截器。 */
|
||||
export async function digital<T>(
|
||||
path: string,
|
||||
method: "get" | "post" | "put" | "patch" | "delete" = "get",
|
||||
method: "get" | "post" | "put" | "delete" = "get",
|
||||
data?: unknown
|
||||
): Promise<T> {
|
||||
try {
|
||||
@@ -1224,38 +1224,3 @@ export type ExperimentUser = {
|
||||
};
|
||||
assignment: null | { variant: string; createdAt: string };
|
||||
};
|
||||
|
||||
/** 独立 C 端用户的后台公开资料,不含密码/令牌或员工权限。 */
|
||||
export type DigitalUser = {
|
||||
id: number;
|
||||
account: string;
|
||||
username: string;
|
||||
displayName: string;
|
||||
status: "ACTIVE" | "INACTIVE";
|
||||
/** 账号未保存内容偏好时默认开启,后端在生成时读取实际值。 */
|
||||
nsfwEnabled?: boolean;
|
||||
createdAt: string;
|
||||
lastLoginAt: string | null;
|
||||
conversations: number;
|
||||
messages: number;
|
||||
};
|
||||
/** 用户所属会话的只读摘要。 */
|
||||
export type UserConversation = {
|
||||
id: string;
|
||||
title: string;
|
||||
characterId: string;
|
||||
characterName: string;
|
||||
messages: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
/** 持久化聊天消息;包括已停止、失败和被替换的历史版本。 */
|
||||
export type UserChatMessage = {
|
||||
id: string;
|
||||
role: "user" | "assistant";
|
||||
content: string;
|
||||
status: string;
|
||||
pinned: number;
|
||||
sequenceId: number;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
@@ -8,12 +8,6 @@ export default {
|
||||
redirect: "/digital/content",
|
||||
meta: { title: "数字人运营", icon: "ep/chat-dot-round", rank: 0 },
|
||||
children: [
|
||||
{
|
||||
path: "/digital/users",
|
||||
name: "DigitalUsers",
|
||||
component: () => import("@/views/digital/users.vue"),
|
||||
meta: { title: "用户管理", permission: "*" }
|
||||
},
|
||||
{
|
||||
path: "/digital/content",
|
||||
name: "DigitalContent",
|
||||
@@ -47,7 +41,7 @@ export default {
|
||||
path: "/digital/experiment-users",
|
||||
name: "DigitalExperimentUsers",
|
||||
component: () => import("@/views/digital/experiment-users.vue"),
|
||||
meta: { title: "实验用户分组", permission: "*" }
|
||||
meta: { title: "用户管理", permission: "*" }
|
||||
}
|
||||
]
|
||||
} satisfies RouteConfigsTable;
|
||||
|
||||
@@ -196,7 +196,7 @@ function jump(id: string) {
|
||||
@click="router.push('/digital/experiments')"
|
||||
>去测试方案</el-button
|
||||
><el-button @click="router.push('/digital/experiment-users')"
|
||||
>去实验用户分组</el-button
|
||||
>去用户管理</el-button
|
||||
>
|
||||
</footer>
|
||||
</article>
|
||||
|
||||
@@ -331,8 +331,8 @@ onMounted(async () => {
|
||||
<div class="users-page">
|
||||
<div class="heading">
|
||||
<div>
|
||||
<h2>实验用户分组</h2>
|
||||
<p>选择测试方案,查看独立 C 端用户的分组,或为测试账号指定分组。</p>
|
||||
<h2>用户分组管理</h2>
|
||||
<p>选择测试方案,查看用户分组,或为测试账号指定分组。</p>
|
||||
</div>
|
||||
<el-button :loading="loading" @click="load">刷新</el-button>
|
||||
</div>
|
||||
|
||||
@@ -328,7 +328,7 @@ onMounted(load);
|
||||
<div>
|
||||
<h2>测试方案</h2>
|
||||
<p>
|
||||
配置测什么、给谁看、分配多少流量;账号查询与人工分组在「实验用户分组」。
|
||||
配置测什么、给谁看、分配多少流量;账号查询与人工分组在「用户管理」。
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
@@ -337,7 +337,7 @@ onMounted(load);
|
||||
><el-button @click="router.push('/digital/experiment-types')"
|
||||
>实验类型</el-button
|
||||
><el-button @click="router.push('/digital/experiment-users')"
|
||||
>实验用户分组</el-button
|
||||
>用户管理</el-button
|
||||
><el-button type="primary" @click="open()">创建测试方案</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -462,7 +462,7 @@ onMounted(load);
|
||||
><el-button link type="primary" @click="inspect(row)"
|
||||
>效果与审计</el-button
|
||||
><el-button link type="primary" @click="users(row)"
|
||||
>实验用户分组</el-button
|
||||
>用户管理</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
></el-table
|
||||
|
||||
@@ -1,651 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/** 独立 C 端用户管理:开户、内容偏好、停用、改密与持久化聊天记录。 */
|
||||
import { onMounted, ref } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import {
|
||||
digital,
|
||||
type DigitalUser,
|
||||
type UserConversation,
|
||||
type UserChatMessage
|
||||
} from "@/api/access";
|
||||
const q = ref(""),
|
||||
status = ref(""),
|
||||
page = ref(1),
|
||||
total = ref(0),
|
||||
loading = ref(false),
|
||||
users = ref<DigitalUser[]>([]);
|
||||
const creating = ref(false),
|
||||
saving = ref(false),
|
||||
createForm = ref({
|
||||
username: "",
|
||||
displayName: "",
|
||||
password: "",
|
||||
nsfwEnabled: true
|
||||
});
|
||||
const editing = ref<DigitalUser | null>(null),
|
||||
editForm = ref({ displayName: "", status: "ACTIVE", nsfwEnabled: true });
|
||||
const resetTarget = ref<DigitalUser | null>(null),
|
||||
newPassword = ref("");
|
||||
const selected = ref<DigitalUser | null>(null),
|
||||
history = ref(false),
|
||||
conversations = ref<UserConversation[]>([]),
|
||||
conversationPage = ref(1),
|
||||
conversationTotal = ref(0),
|
||||
conversationLoading = ref(false);
|
||||
const active = ref<UserConversation | null>(null),
|
||||
messages = ref<UserChatMessage[]>([]),
|
||||
messagePage = ref(1),
|
||||
messageTotal = ref(0),
|
||||
messageLoading = ref(false);
|
||||
let listVersion = 0,
|
||||
chatVersion = 0,
|
||||
messageVersion = 0;
|
||||
const time = (value: string | null) =>
|
||||
value ? new Date(value).toLocaleString() : "—";
|
||||
const states: Record<string, string> = {
|
||||
complete: "已完成",
|
||||
stopped: "已停止",
|
||||
failed: "生成失败",
|
||||
generating: "生成中",
|
||||
superseded: "旧版本"
|
||||
};
|
||||
/** 请求编号避免快速切换用户时把旧请求结果写进新用户的聊天面板。 */
|
||||
async function load() {
|
||||
const version = ++listVersion;
|
||||
loading.value = true;
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
q: q.value,
|
||||
page: String(page.value),
|
||||
size: "20"
|
||||
});
|
||||
if (status.value) params.set("status", status.value);
|
||||
const r = await digital<{ items: DigitalUser[]; total: number }>(
|
||||
`users?${params}`
|
||||
);
|
||||
if (version === listVersion) {
|
||||
users.value = r.items;
|
||||
total.value = r.total;
|
||||
}
|
||||
} catch (e) {
|
||||
ElMessage.error(e instanceof Error ? e.message : "加载失败");
|
||||
} finally {
|
||||
if (version === listVersion) loading.value = false;
|
||||
}
|
||||
}
|
||||
function search() {
|
||||
page.value = 1;
|
||||
load();
|
||||
}
|
||||
async function create() {
|
||||
if (
|
||||
!createForm.value.username.trim() ||
|
||||
!createForm.value.displayName.trim() ||
|
||||
createForm.value.password.length < 8
|
||||
)
|
||||
return ElMessage.warning("请填写账号、昵称及至少8位密码");
|
||||
saving.value = true;
|
||||
try {
|
||||
await digital("users", "post", createForm.value);
|
||||
creating.value = false;
|
||||
createForm.value = {
|
||||
username: "",
|
||||
displayName: "",
|
||||
password: "",
|
||||
nsfwEnabled: true
|
||||
};
|
||||
search();
|
||||
ElMessage.success("C 端账号已创建,可在星港前台登录");
|
||||
} catch (e) {
|
||||
ElMessage.error(e instanceof Error ? e.message : "创建失败");
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
function edit(user: DigitalUser) {
|
||||
editing.value = user;
|
||||
editForm.value = {
|
||||
displayName: user.displayName,
|
||||
status: user.status,
|
||||
nsfwEnabled: user.nsfwEnabled ?? true
|
||||
};
|
||||
}
|
||||
async function saveEdit() {
|
||||
if (!editing.value) return;
|
||||
saving.value = true;
|
||||
try {
|
||||
await digital(`users/${editing.value.id}`, "patch", editForm.value);
|
||||
editing.value = null;
|
||||
await load();
|
||||
ElMessage.success("用户资料已保存");
|
||||
} catch (e) {
|
||||
ElMessage.error(e instanceof Error ? e.message : "保存失败");
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
async function resetPassword() {
|
||||
if (!resetTarget.value) return;
|
||||
if (newPassword.value.length < 8) return ElMessage.warning("密码至少8位");
|
||||
saving.value = true;
|
||||
try {
|
||||
await digital(`users/${resetTarget.value.id}/password`, "post", {
|
||||
password: newPassword.value
|
||||
});
|
||||
newPassword.value = "";
|
||||
resetTarget.value = null;
|
||||
ElMessage.success("密码已重置,该用户需要重新登录");
|
||||
} catch (e) {
|
||||
ElMessage.error(e instanceof Error ? e.message : "重置失败");
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
async function openHistory(user: DigitalUser) {
|
||||
selected.value = user;
|
||||
history.value = true;
|
||||
conversationPage.value = 1;
|
||||
active.value = null;
|
||||
messages.value = [];
|
||||
++messageVersion;
|
||||
await loadConversations();
|
||||
}
|
||||
async function loadConversations() {
|
||||
if (!selected.value) return;
|
||||
const version = ++chatVersion;
|
||||
conversationLoading.value = true;
|
||||
conversations.value = [];
|
||||
try {
|
||||
const r = await digital<{ items: UserConversation[]; total: number }>(
|
||||
`users/${selected.value.id}/conversations?page=${conversationPage.value}&size=20`
|
||||
);
|
||||
if (version === chatVersion) {
|
||||
conversations.value = r.items;
|
||||
conversationTotal.value = r.total;
|
||||
}
|
||||
} catch (e) {
|
||||
if (version === chatVersion)
|
||||
ElMessage.error(e instanceof Error ? e.message : "会话加载失败");
|
||||
} finally {
|
||||
if (version === chatVersion) conversationLoading.value = false;
|
||||
}
|
||||
}
|
||||
async function chooseConversation(c: UserConversation) {
|
||||
active.value = c;
|
||||
messagePage.value = 1;
|
||||
await loadMessages();
|
||||
}
|
||||
async function loadMessages() {
|
||||
if (!selected.value || !active.value) return;
|
||||
const version = ++messageVersion;
|
||||
messageLoading.value = true;
|
||||
messages.value = [];
|
||||
try {
|
||||
const r = await digital<{ items: UserChatMessage[]; total: number }>(
|
||||
`users/${selected.value.id}/conversations/${active.value.id}/messages?page=${messagePage.value}&size=30`
|
||||
);
|
||||
if (version === messageVersion) {
|
||||
messages.value = r.items;
|
||||
messageTotal.value = r.total;
|
||||
}
|
||||
} catch (e) {
|
||||
if (version === messageVersion)
|
||||
ElMessage.error(e instanceof Error ? e.message : "聊天记录加载失败");
|
||||
} finally {
|
||||
if (version === messageVersion) messageLoading.value = false;
|
||||
}
|
||||
}
|
||||
function closeHistory() {
|
||||
++chatVersion;
|
||||
++messageVersion;
|
||||
selected.value = null;
|
||||
active.value = null;
|
||||
messages.value = [];
|
||||
}
|
||||
onMounted(load);
|
||||
</script>
|
||||
<template>
|
||||
<div class="customer-page">
|
||||
<div class="heading">
|
||||
<div>
|
||||
<h2>用户管理</h2>
|
||||
<p>C 端账号独立于后台管理员,由后台开通。聊天记录按用户和会话查看。</p>
|
||||
</div>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="
|
||||
createForm = {
|
||||
username: '',
|
||||
displayName: '',
|
||||
password: '',
|
||||
nsfwEnabled: true
|
||||
};
|
||||
creating = true;
|
||||
"
|
||||
>创建 C 端用户</el-button
|
||||
>
|
||||
</div>
|
||||
<el-card shadow="never"
|
||||
><div class="filters">
|
||||
<el-input
|
||||
v-model="q"
|
||||
clearable
|
||||
placeholder="搜索账号、昵称或用户 ID"
|
||||
@keyup.enter="search"
|
||||
@clear="search"
|
||||
/><el-select
|
||||
v-model="status"
|
||||
clearable
|
||||
placeholder="全部状态"
|
||||
@change="search"
|
||||
><el-option value="ACTIVE" label="正常" /><el-option
|
||||
value="INACTIVE"
|
||||
label="已停用" /></el-select
|
||||
><el-button :loading="loading" @click="search">查询</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="users"
|
||||
empty-text="暂无 C 端用户,可点击上方创建"
|
||||
><el-table-column label="用户" min-width="220"
|
||||
><template #default="{ row }"
|
||||
><strong>{{ row.displayName }}</strong>
|
||||
<p class="secondary">
|
||||
{{ row.username }} · UID {{ row.id }}
|
||||
</p></template
|
||||
></el-table-column
|
||||
><el-table-column label="状态" width="100"
|
||||
><template #default="{ row }"
|
||||
><el-tag :type="row.status === 'ACTIVE' ? 'success' : 'info'">{{
|
||||
row.status === "ACTIVE" ? "正常" : "已停用"
|
||||
}}</el-tag></template
|
||||
></el-table-column
|
||||
><el-table-column label="NSFW" width="100"
|
||||
><template #default="{ row }"
|
||||
><el-tag :type="row.nsfwEnabled === false ? 'info' : 'success'">{{
|
||||
row.nsfwEnabled === false ? "已关闭" : "已开启"
|
||||
}}</el-tag></template
|
||||
></el-table-column
|
||||
><el-table-column
|
||||
prop="conversations"
|
||||
label="会话数"
|
||||
width="90"
|
||||
/><el-table-column
|
||||
prop="messages"
|
||||
label="消息数"
|
||||
width="90"
|
||||
/><el-table-column label="创建时间" min-width="175"
|
||||
><template #default="{ row }">{{
|
||||
time(row.createdAt)
|
||||
}}</template></el-table-column
|
||||
><el-table-column label="最近登录" min-width="175"
|
||||
><template #default="{ row }">{{
|
||||
time(row.lastLoginAt)
|
||||
}}</template></el-table-column
|
||||
><el-table-column label="操作" min-width="235" fixed="right"
|
||||
><template #default="{ row }"
|
||||
><el-button link type="primary" @click="openHistory(row)"
|
||||
>聊天记录</el-button
|
||||
><el-button link type="primary" @click="edit(row)">编辑</el-button
|
||||
><el-button
|
||||
link
|
||||
type="warning"
|
||||
@click="
|
||||
resetTarget = row;
|
||||
newPassword = '';
|
||||
"
|
||||
>重置密码</el-button
|
||||
></template
|
||||
></el-table-column
|
||||
></el-table
|
||||
>
|
||||
<el-pagination
|
||||
v-model:current-page="page"
|
||||
:page-size="20"
|
||||
:total="total"
|
||||
layout="total, prev, pager, next"
|
||||
@current-change="load"
|
||||
/>
|
||||
</el-card>
|
||||
<el-dialog
|
||||
v-model="creating"
|
||||
title="创建 C 端用户"
|
||||
width="min(520px,95vw)"
|
||||
:close-on-click-modal="false"
|
||||
><el-form label-position="top"
|
||||
><el-form-item label="登录账号" required
|
||||
><el-input
|
||||
v-model="createForm.username"
|
||||
maxlength="120"
|
||||
placeholder="字母、数字、手机号或邮箱"
|
||||
autocomplete="off" /></el-form-item
|
||||
><el-form-item label="用户昵称" required
|
||||
><el-input
|
||||
v-model="createForm.displayName"
|
||||
maxlength="120" /></el-form-item
|
||||
><el-form-item label="初始密码" required
|
||||
><el-input
|
||||
v-model="createForm.password"
|
||||
type="password"
|
||||
show-password
|
||||
maxlength="128"
|
||||
placeholder="至少8位"
|
||||
autocomplete="new-password" /></el-form-item
|
||||
><el-form-item label="NSFW 成人内容"
|
||||
><el-switch
|
||||
v-model="createForm.nsfwEnabled"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
/>
|
||||
<p class="secondary">
|
||||
登录账号默认开启,用户可在前台保存自己的选择。
|
||||
</p>
|
||||
</el-form-item></el-form
|
||||
><template #footer
|
||||
><el-button @click="creating = false">取消</el-button
|
||||
><el-button type="primary" :loading="saving" @click="create"
|
||||
>创建用户</el-button
|
||||
></template
|
||||
></el-dialog
|
||||
>
|
||||
<el-dialog
|
||||
:model-value="!!editing"
|
||||
title="编辑 C 端用户"
|
||||
width="min(520px,95vw)"
|
||||
@close="editing = null"
|
||||
><el-form label-position="top"
|
||||
><el-form-item label="登录账号">{{ editing?.username }}</el-form-item
|
||||
><el-form-item label="用户昵称"
|
||||
><el-input
|
||||
v-model="editForm.displayName"
|
||||
maxlength="120" /></el-form-item
|
||||
><el-form-item label="账号状态"
|
||||
><el-radio-group v-model="editForm.status"
|
||||
><el-radio value="ACTIVE">正常</el-radio
|
||||
><el-radio value="INACTIVE">停用</el-radio></el-radio-group
|
||||
></el-form-item
|
||||
><el-form-item label="NSFW 成人内容"
|
||||
><el-switch
|
||||
v-model="editForm.nsfwEnabled"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
/>
|
||||
<p class="secondary">保存后用于该账号的后续回复。</p>
|
||||
</el-form-item></el-form
|
||||
><el-alert
|
||||
title="停用后用户无法登录,已有会话记录仍保留。"
|
||||
:closable="false"
|
||||
/><template #footer
|
||||
><el-button @click="editing = null">取消</el-button
|
||||
><el-button type="primary" :loading="saving" @click="saveEdit"
|
||||
>保存</el-button
|
||||
></template
|
||||
></el-dialog
|
||||
>
|
||||
<el-dialog
|
||||
:model-value="!!resetTarget"
|
||||
title="重置 C 端用户密码"
|
||||
width="min(520px,95vw)"
|
||||
@close="
|
||||
resetTarget = null;
|
||||
newPassword = '';
|
||||
"
|
||||
><p>{{ resetTarget?.displayName }} · {{ resetTarget?.username }}</p>
|
||||
<el-input
|
||||
v-model="newPassword"
|
||||
type="password"
|
||||
show-password
|
||||
maxlength="128"
|
||||
autocomplete="new-password"
|
||||
placeholder="设置至少8位新密码"
|
||||
/>
|
||||
<p class="secondary">
|
||||
重置后该 C 端账号的旧登录状态失效,不影响同名后台账号。
|
||||
</p>
|
||||
<template #footer
|
||||
><el-button @click="resetTarget = null">取消</el-button
|
||||
><el-button type="primary" :loading="saving" @click="resetPassword"
|
||||
>确认重置</el-button
|
||||
></template
|
||||
></el-dialog
|
||||
>
|
||||
<el-dialog
|
||||
v-model="history"
|
||||
:title="`${selected?.displayName ?? ''} · 聊天记录`"
|
||||
width="min(1280px,96vw)"
|
||||
top="4vh"
|
||||
@closed="closeHistory"
|
||||
>
|
||||
<div class="history-layout">
|
||||
<aside v-loading="conversationLoading" class="conversation-list">
|
||||
<p class="secondary">
|
||||
{{ selected?.username }} · {{ conversationTotal }} 个会话
|
||||
</p>
|
||||
<el-empty
|
||||
v-if="!conversations.length && !conversationLoading"
|
||||
description="暂无聊天记录"
|
||||
/><button
|
||||
v-for="c in conversations"
|
||||
:key="c.id"
|
||||
class="conversation"
|
||||
:class="{ active: active?.id === c.id }"
|
||||
@click="chooseConversation(c)"
|
||||
>
|
||||
<strong>{{ c.characterName }}</strong
|
||||
><span>{{ c.title }}</span
|
||||
><small
|
||||
>{{ c.messages }} 条消息 · {{ time(c.updatedAt) }}</small
|
||||
></button
|
||||
><el-pagination
|
||||
v-model:current-page="conversationPage"
|
||||
small
|
||||
:page-size="20"
|
||||
:total="conversationTotal"
|
||||
layout="prev, pager, next"
|
||||
@current-change="loadConversations"
|
||||
/>
|
||||
</aside>
|
||||
<section v-loading="messageLoading" class="message-pane">
|
||||
<template v-if="active"
|
||||
><header>
|
||||
<strong>{{ active.characterName }} · {{ active.title }}</strong
|
||||
><el-button size="small" @click="loadMessages"
|
||||
>刷新记录</el-button
|
||||
>
|
||||
</header>
|
||||
<p class="secondary">
|
||||
第1页为最新记录,每页按发送顺序展示;较早内容可翻页查看。共
|
||||
{{ messageTotal }} 条。
|
||||
</p>
|
||||
<div class="messages">
|
||||
<el-empty
|
||||
v-if="!messages.length && !messageLoading"
|
||||
description="此会话尚无消息"
|
||||
/>
|
||||
<article v-for="m in messages" :key="m.id" :class="m.role">
|
||||
<div class="message-meta">
|
||||
<strong>{{
|
||||
m.role === "user"
|
||||
? selected?.displayName
|
||||
: active.characterName
|
||||
}}</strong
|
||||
><time>{{ time(m.createdAt) }}</time
|
||||
><el-tag
|
||||
v-if="m.status !== 'complete'"
|
||||
size="small"
|
||||
type="info"
|
||||
>{{ states[m.status] ?? m.status }}</el-tag
|
||||
><el-tag v-if="m.pinned" size="small">已固定</el-tag>
|
||||
</div>
|
||||
<p>{{ m.content || "(未生成正文)" }}</p>
|
||||
</article>
|
||||
</div>
|
||||
<el-pagination
|
||||
v-model:current-page="messagePage"
|
||||
:page-size="30"
|
||||
:total="messageTotal"
|
||||
layout="total, prev, pager, next"
|
||||
@current-change="loadMessages" /></template
|
||||
><el-empty v-else description="选择左侧会话查看聊天内容" />
|
||||
</section>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.heading,
|
||||
.filters,
|
||||
.message-pane header {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.secondary,
|
||||
.heading p {
|
||||
margin: 6px 0;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.filters .el-input {
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.filters .el-select {
|
||||
width: 160px;
|
||||
}
|
||||
|
||||
.filters {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.el-pagination {
|
||||
justify-content: flex-end;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.history-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 280px minmax(0, 1fr);
|
||||
gap: 20px;
|
||||
height: 72vh;
|
||||
}
|
||||
|
||||
.conversation-list,
|
||||
.message-pane {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.conversation-list {
|
||||
padding-right: 12px;
|
||||
border-right: 1px solid var(--el-border-color-light);
|
||||
}
|
||||
|
||||
.conversation {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
padding: 14px 10px;
|
||||
color: var(--el-text-color-primary);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.conversation.active {
|
||||
color: var(--el-color-primary);
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
|
||||
.conversation small {
|
||||
font-size: 11px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.message-pane {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.message-pane header {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.messages {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 8px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.messages article {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.message-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.message-meta time {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.messages article p {
|
||||
padding: 12px 14px;
|
||||
margin: 6px 0;
|
||||
overflow-wrap: anywhere;
|
||||
white-space: pre-wrap;
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.messages article.user p {
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
|
||||
.conversation:focus-visible {
|
||||
outline: 2px solid var(--el-color-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
@media (width<=760px) {
|
||||
.heading,
|
||||
.filters {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.filters .el-input,
|
||||
.filters .el-select {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.history-layout {
|
||||
grid-template-rows: 180px minmax(0, 1fr);
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.conversation-list {
|
||||
padding-right: 0;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid var(--el-border-color-light);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user