feat(users): 支持恢复用户已删除会话 #27
@@ -277,3 +277,5 @@ pnpm build
|
|||||||
`src/api/access.ts` 定义 C 端用户、会话和消息响应类型。消息记录第1页为最新内容,每页按发送顺序展示,支持刷新、分页和生成状态查看。原实验账号页面 `/digital/experiment-users` 更名为「实验用户分组」,只针对 C 端用户配置实验。
|
`src/api/access.ts` 定义 C 端用户、会话和消息响应类型。消息记录第1页为最新内容,每页按发送顺序展示,支持刷新、分页和生成状态查看。原实验账号页面 `/digital/experiment-users` 更名为「实验用户分组」,只针对 C 端用户配置实验。
|
||||||
|
|
||||||
用户列表展示账号的 NSFW 开关;创建用户默认开启,编辑用户可单独开启或关闭。与前台「我的」读取和修改同一份服务端账号偏好,不覆盖收藏、称呼或身份背景。已有账号未保存该字段时默认开启,游客的登录限制不变;需与 `access-manage` 配套发布。
|
用户列表展示账号的 NSFW 开关;创建用户默认开启,编辑用户可单独开启或关闭。与前台「我的」读取和修改同一份服务端账号偏好,不覆盖收藏、称呼或身份背景。已有账号未保存该字段时默认开启,游客的登录限制不变;需与 `access-manage` 配套发布。
|
||||||
|
|
||||||
|
聊天历史中的“前台已删除”显示删除时间,管理员可在会话详情通过“恢复给用户”恢复可见性。接口校验用户归属并记录审计,原消息不重写。
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/** 独立 C 端用户管理:开户、内容偏好、停用、改密与区分对白/叙述的持久化聊天记录。 */
|
/** 独立 C 端用户管理:开户、内容偏好、停用、改密与区分对白/叙述的持久化聊天记录。 */
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import DigitalMessageText from "@/components/DigitalMessageText.vue";
|
import DigitalMessageText from "@/components/DigitalMessageText.vue";
|
||||||
import {
|
import {
|
||||||
digital,
|
digital,
|
||||||
@@ -171,6 +171,40 @@ async function loadConversations() {
|
|||||||
if (version === chatVersion) conversationLoading.value = false;
|
if (version === chatVersion) conversationLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const restoring = ref(false);
|
||||||
|
/** 恢复仅作用于选中的用户和会话,切换用户后的迟到结果不能覆盖当前详情。 */
|
||||||
|
async function restoreChat() {
|
||||||
|
if (!selected.value || !active.value?.deletedAt || restoring.value) return;
|
||||||
|
const user = selected.value.id,
|
||||||
|
conversation = active.value.id;
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
"恢复后用户可在前台继续查看这段对话,原消息不会改变。",
|
||||||
|
"恢复会话",
|
||||||
|
{ type: "info" }
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
restoring.value = true;
|
||||||
|
try {
|
||||||
|
await digital(
|
||||||
|
`users/${user}/conversations/${conversation}/restore`,
|
||||||
|
"post",
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
if (selected.value?.id === user) {
|
||||||
|
if (active.value?.id === conversation)
|
||||||
|
active.value = { ...active.value, deletedAt: null };
|
||||||
|
await loadConversations();
|
||||||
|
}
|
||||||
|
ElMessage.success("会话已恢复");
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error(e instanceof Error ? e.message : "恢复失败");
|
||||||
|
} finally {
|
||||||
|
restoring.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
async function chooseConversation(c: UserConversation) {
|
async function chooseConversation(c: UserConversation) {
|
||||||
active.value = c;
|
active.value = c;
|
||||||
messagePage.value = 1;
|
messagePage.value = 1;
|
||||||
@@ -436,7 +470,7 @@ onMounted(load);
|
|||||||
><span
|
><span
|
||||||
>{{ c.title
|
>{{ c.title
|
||||||
}}<el-tag v-if="c.deletedAt" size="small" type="info"
|
}}<el-tag v-if="c.deletedAt" size="small" type="info"
|
||||||
>前台已删除</el-tag
|
>前台已删除 · {{ time(c.deletedAt) }}</el-tag
|
||||||
></span
|
></span
|
||||||
><small
|
><small
|
||||||
>{{ c.messages }} 条消息 · {{ time(c.updatedAt) }}</small
|
>{{ c.messages }} 条消息 · {{ time(c.updatedAt) }}</small
|
||||||
@@ -454,6 +488,12 @@ onMounted(load);
|
|||||||
<template v-if="active"
|
<template v-if="active"
|
||||||
><header>
|
><header>
|
||||||
<strong>{{ active.characterName }} · {{ active.title }}</strong
|
<strong>{{ active.characterName }} · {{ active.title }}</strong
|
||||||
|
><el-button
|
||||||
|
v-if="active.deletedAt"
|
||||||
|
size="small"
|
||||||
|
:loading="restoring"
|
||||||
|
@click="restoreChat"
|
||||||
|
>恢复给用户</el-button
|
||||||
><el-button size="small" @click="loadMessages"
|
><el-button size="small" @click="loadMessages"
|
||||||
>刷新记录</el-button
|
>刷新记录</el-button
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user