@@ -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 端用户 < / e l - b u t t o n
@@ -241,6 +260,12 @@ onMounted(load);
row . status === "ACTIVE" ? "正常" : "已停用"
} } < / el-tag > < / t e m p l a t e
> < / e l - t a b l e - c o l u m n
> < el-table-column label = "NSFW" width = "100"
> < template # default = "{ row }"
> < el-tag : type = "row.nsfwEnabled === false ? 'info' : 'success'" > { {
row . nsfwEnabled === false ? "已关闭" : "已开启"
} } < / el-tag > < / t e m p l a t e
> < / e l - t a b l e - c o l u m n
> < el-table-column
prop = "conversations"
label = "会话数"
@@ -305,7 +330,17 @@ onMounted(load);
show -password
maxlength = "128"
placeholder = "至少8位"
autocomplete = "new-password" / > < / el-form-item > < / e l - f o r m
autocomplete = "new-password" / > < / e l - f o r m - i t e m
> < el-form-item label = "NSFW 成人内容"
> < el-switch
v-model = "createForm.nsfwEnabled"
active -text = " 开启 "
inactive -text = " 关闭 "
/ >
< p class = "secondary" >
登录账号默认开启 , 用户可在前台保存自己的选择 。
< / p >
< / el-form-item > < / e l - f o r m
> < 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" > 正常 < / e l - r a d i o
> < el-radio value = "INACTIVE" > 停用 < / el-radio > < / e l - r a d i o - g r o u p
> < / e l - f o r m - i t e m
> < / e l - f o r m
> < el-form-item label = "NSFW 成人内容"
> < el-switch
v-model = "editForm.nsfwEnabled"
active -text = " 开启 "
inactive -text = " 关闭 "
/ >
< p class = "secondary" > 保存后用于该账号的后续回复 。 < / p >
< / el-form-item > < / e l - f o r m
> < el-alert
title = "停用后用户无法登录,已有会话记录仍保留。"
:closable = "false"