feat(nsfw): 支持管理 C 端账号成人内容偏好
- src/api/access.ts: 补充 C 端账号 NSFW 偏好字段与中文注释 - src/views/digital/users.vue: 展示开关状态,创建默认开启,编辑可保存账号选择 - README.md: 说明前后台共用偏好及配套发布要求
This commit is contained in:
@@ -1232,6 +1232,8 @@ export type DigitalUser = {
|
||||
username: string;
|
||||
displayName: string;
|
||||
status: "ACTIVE" | "INACTIVE";
|
||||
/** 账号未保存内容偏好时默认开启,后端在生成时读取实际值。 */
|
||||
nsfwEnabled?: boolean;
|
||||
createdAt: string;
|
||||
lastLoginAt: string | null;
|
||||
conversations: number;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
/** 独立 C 端用户管理:开户、停用、重置密码及按用户查看持久化聊天记录。 */
|
||||
/** 独立 C 端用户管理:开户、内容偏好、停用、改密与持久化聊天记录。 */
|
||||
import { onMounted, ref } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import {
|
||||
@@ -16,9 +16,14 @@ const q = ref(""),
|
||||
users = ref<DigitalUser[]>([]);
|
||||
const creating = ref(false),
|
||||
saving = ref(false),
|
||||
createForm = ref({ username: "", displayName: "", password: "" });
|
||||
createForm = ref({
|
||||
username: "",
|
||||
displayName: "",
|
||||
password: "",
|
||||
nsfwEnabled: true
|
||||
});
|
||||
const editing = ref<DigitalUser | null>(null),
|
||||
editForm = ref({ displayName: "", status: "ACTIVE" });
|
||||
editForm = ref({ displayName: "", status: "ACTIVE", nsfwEnabled: true });
|
||||
const resetTarget = ref<DigitalUser | null>(null),
|
||||
newPassword = ref("");
|
||||
const selected = ref<DigitalUser | null>(null),
|
||||
@@ -83,7 +88,12 @@ async function create() {
|
||||
try {
|
||||
await digital("users", "post", createForm.value);
|
||||
creating.value = false;
|
||||
createForm.value = { username: "", displayName: "", password: "" };
|
||||
createForm.value = {
|
||||
username: "",
|
||||
displayName: "",
|
||||
password: "",
|
||||
nsfwEnabled: true
|
||||
};
|
||||
search();
|
||||
ElMessage.success("C 端账号已创建,可在星港前台登录");
|
||||
} catch (e) {
|
||||
@@ -94,7 +104,11 @@ async function create() {
|
||||
}
|
||||
function edit(user: DigitalUser) {
|
||||
editing.value = user;
|
||||
editForm.value = { displayName: user.displayName, status: user.status };
|
||||
editForm.value = {
|
||||
displayName: user.displayName,
|
||||
status: user.status,
|
||||
nsfwEnabled: user.nsfwEnabled ?? true
|
||||
};
|
||||
}
|
||||
async function saveEdit() {
|
||||
if (!editing.value) return;
|
||||
@@ -200,7 +214,12 @@ onMounted(load);
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="
|
||||
createForm = { username: '', displayName: '', password: '' };
|
||||
createForm = {
|
||||
username: '',
|
||||
displayName: '',
|
||||
password: '',
|
||||
nsfwEnabled: true
|
||||
};
|
||||
creating = true;
|
||||
"
|
||||
>创建 C 端用户</el-button
|
||||
@@ -241,6 +260,12 @@ onMounted(load);
|
||||
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="会话数"
|
||||
@@ -305,7 +330,17 @@ onMounted(load);
|
||||
show-password
|
||||
maxlength="128"
|
||||
placeholder="至少8位"
|
||||
autocomplete="new-password" /></el-form-item></el-form
|
||||
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"
|
||||
@@ -329,7 +364,14 @@ onMounted(load);
|
||||
><el-radio value="ACTIVE">正常</el-radio
|
||||
><el-radio value="INACTIVE">停用</el-radio></el-radio-group
|
||||
></el-form-item
|
||||
></el-form
|
||||
><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"
|
||||
|
||||
Reference in New Issue
Block a user