feat: 用户管理和数字人授权

This commit is contained in:
2024-08-20 03:36:25 +08:00
parent 777aecd1cb
commit 2bf4bfad81
17 changed files with 989 additions and 464 deletions

View File

@@ -10,6 +10,14 @@ const props = defineProps({
type: Boolean,
default: false,
},
disabledDigitalHumanIds: {
type: Array,
default: () => [],
},
defaultTab: {
type: String as PropType<'user' | 'system'>,
default: 'user',
},
})
const emit = defineEmits({
@@ -107,6 +115,20 @@ const {
watch: [page],
},
)
onMounted(() => {
if (loginState.user.auth_code === 2) {
tabItems.push({
key: 'system',
label: '系统数字人',
icon: 'i-tabler-user-star',
})
nextTick(() => {
tabIndex.value = tabItems.findIndex(i => i.key === props.defaultTab)
console.log('tabIndex', tabIndex.value)
})
}
})
</script>
<template>
@@ -132,37 +154,49 @@ const {
</template>
<UTabs
:items="[
...tabItems,
loginState.user.auth_code === 2 ? {
key: 'system',
label: '系统数字人',
icon: 'i-tabler-user-star',
} : null
].filter(Boolean)"
@change="i => tabIndex = i"
v-model="tabIndex"
:items="tabItems"
>
<template #item="{ item }">
<div class="w-full grid grid-cols-3 sm:grid-cols-5 gap-4">
<div
v-for="(d, i) in item.key === 'user' ? userDigitalList?.data.items : systemDigitalList?.data.items"
:key="`${item.key === 'user' ? 'user' : 'system'}-digital-${d.model_id}`"
:class="{'border-primary shadow-md': selectedDigitalHumans.includes(d)}"
class="relative flex flex-col justify-center items-center gap-2 overflow-hidden w-full bg-white rounded-md border cursor-pointer transition-all duration-150 select-none"
@click="handleSelectClick(d)"
:class="{
'border-primary shadow-md': selectedDigitalHumans.includes(d),
'border-neutral-200 dark:border-neutral-700': !selectedDigitalHumans.includes(d),
}"
class="relative flex flex-col justify-center items-center gap-2 overflow-hidden w-full bg-white dark:bg-neutral-800 rounded-md border dark:border-2 cursor-pointer transition-all duration-150 select-none"
@click="!disabledDigitalHumanIds.includes(d.model_id) ? handleSelectClick(d) : void 0"
>
<div
v-if="disabledDigitalHumanIds.includes(d.model_id)"
class="absolute inset-0 bg-neutral-400 dark:bg-neutral-700 bg-opacity-50 dark:bg-opacity-50 cursor-not-allowed z-10"
></div>
<div
:class="{'bg-primary-50': selectedDigitalHumans.includes(d)}"
class="relative bg-neutral-100 border-b w-full aspect-square object-cover overflow-hidden transition-all duration-150"
class="relative bg-neutral-100 dark:bg-neutral-800 border-b dark:border-neutral-700 w-full aspect-square object-cover overflow-hidden transition-all duration-150"
>
<NuxtImg :src="d.avatar" class="-translate-y-4"/>
<UIcon v-if="selectedDigitalHumans.includes(d)" class="absolute top-1 right-1 text-lg text-primary"
name="i-tabler-check"/>
<UIcon
v-if="selectedDigitalHumans.includes(d)"
class="absolute top-1 right-1 text-lg text-primary"
name="i-tabler-check"
/>
<UIcon
v-if="disabledDigitalHumanIds.includes(d.model_id)"
class="absolute top-1 right-1 text-lg text-red-500"
name="tabler:user-off"
/>
</div>
<div class="w-full flex flex-col gap-1 px-2 pb-2">
<div class="flex justify-between items-center">
<span class="text-sm text-neutral-800 font-medium line-clamp-1">{{ d.name }}</span>
<span class="text-xs text-neutral-300 font-medium">ID:{{ d.digital_human_id || d.id }}</span>
<span class="text-sm text-neutral-800 dark:text-neutral-300 font-medium line-clamp-1">
{{ d.name }}
</span>
<span class="text-xs text-neutral-300 dark:text-neutral-500 font-medium">
ID:{{ d.digital_human_id || d.id }}
</span>
</div>
</div>
</div>