diff --git a/components/AccountLoginModal.client.vue b/components/AccountLoginModal.client.vue index 4091629..3a793ac 100644 --- a/components/AccountLoginModal.client.vue +++ b/components/AccountLoginModal.client.vue @@ -39,7 +39,7 @@ const rules: FormRules = { async function addAccount() { await formRef.value?.validate() - if (accountStore.accounts.some(a => a.username === form.username)) { + if (accountStore.accounts?.some(a => a.username === form.username)) { ms.warning('账号已存在,无需添加') return } diff --git a/server/api/cx/courses/index.get.ts b/server/api/cx/courses/index.get.ts index e35355b..cddf0cb 100644 --- a/server/api/cx/courses/index.get.ts +++ b/server/api/cx/courses/index.get.ts @@ -14,7 +14,7 @@ export default defineEventHandler(async (event) => { }, }) - const toCreate = courses.filter(c => !exists.some(e => e.id === `${c.courseId}_${c.classId}`)) + const toCreate = courses.filter(c => !exists?.some(e => e.id === `${c.courseId}_${c.classId}`)) if (toCreate.length > 0) { await event.context.prisma.course.createMany({ diff --git a/server/api/cx/logout.post.ts b/server/api/cx/logout.post.ts index d384551..aae92d5 100644 --- a/server/api/cx/logout.post.ts +++ b/server/api/cx/logout.post.ts @@ -2,7 +2,7 @@ import { CXMap } from '~~/server/protocol/cx' import { IMConnectionMap } from '~~/server/protocol/easemob' export default defineEventHandler(async (event) => { - const uid = event.context.cx.user?.uid + const uid = event.context.cx?.user?.uid await event.context.cx?.logout() diff --git a/server/middleware/2.cx.ts b/server/middleware/2.cx.ts index 5647431..73d5b1f 100644 --- a/server/middleware/2.cx.ts +++ b/server/middleware/2.cx.ts @@ -8,7 +8,7 @@ declare module 'h3' { } } -const exclude = ['/api/cx/login', '/api/cx/logout', '/api/cx/accounts'] +const exclude = ['/api/cx/login', '/api/cx/accounts'] export default eventHandler(async (event) => { const { context, node: { req } } = event