|
|
|
@@ -1,7 +1,7 @@
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
/** 独立 C 端用户管理:开户、内容偏好、停用、改密与区分对白/叙述的持久化聊天记录。 */
|
|
|
|
|
import { onMounted, ref } from "vue";
|
|
|
|
|
import { ElMessage } from "element-plus";
|
|
|
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
|
|
import DigitalMessageText from "@/components/DigitalMessageText.vue";
|
|
|
|
|
import {
|
|
|
|
|
digital,
|
|
|
|
@@ -171,6 +171,40 @@ async function loadConversations() {
|
|
|
|
|
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) {
|
|
|
|
|
active.value = c;
|
|
|
|
|
messagePage.value = 1;
|
|
|
|
@@ -436,7 +470,7 @@ onMounted(load);
|
|
|
|
|
><span
|
|
|
|
|
>{{ c.title
|
|
|
|
|
}}<el-tag v-if="c.deletedAt" size="small" type="info"
|
|
|
|
|
>前台已删除</el-tag
|
|
|
|
|
>前台已删除 · {{ time(c.deletedAt) }}</el-tag
|
|
|
|
|
></span
|
|
|
|
|
><small
|
|
|
|
|
>{{ c.messages }} 条消息 · {{ time(c.updatedAt) }}</small
|
|
|
|
@@ -454,6 +488,12 @@ onMounted(load);
|
|
|
|
|
<template v-if="active"
|
|
|
|
|
><header>
|
|
|
|
|
<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
|
|
|
|
|
>
|
|
|
|
|