From 6586872327d6aa1e49d08a5e41b3b9dae4b3fc5e Mon Sep 17 00:00:00 2001 From: Timothy Yin Date: Thu, 20 Feb 2025 19:29:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=92=8C=E7=AE=A1=E7=90=86=E5=91=98=E7=99=BB=E5=BD=95=E6=97=B6?= =?UTF-8?q?=E6=96=B0=E7=94=A8=E6=88=B7=E5=AE=A1=E6=A0=B8=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.vue | 17 +-- layouts/default.vue | 56 ++++++++++ pages/generation/admin/users.vue | 7 ++ pages/user/authenticate.vue | 16 +++ pages/user/register.vue | 173 +++++++++++++++++++++++++++++++ 5 files changed, 262 insertions(+), 7 deletions(-) create mode 100644 pages/user/register.vue diff --git a/app.vue b/app.vue index b6f2e11..4c48f4b 100644 --- a/app.vue +++ b/app.vue @@ -2,13 +2,14 @@ import ModalAuthentication from '~/components/ModalAuthentication.vue' const toast = useToast() +const route = useRoute() const router = useRouter() const modal = useModal() const loginState = useLoginState() useHead({ titleTemplate(title) { - return title ? `${ title } - 眩生花 AI 助手` : '眩生花 AI 助手' + return title ? `${title} - AIGC 微课视频研创平台` : 'AIGC 微课视频研创平台' }, }) @@ -17,7 +18,7 @@ useSeoMeta({ }) onMounted(() => { - loginState.checkSession().then(res => { + loginState.checkSession().then(async (res) => { if (!res && loginState.token) { toast.add({ title: '登录失效', @@ -27,6 +28,8 @@ onMounted(() => { }) modal.open(ModalAuthentication) } else if (!res && !loginState.token) { + // Prevents redirect from register page + if (route.path === '/user/register') return router.replace('/user/authenticate') } }) @@ -35,14 +38,14 @@ onMounted(() => { diff --git a/layouts/default.vue b/layouts/default.vue index 12d9bda..1f51099 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -76,6 +76,62 @@ const items = [ const open_login_modal = () => { modal.open(ModalAuthentication) } + +onMounted(async () => { + if (loginState.user.auth_code === 2) { + /** Adminstrator notifications */ + + // Fetch unverified users + const unverifiedUsers = await useFetchWrapped< + req.user.UserList & AuthedRequest, + BaseResponse> + >('App.User_User.ListUser', { + token: loginState.token!, + user_id: loginState.user.id!, + page: 1, + perpage: 20, + is_verify: false, + }) + + if (!unverifiedUsers) { + toast.add({ + title: '获取待审核用户失败', + description: '获取未审核用户列表失败', + color: 'red', + icon: 'i-tabler-alert-triangle', + }) + } else if (unverifiedUsers.data.total > 0) { + toast.add({ + title: '有新用户等待审核', + description: `有 ${unverifiedUsers.data.total} 个新用户注册,请尽快审核`, + color: 'amber', + icon: 'i-tabler-user-plus', + timeout: 0, + actions: [ + { + label: '前往处理', + variant: 'solid', + color: 'amber', + click: () => { + router.push({ + path: '/generation/admin/users', + query: { + unverified: 1, + }, + }) + }, + }, + // { + // label: '全部忽略', + // click: () => { + // alert('ignored') + // }, + // }, + ], + }) + } + } +})