refactor(deps): migrate to nuxt v4
This commit is contained in:
588
app/pages/generation/admin/digital-human-train.vue
Normal file
588
app/pages/generation/admin/digital-human-train.vue
Normal file
@@ -0,0 +1,588 @@
|
||||
<script lang="ts" setup>
|
||||
import { object, string, number } from 'yup'
|
||||
import type { FormSubmitEvent } from '#ui/types'
|
||||
|
||||
useHead({
|
||||
title: '数字人定制管理 | 管理员',
|
||||
})
|
||||
|
||||
const toast = useToast()
|
||||
const loginState = useLoginState()
|
||||
|
||||
// 定制记录列表
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
})
|
||||
|
||||
const {
|
||||
data: trainListResp,
|
||||
status: trainListStatus,
|
||||
refresh: refreshTrainList,
|
||||
} = useAsyncData(
|
||||
'digital-train-list',
|
||||
() =>
|
||||
useFetchWrapped<
|
||||
PagedDataRequest & AuthedRequest,
|
||||
BaseResponse<PagedData<DigitalHumanTrainItem>>
|
||||
>('App.Digital_Train.GetList', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id,
|
||||
to_user_id: loginState.user.id,
|
||||
page: pagination.page,
|
||||
perpage: pagination.pageSize,
|
||||
}),
|
||||
{
|
||||
watch: [pagination],
|
||||
}
|
||||
)
|
||||
|
||||
const trainList = computed(() => trainListResp.value?.data.items || [])
|
||||
|
||||
// 表格列定义
|
||||
const columns = [
|
||||
{
|
||||
key: 'id',
|
||||
label: 'ID',
|
||||
},
|
||||
{
|
||||
key: 'dh_name',
|
||||
label: '数字人名称',
|
||||
},
|
||||
{
|
||||
key: 'organization',
|
||||
label: '单位名称',
|
||||
},
|
||||
{
|
||||
key: 'user_id',
|
||||
label: '用户ID',
|
||||
},
|
||||
{
|
||||
key: 'create_time',
|
||||
label: '创建时间',
|
||||
},
|
||||
{
|
||||
key: 'video_url',
|
||||
label: '数字人视频',
|
||||
},
|
||||
{
|
||||
key: 'auth_video_url',
|
||||
label: '授权视频',
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
label: '操作',
|
||||
},
|
||||
]
|
||||
|
||||
// 录入数字人相关状态
|
||||
const isProcessModalOpen = ref(false)
|
||||
const currentTrainItem = ref<DigitalHumanTrainItem | null>(null)
|
||||
|
||||
const processFormState = reactive({
|
||||
name: '',
|
||||
model_id: undefined as number | undefined,
|
||||
description: '',
|
||||
type: 2, // 默认为XSH自有
|
||||
})
|
||||
|
||||
const processFormSchema = object({
|
||||
name: string().required('请输入名称'),
|
||||
model_id: number().required('请输入数字人ID'),
|
||||
description: string().required('请输入描述'),
|
||||
type: number().required('请选择类型'),
|
||||
})
|
||||
|
||||
const sourceTypeList = [
|
||||
{ label: 'xsh_wm', value: 1, color: 'blue' }, // 万木(腾讯)
|
||||
{ label: 'xsh_zy', value: 2, color: 'green' }, // XSH 自有
|
||||
{ label: 'xsh_fh', value: 3, color: 'purple' }, // 硅基(泛化数字人)
|
||||
{ label: 'xsh_bb', value: 4, color: 'indigo' }, // 百度小冰
|
||||
]
|
||||
|
||||
const avatarFile = ref<File | null>(null)
|
||||
const isProcessing = ref(false)
|
||||
|
||||
// 处理训练素材:录入系统数字人并分配给用户
|
||||
const handleProcessTrain = (item: DigitalHumanTrainItem) => {
|
||||
currentTrainItem.value = item
|
||||
|
||||
// 预填充表单数据
|
||||
processFormState.name = item.dh_name
|
||||
processFormState.model_id = undefined
|
||||
processFormState.description = `基于${item.organization}提交的训练素材创建`
|
||||
processFormState.type = 2
|
||||
|
||||
isProcessModalOpen.value = true
|
||||
}
|
||||
|
||||
// 处理文件上传
|
||||
const handleAvatarUpload = (files: FileList) => {
|
||||
const file = files[0]
|
||||
if (!file) return
|
||||
|
||||
// 验证文件类型
|
||||
if (!file.type.startsWith('image/')) {
|
||||
toast.add({
|
||||
title: '文件格式错误',
|
||||
description: '请上传图片文件',
|
||||
color: 'red',
|
||||
icon: 'i-tabler-alert-triangle',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 验证文件大小 (10MB)
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
toast.add({
|
||||
title: '文件过大',
|
||||
description: '图片文件大小不能超过10MB',
|
||||
color: 'red',
|
||||
icon: 'i-tabler-alert-triangle',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
avatarFile.value = file
|
||||
}
|
||||
|
||||
// 提交录入表单
|
||||
const onProcessSubmit = async (
|
||||
event: FormSubmitEvent<typeof processFormState>
|
||||
) => {
|
||||
if (!currentTrainItem.value) return
|
||||
|
||||
if (!avatarFile.value) {
|
||||
toast.add({
|
||||
title: '请上传数字人预览图',
|
||||
color: 'red',
|
||||
icon: 'i-tabler-alert-triangle',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (isProcessing.value) return
|
||||
|
||||
try {
|
||||
isProcessing.value = true
|
||||
|
||||
// 1. 上传预览图
|
||||
const avatarUrl = await useFileGo(avatarFile.value, 'material')
|
||||
|
||||
// 2. 创建系统数字人
|
||||
const createSystemResult = await useFetchWrapped<
|
||||
{
|
||||
name: string
|
||||
model_id: number
|
||||
type: number
|
||||
description: string
|
||||
avatar: string
|
||||
} & AuthedRequest,
|
||||
BaseResponse<{ digital_human_id: number }>
|
||||
>('App.Digital_Human.Create', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id,
|
||||
name: event.data.name,
|
||||
model_id: event.data.model_id!,
|
||||
type: event.data.type,
|
||||
description: event.data.description,
|
||||
avatar: avatarUrl,
|
||||
})
|
||||
|
||||
if (
|
||||
createSystemResult.ret !== 200 ||
|
||||
!createSystemResult.data.digital_human_id
|
||||
) {
|
||||
throw new Error(createSystemResult.msg || '创建系统数字人失败')
|
||||
}
|
||||
|
||||
// 3. 分配数字人给提交素材的用户
|
||||
const createUserResult = await useFetchWrapped<
|
||||
{
|
||||
to_user_id: number
|
||||
digital_human_array: number[]
|
||||
} & AuthedRequest,
|
||||
BaseResponse<{
|
||||
total: number
|
||||
success: number
|
||||
failed: number
|
||||
}>
|
||||
>('App.User_UserDigital.CreateConnArr', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id,
|
||||
to_user_id: currentTrainItem.value.user_id,
|
||||
digital_human_array: [createSystemResult.data.digital_human_id],
|
||||
})
|
||||
|
||||
if (createUserResult.ret !== 200 || createUserResult.data.success === 0) {
|
||||
throw new Error(createUserResult.msg || '分配用户数字人失败')
|
||||
}
|
||||
|
||||
toast.add({
|
||||
title: '录入成功',
|
||||
description: `数字人"${event.data.name}"已成功录入并分配给用户 ${currentTrainItem.value.user_id}${
|
||||
createUserResult.data.failed
|
||||
? `,失败 ${createUserResult.data.failed} 个`
|
||||
: ''
|
||||
}`,
|
||||
color: 'green',
|
||||
icon: 'i-tabler-check',
|
||||
})
|
||||
|
||||
// 删除定制记录
|
||||
await handleDeleteTrain(currentTrainItem.value)
|
||||
|
||||
// 重置表单和状态
|
||||
processFormState.name = ''
|
||||
processFormState.model_id = undefined
|
||||
processFormState.description = ''
|
||||
processFormState.type = 2
|
||||
avatarFile.value = null
|
||||
currentTrainItem.value = null
|
||||
isProcessModalOpen.value = false
|
||||
|
||||
// 刷新列表
|
||||
await refreshTrainList()
|
||||
} catch (error) {
|
||||
console.error('录入数字人失败:', error)
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : '录入失败,请重试'
|
||||
toast.add({
|
||||
title: '录入失败',
|
||||
description: errorMessage,
|
||||
color: 'red',
|
||||
icon: 'i-tabler-alert-triangle',
|
||||
})
|
||||
} finally {
|
||||
isProcessing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 删除定制记录
|
||||
const handleDeleteTrain = async (item: DigitalHumanTrainItem) => {
|
||||
try {
|
||||
const result = await useFetchWrapped<
|
||||
{ train_id: number } & AuthedRequest,
|
||||
BaseResponse<{ code: 0 | 1 }>
|
||||
>('App.Digital_Train.Delete', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id,
|
||||
train_id: item.id,
|
||||
})
|
||||
|
||||
if (result.ret === 200 && result.data.code === 1) {
|
||||
toast.add({
|
||||
title: '删除成功',
|
||||
description: '定制记录已删除',
|
||||
color: 'green',
|
||||
icon: 'i-tabler-check',
|
||||
})
|
||||
await refreshTrainList()
|
||||
} else {
|
||||
throw new Error(result.msg || '删除失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除定制记录失败:', error)
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : '删除失败,请重试'
|
||||
toast.add({
|
||||
title: '删除失败',
|
||||
description: errorMessage,
|
||||
color: 'red',
|
||||
icon: 'i-tabler-alert-triangle',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
const formatTime = (timestamp: number) => {
|
||||
return new Date(timestamp * 1000).toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
// 预览视频
|
||||
const previewVideo = (videoUrl: string, title: string) => {
|
||||
// 创建一个简单的视频预览弹窗
|
||||
const videoModal = document.createElement('div')
|
||||
videoModal.className =
|
||||
'fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50'
|
||||
|
||||
const videoContainer = document.createElement('div')
|
||||
videoContainer.className =
|
||||
'bg-white dark:bg-gray-800 rounded-lg p-4 max-w-4xl max-h-[80vh] overflow-auto'
|
||||
|
||||
const titleElement = document.createElement('h3')
|
||||
titleElement.textContent = title
|
||||
titleElement.className =
|
||||
'text-lg font-semibold mb-4 text-gray-900 dark:text-white'
|
||||
|
||||
const video = document.createElement('video')
|
||||
video.src = videoUrl
|
||||
video.controls = true
|
||||
video.className = 'w-full max-h-[60vh]'
|
||||
|
||||
const closeButton = document.createElement('button')
|
||||
closeButton.textContent = '关闭'
|
||||
closeButton.className =
|
||||
'mt-4 px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600'
|
||||
closeButton.onclick = () => {
|
||||
document.body.removeChild(videoModal)
|
||||
}
|
||||
|
||||
videoContainer.appendChild(titleElement)
|
||||
videoContainer.appendChild(video)
|
||||
videoContainer.appendChild(closeButton)
|
||||
videoModal.appendChild(videoContainer)
|
||||
|
||||
videoModal.onclick = (e) => {
|
||||
if (e.target === videoModal) {
|
||||
document.body.removeChild(videoModal)
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(videoModal)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="p-4 pb-0">
|
||||
<BubbleTitle
|
||||
title="数字人定制管理"
|
||||
subtitle="Digital Human Training Management"
|
||||
>
|
||||
<template #action>
|
||||
<UButton
|
||||
color="gray"
|
||||
variant="soft"
|
||||
icon="i-tabler-refresh"
|
||||
label="刷新"
|
||||
@click="refreshTrainList"
|
||||
/>
|
||||
</template>
|
||||
</BubbleTitle>
|
||||
<GradientDivider />
|
||||
</div>
|
||||
|
||||
<div class="p-4">
|
||||
<UAlert
|
||||
v-if="loginState.user.auth_code === 2"
|
||||
icon="i-tabler-user-shield"
|
||||
title="管理员功能"
|
||||
description="当前正在管理用户提交的数字人定制请求,仅管理员可见"
|
||||
class="mb-4"
|
||||
/>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<UTable
|
||||
:rows="trainList"
|
||||
:columns="columns"
|
||||
:loading="trainListStatus === 'pending'"
|
||||
:progress="{ color: 'amber', animation: 'carousel' }"
|
||||
class="border dark:border-neutral-800 rounded-md"
|
||||
>
|
||||
<template #create_time-data="{ row }">
|
||||
<span class="text-sm">{{ formatTime(row.create_time) }}</span>
|
||||
</template>
|
||||
|
||||
<template #video_url-data="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<UButton
|
||||
color="blue"
|
||||
variant="soft"
|
||||
size="xs"
|
||||
icon="i-tabler-download"
|
||||
:to="row.video_url"
|
||||
target="_blank"
|
||||
label="下载"
|
||||
/>
|
||||
<UButton
|
||||
color="green"
|
||||
variant="soft"
|
||||
size="xs"
|
||||
icon="i-tabler-eye"
|
||||
label="预览"
|
||||
@click="previewVideo(row.video_url, '数字人视频')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #auth_video_url-data="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<UButton
|
||||
color="blue"
|
||||
variant="soft"
|
||||
size="xs"
|
||||
icon="i-tabler-download"
|
||||
:to="row.auth_video_url"
|
||||
target="_blank"
|
||||
label="下载"
|
||||
/>
|
||||
<UButton
|
||||
color="green"
|
||||
variant="soft"
|
||||
size="xs"
|
||||
icon="i-tabler-eye"
|
||||
label="预览"
|
||||
@click="previewVideo(row.auth_video_url, '授权视频')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #actions-data="{ row }">
|
||||
<div class="flex gap-2">
|
||||
<UButton
|
||||
color="amber"
|
||||
variant="soft"
|
||||
size="xs"
|
||||
icon="i-tabler-user-cog"
|
||||
label="录入"
|
||||
@click="handleProcessTrain(row)"
|
||||
/>
|
||||
<UButton
|
||||
color="red"
|
||||
variant="soft"
|
||||
size="xs"
|
||||
icon="i-tabler-trash"
|
||||
label="删除"
|
||||
@click="handleDeleteTrain(row)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</UTable>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<UPagination
|
||||
v-model="pagination.page"
|
||||
:max="9"
|
||||
:page-count="pagination.pageSize"
|
||||
:total="trainListResp?.data.total || 0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 录入数字人弹窗 -->
|
||||
<USlideover v-model="isProcessModalOpen">
|
||||
<UCard
|
||||
:ui="{
|
||||
body: { base: 'flex-1' },
|
||||
ring: '',
|
||||
divide: 'divide-y divide-gray-100 dark:divide-gray-800',
|
||||
}"
|
||||
class="flex flex-col flex-1"
|
||||
>
|
||||
<template #header>
|
||||
<UButton
|
||||
class="flex absolute end-5 top-5 z-10"
|
||||
color="gray"
|
||||
icon="i-tabler-x"
|
||||
padded
|
||||
size="sm"
|
||||
square
|
||||
variant="ghost"
|
||||
@click="isProcessModalOpen = false"
|
||||
/>
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold">录入数字人</h3>
|
||||
<p class="text-sm text-gray-500 mt-1">
|
||||
为"{{ currentTrainItem?.dh_name }}"创建系统数字人并分配给用户
|
||||
{{ currentTrainItem?.user_id }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<UForm
|
||||
class="space-y-4"
|
||||
:schema="processFormSchema"
|
||||
:state="processFormState"
|
||||
@submit="onProcessSubmit"
|
||||
>
|
||||
<UFormGroup
|
||||
label="名称"
|
||||
name="name"
|
||||
>
|
||||
<UInput v-model="processFormState.name" />
|
||||
</UFormGroup>
|
||||
|
||||
<UFormGroup
|
||||
label="数字人ID"
|
||||
name="model_id"
|
||||
description="请输入五位数字人ID"
|
||||
>
|
||||
<UInput
|
||||
v-model="processFormState.model_id"
|
||||
type="number"
|
||||
placeholder="请输入数字人ID"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
<UFormGroup
|
||||
label="描述"
|
||||
name="description"
|
||||
>
|
||||
<UTextarea
|
||||
v-model="processFormState.description"
|
||||
rows="3"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
<UFormGroup
|
||||
label="供应商类型"
|
||||
name="type"
|
||||
>
|
||||
<USelectMenu
|
||||
v-model="processFormState.type"
|
||||
value-attribute="value"
|
||||
:options="sourceTypeList"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
<UFormGroup
|
||||
label="数字人预览图"
|
||||
required
|
||||
>
|
||||
<UniFileDnD
|
||||
accept="image/png,image/jpeg,image/jpg"
|
||||
@change="handleAvatarUpload"
|
||||
>
|
||||
<template #default>
|
||||
<div class="text-center">
|
||||
<UIcon
|
||||
name="i-heroicons-photo"
|
||||
class="mx-auto h-12 w-12 text-gray-400"
|
||||
/>
|
||||
<div class="mt-2">
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400">
|
||||
{{ avatarFile ? avatarFile.name : '点击或拖拽上传图片' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</UniFileDnD>
|
||||
</UFormGroup>
|
||||
|
||||
<div class="flex justify-end gap-2 pt-4">
|
||||
<UButton
|
||||
type="button"
|
||||
color="gray"
|
||||
variant="soft"
|
||||
@click="isProcessModalOpen = false"
|
||||
>
|
||||
取消
|
||||
</UButton>
|
||||
<UButton
|
||||
type="submit"
|
||||
color="primary"
|
||||
:loading="isProcessing"
|
||||
:disabled="isProcessing"
|
||||
>
|
||||
{{ isProcessing ? '录入中...' : '录入并分配' }}
|
||||
</UButton>
|
||||
</div>
|
||||
</UForm>
|
||||
</UCard>
|
||||
</USlideover>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
121
app/pages/generation/admin/index.vue
Normal file
121
app/pages/generation/admin/index.vue
Normal file
@@ -0,0 +1,121 @@
|
||||
<script lang="ts" setup>
|
||||
const router = useRouter()
|
||||
const loginState = useLoginState()
|
||||
|
||||
// 检查用户权限
|
||||
if (loginState.user.auth_code !== 2) {
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: '无权访问管理页面',
|
||||
})
|
||||
}
|
||||
|
||||
useHead({
|
||||
title: '管理中心',
|
||||
})
|
||||
|
||||
const adminPages = [
|
||||
{
|
||||
title: '用户管理',
|
||||
description: '管理系统用户、权限和服务配额',
|
||||
icon: 'i-tabler-users',
|
||||
path: '/generation/admin/users',
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
title: '数字人定制管理',
|
||||
description: '管理用户提交的数字人定制请求',
|
||||
icon: 'i-tabler-user-cog',
|
||||
path: '/generation/admin/digital-human-train',
|
||||
color: 'amber',
|
||||
},
|
||||
{
|
||||
title: '片头片尾管理',
|
||||
description: '管理用户提交的片头片尾制作请求',
|
||||
icon: 'i-tabler-movie',
|
||||
path: '/generation/admin/materials',
|
||||
color: 'green',
|
||||
},
|
||||
]
|
||||
|
||||
const navigateToPage = (path: string) => {
|
||||
router.push(path)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="p-4 pb-0">
|
||||
<BubbleTitle
|
||||
title="管理中心"
|
||||
subtitle="Administrator Panel"
|
||||
/>
|
||||
<GradientDivider />
|
||||
</div>
|
||||
|
||||
<div class="p-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div
|
||||
v-for="page in adminPages"
|
||||
:key="page.path"
|
||||
class="group cursor-pointer"
|
||||
@click="navigateToPage(page.path)"
|
||||
>
|
||||
<UCard
|
||||
class="hover:shadow-lg transition-all duration-200 group-hover:scale-105"
|
||||
:ui="{
|
||||
ring: 'ring-1 ring-gray-200 dark:ring-gray-700 group-hover:ring-gray-300 dark:group-hover:ring-gray-600',
|
||||
}"
|
||||
>
|
||||
<div class="flex flex-col items-center text-center p-6">
|
||||
<div
|
||||
class="w-16 h-16 rounded-full flex items-center justify-center mb-4 transition-colors"
|
||||
:class="{
|
||||
'bg-blue-100 dark:bg-blue-900/30': page.color === 'blue',
|
||||
'bg-amber-100 dark:bg-amber-900/30': page.color === 'amber',
|
||||
'bg-green-100 dark:bg-green-900/30': page.color === 'green',
|
||||
}"
|
||||
>
|
||||
<UIcon
|
||||
:name="page.icon"
|
||||
class="w-8 h-8"
|
||||
:class="{
|
||||
'text-blue-600 dark:text-blue-400': page.color === 'blue',
|
||||
'text-amber-600 dark:text-amber-400':
|
||||
page.color === 'amber',
|
||||
'text-green-600 dark:text-green-400':
|
||||
page.color === 'green',
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<h3
|
||||
class="text-lg font-semibold text-gray-900 dark:text-white mb-2"
|
||||
>
|
||||
{{ page.title }}
|
||||
</h3>
|
||||
|
||||
<p
|
||||
class="text-sm text-gray-600 dark:text-gray-400 leading-relaxed"
|
||||
>
|
||||
{{ page.description }}
|
||||
</p>
|
||||
|
||||
<div
|
||||
class="mt-4 flex items-center text-sm text-gray-500 dark:text-gray-400 group-hover:text-gray-700 dark:group-hover:text-gray-300 transition-colors"
|
||||
>
|
||||
<span>进入管理</span>
|
||||
<UIcon
|
||||
name="i-heroicons-arrow-right"
|
||||
class="ml-1 w-4 h-4"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</UCard>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
1672
app/pages/generation/admin/materials.vue
Normal file
1672
app/pages/generation/admin/materials.vue
Normal file
File diff suppressed because it is too large
Load Diff
883
app/pages/generation/admin/users.vue
Normal file
883
app/pages/generation/admin/users.vue
Normal file
@@ -0,0 +1,883 @@
|
||||
<script lang="ts" setup>
|
||||
const route = useRoute()
|
||||
const toast = useToast()
|
||||
const dayjs = useDayjs()
|
||||
const loginState = useLoginState()
|
||||
|
||||
const systemServices: ServiceType[] = [
|
||||
{
|
||||
tag: 'PPTToVideo',
|
||||
name: '微课视频(PPT驱动)',
|
||||
},
|
||||
{
|
||||
tag: 'TextToVideo',
|
||||
name: '绿幕视频(文字驱动)',
|
||||
},
|
||||
{
|
||||
tag: 'SparkChat15',
|
||||
name: '讯飞星火大模型 1.5',
|
||||
},
|
||||
{
|
||||
tag: 'SparkChat30',
|
||||
name: '讯飞星火大模型 3.0',
|
||||
},
|
||||
{
|
||||
tag: 'SparkChat35',
|
||||
name: '讯飞星火大模型 3.5',
|
||||
},
|
||||
{
|
||||
tag: 'TenImgToImg',
|
||||
name: '腾讯混元 - 图生图',
|
||||
},
|
||||
{
|
||||
tag: 'TenTextToImg',
|
||||
name: '腾讯混元 - 文生图',
|
||||
},
|
||||
]
|
||||
|
||||
const columns = [
|
||||
{
|
||||
key: 'id',
|
||||
label: 'ID',
|
||||
disabled: true,
|
||||
},
|
||||
{
|
||||
key: 'avatar',
|
||||
label: '头像',
|
||||
disabled: true,
|
||||
},
|
||||
{
|
||||
key: 'username',
|
||||
label: '账户名/姓名',
|
||||
disabled: true,
|
||||
},
|
||||
{
|
||||
key: 'company',
|
||||
label: '单位',
|
||||
},
|
||||
{
|
||||
key: 'mobile',
|
||||
label: '手机号',
|
||||
},
|
||||
{
|
||||
key: 'sex',
|
||||
label: '性别',
|
||||
},
|
||||
{
|
||||
key: 'auth_code',
|
||||
label: '角色',
|
||||
},
|
||||
{
|
||||
key: 'actions',
|
||||
label: '操作',
|
||||
},
|
||||
]
|
||||
|
||||
const selectedColumns = ref([
|
||||
...columns.filter((row) => {
|
||||
return !['auth_code'].includes(row.key)
|
||||
}),
|
||||
])
|
||||
const page = ref(1)
|
||||
const pageCount = ref(15)
|
||||
const state_filter = ref<'verified' | 'unverified'>('verified')
|
||||
const is_verified = ref(true)
|
||||
const viewingUser = ref<UserSchema | null>(null)
|
||||
const isSlideOpen = computed({
|
||||
get: () => !!viewingUser.value,
|
||||
set: () => (viewingUser.value = null),
|
||||
})
|
||||
|
||||
watch([is_verified, pageCount], () => (page.value = 1))
|
||||
watch(
|
||||
state_filter,
|
||||
() => (is_verified.value = state_filter.value === 'verified')
|
||||
)
|
||||
|
||||
const {
|
||||
data: usersData,
|
||||
refresh: refreshUsersData,
|
||||
status: usersDataStatus,
|
||||
} = useAsyncData(
|
||||
'systemUsers',
|
||||
() =>
|
||||
useFetchWrapped<
|
||||
req.user.UserList & AuthedRequest,
|
||||
BaseResponse<PagedData<UserSchema>>
|
||||
>('App.User_User.ListUser', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id!,
|
||||
page: page.value,
|
||||
perpage: pageCount.value,
|
||||
is_verify: is_verified.value,
|
||||
}),
|
||||
{
|
||||
watch: [page, pageCount, is_verified],
|
||||
transform: (res) => {
|
||||
res.data.items.unshift(loginState.user)
|
||||
return res
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
const isDigitalSelectorOpen = ref(false)
|
||||
const dhPage = ref(1)
|
||||
const dhPageCount = ref(10)
|
||||
|
||||
watch(dhPageCount, () => (dhPage.value = 1))
|
||||
|
||||
onMounted(() => {
|
||||
if (!!route.query?.unverified) {
|
||||
state_filter.value = 'unverified'
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
data: digitalHumansData,
|
||||
refresh: refreshDigitalHumansData,
|
||||
status: digitalHumansDataStatus,
|
||||
} = useAsyncData(
|
||||
'currentUserDigitalHumans',
|
||||
() =>
|
||||
useFetchWrapped<
|
||||
PagedDataRequest & AuthedRequest,
|
||||
BaseResponse<PagedData<DigitalHumanItem>>
|
||||
>('App.User_UserDigital.GetList', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id!,
|
||||
to_user_id: viewingUser.value?.id || 0,
|
||||
page: dhPage.value,
|
||||
perpage: dhPageCount.value,
|
||||
}),
|
||||
{
|
||||
watch: [viewingUser, dhPage, dhPageCount],
|
||||
}
|
||||
)
|
||||
|
||||
const {
|
||||
data: userBalances,
|
||||
status: userBalancesStatus,
|
||||
refresh: refreshUserBalances,
|
||||
} = useAsyncData(
|
||||
'userServiceBalances',
|
||||
() =>
|
||||
useFetchWrapped<
|
||||
PagedDataRequest & AuthedRequest,
|
||||
BaseResponse<PagedData<ServiceBalance>>
|
||||
>('App.User_UserBalance.GetList', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id,
|
||||
to_user_id: viewingUser.value?.id || 0,
|
||||
page: 1,
|
||||
perpage: 20,
|
||||
}),
|
||||
{
|
||||
watch: [viewingUser],
|
||||
}
|
||||
)
|
||||
|
||||
const getBalanceByTag = (tag: ServiceTag): ServiceBalance | null => {
|
||||
return (
|
||||
userBalances?.value?.data.items.find((row) => row.request_type === tag) ||
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
const items = (row: UserSchema) => [
|
||||
[
|
||||
{
|
||||
label: '服务和用量',
|
||||
icon: 'tabler:server-cog',
|
||||
click: () => openSlide(row),
|
||||
disabled: row.auth_code === 0,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
disabled: row.id === loginState.user.id,
|
||||
label: row.auth_code !== 0 ? '停用账号' : '启用账号',
|
||||
icon: row.auth_code !== 0 ? 'tabler:cancel' : 'tabler:shield-check',
|
||||
click: () => setUserStatus(row.id, row.auth_code === 0),
|
||||
},
|
||||
],
|
||||
]
|
||||
|
||||
const openSlide = (user: UserSchema) => {
|
||||
viewingUser.value = user
|
||||
}
|
||||
|
||||
const closeSlide = () => {
|
||||
viewingUser.value = null
|
||||
}
|
||||
|
||||
const onDigitalHumansSelected = (digitalHumans: DigitalHumanItem[]) => {
|
||||
useFetchWrapped<
|
||||
{
|
||||
to_user_id: number
|
||||
digital_human_array: number[]
|
||||
} & AuthedRequest,
|
||||
BaseResponse<{
|
||||
total: number
|
||||
success: number
|
||||
failed: number
|
||||
}>
|
||||
>('App.User_UserDigital.CreateConnArr', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id!,
|
||||
to_user_id: viewingUser.value?.id || 0,
|
||||
digital_human_array: digitalHumans.map(
|
||||
(row) => row.id || row.digital_human_id || 0
|
||||
),
|
||||
}).then((res) => {
|
||||
if (res.ret === 200) {
|
||||
toast.add({
|
||||
title: '授权成功',
|
||||
description: `成功授权 ${res.data.success} 个数字人${
|
||||
res.data.failed ? `,失败 ${res.data.failed} 个` : ''
|
||||
}`,
|
||||
color: 'green',
|
||||
icon: 'tabler:check',
|
||||
})
|
||||
refreshDigitalHumansData()
|
||||
} else {
|
||||
toast.add({
|
||||
title: '授权失败',
|
||||
description: res.msg || '未知错误',
|
||||
color: 'red',
|
||||
icon: 'tabler:alert-triangle',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const revokeDigitalHuman = (uid: number, digitalHumanId: number) => {
|
||||
useFetchWrapped<
|
||||
{
|
||||
to_user_id: number
|
||||
digital_human_id: number
|
||||
} & AuthedRequest,
|
||||
BaseResponse<{
|
||||
code: number // 1: success, 0: failed
|
||||
}>
|
||||
>('App.User_UserDigital.DeleteConn', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id!,
|
||||
to_user_id: uid,
|
||||
digital_human_id: digitalHumanId,
|
||||
}).then((res) => {
|
||||
if (res.ret === 200 && res.data.code === 1) {
|
||||
toast.add({
|
||||
title: '撤销成功',
|
||||
description: '已撤销数字人授权',
|
||||
color: 'green',
|
||||
icon: 'tabler:check',
|
||||
})
|
||||
refreshDigitalHumansData()
|
||||
} else {
|
||||
toast.add({
|
||||
title: '撤销失败',
|
||||
description: res.msg || '未知错误',
|
||||
color: 'red',
|
||||
icon: 'tabler:alert-triangle',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const setUserStatus = (uid: number, is_verified: boolean) => {
|
||||
useFetchWrapped<
|
||||
{
|
||||
to_user_id: number
|
||||
is_verify: boolean
|
||||
} & AuthedRequest,
|
||||
BaseResponse<{
|
||||
status: number // 1: success, 0: failed
|
||||
}>
|
||||
>('App.User_User.SetUserVerify', {
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id!,
|
||||
to_user_id: uid,
|
||||
is_verify: is_verified,
|
||||
}).then((res) => {
|
||||
if (res.ret === 200 && res.data.status === 1) {
|
||||
toast.add({
|
||||
title: '操作成功',
|
||||
description: `已${is_verified ? '启用' : '停用'}账号`,
|
||||
color: 'green',
|
||||
icon: is_verified ? 'tabler:shield-check' : 'tabler:cancel',
|
||||
})
|
||||
refreshUsersData()
|
||||
} else {
|
||||
toast.add({
|
||||
title: '操作失败',
|
||||
description: res.msg || '未知错误',
|
||||
color: 'red',
|
||||
icon: 'tabler:alert-triangle',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const userBalanceEditing = ref(false)
|
||||
const userBalanceState = reactive({
|
||||
expire_time: dayjs().add(1, 'month').unix() * 1000,
|
||||
remain_count: 1800,
|
||||
request_type: '',
|
||||
})
|
||||
|
||||
const isActivateBalance = ref(false)
|
||||
|
||||
const isBalanceEditModalOpen = computed({
|
||||
get: () => !!viewingUser && userBalanceEditing.value,
|
||||
set: (val) => {
|
||||
userBalanceEditing.value = val
|
||||
if (!val) {
|
||||
userBalanceState.expire_time = dayjs().add(1, 'month').unix() * 1000
|
||||
userBalanceState.remain_count = 1800
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const udpateBalance = (tag: ServiceTag, isActivate: boolean = false) => {
|
||||
useFetchWrapped<
|
||||
{
|
||||
to_user_id: number
|
||||
request_type: ServiceTag
|
||||
expire_time: number
|
||||
remain_count: number
|
||||
} & AuthedRequest,
|
||||
BaseResponse<{
|
||||
code: number // 1: success, 0: failed
|
||||
data_id?: number
|
||||
}>
|
||||
>(
|
||||
isActivate ? 'App.User_UserBalance.Insert' : 'App.User_UserBalance.Update',
|
||||
{
|
||||
token: loginState.token!,
|
||||
user_id: loginState.user.id!,
|
||||
to_user_id: viewingUser.value?.id || 0,
|
||||
request_type: tag,
|
||||
expire_time: userBalanceState.expire_time / 1000,
|
||||
remain_count: userBalanceState.remain_count,
|
||||
}
|
||||
)
|
||||
.then((res) => {
|
||||
if (res.ret === 200 && (res.data.code === 1 || !!res.data.data_id)) {
|
||||
toast.add({
|
||||
title: '操作成功',
|
||||
description: `已${isActivate ? '开通' : '更新'}服务`,
|
||||
color: 'green',
|
||||
icon: 'tabler:check',
|
||||
})
|
||||
} else {
|
||||
toast.add({
|
||||
title: '操作失败',
|
||||
description: res.msg || '未知错误',
|
||||
color: 'red',
|
||||
icon: 'tabler:alert-triangle',
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.add({
|
||||
title: '操作失败',
|
||||
description: err.message || '未知错误',
|
||||
color: 'red',
|
||||
icon: 'tabler:alert-triangle',
|
||||
})
|
||||
})
|
||||
.finally(() => {
|
||||
refreshUserBalances()
|
||||
isBalanceEditModalOpen.value = false
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<LoginNeededContent need-admin>
|
||||
<div class="p-4">
|
||||
<BubbleTitle
|
||||
bubble-color="amber-500"
|
||||
subtitle="User Management"
|
||||
title="用户管理"
|
||||
>
|
||||
<template #action>
|
||||
<UButton
|
||||
color="amber"
|
||||
icon="tabler:reload"
|
||||
variant="soft"
|
||||
@click="refreshUsersData"
|
||||
>
|
||||
刷新
|
||||
</UButton>
|
||||
</template>
|
||||
</BubbleTitle>
|
||||
<GradientDivider
|
||||
line-gradient-from="amber"
|
||||
line-gradient-to="amber"
|
||||
/>
|
||||
<div>
|
||||
<div class="flex justify-between items-center w-full py-3">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="text-sm leading-0">每页显示:</span>
|
||||
<USelect
|
||||
v-model="pageCount"
|
||||
:options="[5, 10, 15, 20]"
|
||||
class="me-2 w-20"
|
||||
size="xs"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-1.5 items-center">
|
||||
<USelectMenu
|
||||
v-model="state_filter"
|
||||
:options="[
|
||||
{
|
||||
label: '正常账号',
|
||||
value: 'verified',
|
||||
icon: 'tabler:user-check',
|
||||
},
|
||||
{
|
||||
label: '停用账号',
|
||||
value: 'unverified',
|
||||
icon: 'tabler:user-cancel',
|
||||
},
|
||||
]"
|
||||
:ui-menu="{
|
||||
width: 'w-fit',
|
||||
option: { size: 'text-xs', icon: { base: 'w-4 h-4' } },
|
||||
}"
|
||||
size="xs"
|
||||
value-attribute="value"
|
||||
/>
|
||||
<USelectMenu
|
||||
v-model="selectedColumns"
|
||||
:options="columns.filter((row) => !['actions'].includes(row.key))"
|
||||
:ui-menu="{
|
||||
width: 'w-fit',
|
||||
option: { size: 'text-xs', icon: { base: 'w-4 h-4' } },
|
||||
}"
|
||||
multiple
|
||||
>
|
||||
<UButton
|
||||
color="gray"
|
||||
icon="tabler:layout-columns"
|
||||
size="xs"
|
||||
>
|
||||
显示列
|
||||
</UButton>
|
||||
</USelectMenu>
|
||||
</div>
|
||||
</div>
|
||||
<UTable
|
||||
:columns="selectedColumns"
|
||||
:loading="usersDataStatus === 'pending'"
|
||||
:progress="{ color: 'amber', animation: 'carousel' }"
|
||||
:rows="usersData?.data.items"
|
||||
class="border dark:border-neutral-800 rounded-md"
|
||||
>
|
||||
<template #username-data="{ row }">
|
||||
<span
|
||||
:class="{
|
||||
'font-semibold text-amber-500': row.id === loginState.user.id,
|
||||
}"
|
||||
>
|
||||
{{ row.username }}
|
||||
<span class="text-xs">
|
||||
{{ row.id === loginState.user.id ? ' (本账号)' : '' }}
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
<template #avatar-data="{ row }">
|
||||
<UAvatar
|
||||
:alt="row.username.toUpperCase()"
|
||||
:src="row.avatar"
|
||||
size="sm"
|
||||
/>
|
||||
</template>
|
||||
<template #sex-data="{ row }">
|
||||
{{ row.sex === 0 ? '' : row.sex === 1 ? '男' : '女' }}
|
||||
</template>
|
||||
<template #actions-data="{ row }">
|
||||
<UDropdown :items="items(row)">
|
||||
<UButton
|
||||
color="gray"
|
||||
icon="tabler:dots"
|
||||
variant="ghost"
|
||||
/>
|
||||
</UDropdown>
|
||||
</template>
|
||||
</UTable>
|
||||
<div class="flex justify-end py-3.5">
|
||||
<UPagination
|
||||
v-if="(usersData?.data.total || -1) > 0"
|
||||
v-model="page"
|
||||
:page-count="pageCount"
|
||||
:total="usersData?.data.total || 0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<USlideover
|
||||
v-model="isSlideOpen"
|
||||
:ui="{ width: 'w-screen max-w-3xl' }"
|
||||
>
|
||||
<UCard
|
||||
:ui="{
|
||||
body: { base: 'flex-1 overflow-y-auto' },
|
||||
ring: '',
|
||||
divide: 'divide-y divide-gray-100 dark:divide-gray-800',
|
||||
}"
|
||||
class="flex flex-col overflow-hidden"
|
||||
>
|
||||
<template #header>
|
||||
<UButton
|
||||
class="flex absolute end-5 top-5 z-10"
|
||||
color="gray"
|
||||
icon="tabler:x"
|
||||
padded
|
||||
size="sm"
|
||||
square
|
||||
variant="ghost"
|
||||
@click="closeSlide"
|
||||
/>
|
||||
服务和用量管理
|
||||
<p class="text-sm font-medium text-primary">
|
||||
{{ viewingUser?.username }} (UID:{{ viewingUser?.id }})
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<div class="">
|
||||
<UDivider
|
||||
label="服务用量管理"
|
||||
class="mb-4"
|
||||
:ui="{ label: 'text-primary-500 dark:text-primary-400' }"
|
||||
/>
|
||||
|
||||
<div class="border dark:border-neutral-700 rounded-md">
|
||||
<UTable
|
||||
:columns="[
|
||||
{ key: 'service', label: '服务' },
|
||||
{ key: 'status', label: '状态' },
|
||||
{ key: 'create_time', label: '开通时间' },
|
||||
{ key: 'expire_time', label: '过期时间' },
|
||||
{ key: 'remain_count', label: '余量(秒)' },
|
||||
{ key: 'actions' },
|
||||
]"
|
||||
:loading="userBalancesStatus === 'pending'"
|
||||
:rows="[
|
||||
...systemServices,
|
||||
// 如果 userBalances?.data.items 具有 systemServices 中没有的服务,则添加到列表中
|
||||
...(userBalances?.data.items
|
||||
.filter(
|
||||
(row) =>
|
||||
!systemServices.find((s) => s.tag === row.request_type)
|
||||
)
|
||||
.map((row) => ({
|
||||
tag: row.request_type,
|
||||
name: row.request_type,
|
||||
})) || []),
|
||||
]"
|
||||
>
|
||||
<template #service-data="{ row }: { row: ServiceType }">
|
||||
{{
|
||||
systemServices.find((s) => s.tag === row.tag)?.name || row.tag
|
||||
}}
|
||||
</template>
|
||||
|
||||
<template #status-data="{ row }">
|
||||
<UBadge
|
||||
v-if="!getBalanceByTag(row.tag)"
|
||||
color="gray"
|
||||
variant="solid"
|
||||
size="xs"
|
||||
>
|
||||
未开通
|
||||
</UBadge>
|
||||
<UBadge
|
||||
v-else-if="
|
||||
getBalanceByTag(row.tag)!.expire_time < dayjs().unix()
|
||||
"
|
||||
color="red"
|
||||
variant="subtle"
|
||||
size="xs"
|
||||
>
|
||||
已过期
|
||||
</UBadge>
|
||||
<UBadge
|
||||
v-else
|
||||
color="green"
|
||||
variant="subtle"
|
||||
size="xs"
|
||||
>
|
||||
生效中
|
||||
</UBadge>
|
||||
</template>
|
||||
|
||||
<template #create_time-data="{ row }">
|
||||
<span class="text-xs">
|
||||
{{
|
||||
!!getBalanceByTag(row.tag)
|
||||
? dayjs(
|
||||
getBalanceByTag(row.tag)!.create_time * 1000
|
||||
).format('YYYY-MM-DD HH:mm:ss')
|
||||
: '未开通'
|
||||
}}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #expire_time-data="{ row }">
|
||||
<span class="text-xs">
|
||||
{{
|
||||
!!getBalanceByTag(row.tag)
|
||||
? dayjs(
|
||||
getBalanceByTag(row.tag)!.expire_time * 1000
|
||||
).format('YYYY-MM-DD HH:mm:ss')
|
||||
: '未开通'
|
||||
}}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #remain_count-data="{ row }">
|
||||
<span class="text-sm">
|
||||
{{ getBalanceByTag(row.tag)?.remain_count || 0 }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #actions-data="{ row }">
|
||||
<UButton
|
||||
v-if="!getBalanceByTag(row.tag)"
|
||||
color="green"
|
||||
icon="tabler:clock-check"
|
||||
size="xs"
|
||||
variant="soft"
|
||||
@click="
|
||||
() => {
|
||||
isActivateBalance = true
|
||||
userBalanceEditing = true
|
||||
userBalanceState.request_type = row.tag
|
||||
}
|
||||
"
|
||||
>
|
||||
开通
|
||||
</UButton>
|
||||
<UButton
|
||||
v-else-if="
|
||||
getBalanceByTag(row.tag)!.expire_time < dayjs().unix()
|
||||
"
|
||||
color="teal"
|
||||
icon="tabler:clock-plus"
|
||||
size="xs"
|
||||
variant="soft"
|
||||
@click="
|
||||
() => {
|
||||
isActivateBalance = false
|
||||
userBalanceEditing = true
|
||||
userBalanceState.request_type = row.tag
|
||||
}
|
||||
"
|
||||
>
|
||||
延续
|
||||
</UButton>
|
||||
<UButton
|
||||
v-else
|
||||
color="sky"
|
||||
icon="tabler:rotate-clockwise"
|
||||
size="xs"
|
||||
variant="soft"
|
||||
@click="
|
||||
() => {
|
||||
isActivateBalance = false
|
||||
userBalanceEditing = true
|
||||
userBalanceState.request_type = row.tag
|
||||
userBalanceState.expire_time =
|
||||
getBalanceByTag(row.tag)!.expire_time * 1000
|
||||
userBalanceState.remain_count = getBalanceByTag(
|
||||
row.tag
|
||||
)!.remain_count
|
||||
}
|
||||
"
|
||||
>
|
||||
更新
|
||||
</UButton>
|
||||
</template>
|
||||
</UTable>
|
||||
|
||||
<UModal
|
||||
v-model="isBalanceEditModalOpen"
|
||||
:ui="{ width: 'w-xl' }"
|
||||
>
|
||||
<UCard
|
||||
:ui="{
|
||||
ring: '',
|
||||
divide: 'divide-y divide-gray-100 dark:divide-gray-800',
|
||||
}"
|
||||
>
|
||||
<template #header>
|
||||
<!-- 为 {{ viewingUser!.username }}
|
||||
<span class="text-primary">{{ isActivateBalance ? '开通' : '续期' }}</span>
|
||||
服务:
|
||||
{{
|
||||
systemServices.find(
|
||||
(s) => s.tag === userBalanceState.request_type
|
||||
)?.name || userBalanceState.request_type
|
||||
}} -->
|
||||
<div class="flex justify-between items-center gap-1">
|
||||
<h1 class="text-sm font-medium">
|
||||
{{ isActivateBalance ? '开通' : '续期' }}
|
||||
{{
|
||||
systemServices.find(
|
||||
(s) => s.tag === userBalanceState.request_type
|
||||
)?.name || userBalanceState.request_type
|
||||
}}
|
||||
服务
|
||||
</h1>
|
||||
<p
|
||||
class="text-xs text-indigo-500 inline-flex items-center gap-1"
|
||||
>
|
||||
<UIcon
|
||||
name="tabler:user-circle"
|
||||
class="text-base"
|
||||
/>
|
||||
{{ viewingUser!.username }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="flex justify-between gap-4">
|
||||
<UFormGroup
|
||||
label="到期时间"
|
||||
class="flex-1"
|
||||
>
|
||||
<UPopover :popper="{ placement: 'bottom-start' }">
|
||||
<UButton
|
||||
block
|
||||
variant="soft"
|
||||
icon="i-heroicons-calendar-days-20-solid"
|
||||
:label="
|
||||
dayjs(userBalanceState.expire_time).format(
|
||||
'YYYY-MM-DD HH:mm'
|
||||
)
|
||||
"
|
||||
/>
|
||||
|
||||
<template #panel="{ close }">
|
||||
<DatePicker
|
||||
v-model="userBalanceState.expire_time"
|
||||
locale="cn"
|
||||
mode="dateTime"
|
||||
title-position="left"
|
||||
is-required
|
||||
is24hr
|
||||
@close="close"
|
||||
/>
|
||||
</template>
|
||||
</UPopover>
|
||||
</UFormGroup>
|
||||
<UFormGroup
|
||||
label="服务时长(秒)"
|
||||
class="flex-1"
|
||||
>
|
||||
<UInput v-model="userBalanceState.remain_count" />
|
||||
</UFormGroup>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<div class="flex items-center justify-end gap-2">
|
||||
<UButton
|
||||
color="gray"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
@click="isBalanceEditModalOpen = false"
|
||||
>
|
||||
取消
|
||||
</UButton>
|
||||
<UButton
|
||||
color="primary"
|
||||
icon="tabler:check"
|
||||
size="sm"
|
||||
@click="
|
||||
udpateBalance(
|
||||
userBalanceState.request_type as ServiceTag,
|
||||
isActivateBalance
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ isActivateBalance ? '开通' : '续期' }}
|
||||
</UButton>
|
||||
</div>
|
||||
</template>
|
||||
</UCard>
|
||||
</UModal>
|
||||
</div>
|
||||
|
||||
<UDivider
|
||||
label="数字人权限管理"
|
||||
class="my-4"
|
||||
:ui="{ label: 'text-primary-500 dark:text-primary-400' }"
|
||||
/>
|
||||
|
||||
<div class="border dark:border-neutral-700 rounded-md">
|
||||
<UTable
|
||||
:columns="[
|
||||
{ key: 'name', label: '名称' },
|
||||
{ key: 'digital_human_id', label: '本地ID' },
|
||||
{ key: 'model_id', label: '上游ID' },
|
||||
{ key: 'actions' },
|
||||
]"
|
||||
:loading="digitalHumansDataStatus === 'pending'"
|
||||
:rows="digitalHumansData?.data.items"
|
||||
>
|
||||
<template #actions-data="{ row }">
|
||||
<UButton
|
||||
color="gray"
|
||||
icon="tabler:cancel"
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
@click="
|
||||
revokeDigitalHuman(
|
||||
viewingUser?.id || 0,
|
||||
row.digital_human_id
|
||||
)
|
||||
"
|
||||
>
|
||||
撤销授权
|
||||
</UButton>
|
||||
</template>
|
||||
</UTable>
|
||||
</div>
|
||||
<div class="flex justify-between py-3.5">
|
||||
<UButton
|
||||
icon="tabler:plus"
|
||||
size="xs"
|
||||
@click="isDigitalSelectorOpen = true"
|
||||
>
|
||||
新增授权
|
||||
</UButton>
|
||||
<UPagination
|
||||
v-if="(digitalHumansData?.data.total || -1) > 0"
|
||||
v-model="dhPage"
|
||||
:page-count="dhPageCount"
|
||||
:total="digitalHumansData?.data.total || 0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</UCard>
|
||||
<ModalDigitalHumanSelect
|
||||
:disabled-digital-human-ids="
|
||||
digitalHumansData?.data.items.map((d) => d.model_id)
|
||||
"
|
||||
:is-open="isDigitalSelectorOpen"
|
||||
default-tab="system"
|
||||
multiple
|
||||
@close="isDigitalSelectorOpen = false"
|
||||
@select="
|
||||
(digitalHumans) =>
|
||||
onDigitalHumansSelected(digitalHumans as DigitalHumanItem[])
|
||||
"
|
||||
/>
|
||||
</USlideover>
|
||||
</LoginNeededContent>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
Reference in New Issue
Block a user