From 9441027305e50a42c2de64fb2da0596f1653fc49 Mon Sep 17 00:00:00 2001 From: Kuizuo Date: Thu, 21 Sep 2023 17:32:42 +0800 Subject: [PATCH] feat: improve code --- .eslintrc | 3 ++- server/api/cx/accounts/[uid]/monitor.post.ts | 2 +- server/api/cx/accounts/[uid]/update_setting.post.ts | 4 ++-- server/api/cx/accounts/index.get.ts | 2 +- server/utils/monitor.ts | 1 + 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.eslintrc b/.eslintrc index 77d24bf..ebf77d5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,6 +3,7 @@ "rules": { "no-console": "off", "new-cap": "off", - "n/prefer-global/process": "off" + "n/prefer-global/process": "off", + "no-restricted-globals": "off" } } \ No newline at end of file diff --git a/server/api/cx/accounts/[uid]/monitor.post.ts b/server/api/cx/accounts/[uid]/monitor.post.ts index 3e411a2..7a76e5e 100644 --- a/server/api/cx/accounts/[uid]/monitor.post.ts +++ b/server/api/cx/accounts/[uid]/monitor.post.ts @@ -7,7 +7,7 @@ export default defineEventHandler(async (event) => { data: { isOpened: true, }, - }, '已监听') + }, '已处于监听状态') } const account = await event.context.prisma.cxAccount.findUnique({ diff --git a/server/api/cx/accounts/[uid]/update_setting.post.ts b/server/api/cx/accounts/[uid]/update_setting.post.ts index aa6fddc..b73c4a6 100644 --- a/server/api/cx/accounts/[uid]/update_setting.post.ts +++ b/server/api/cx/accounts/[uid]/update_setting.post.ts @@ -2,7 +2,7 @@ interface Body { uid: string - setting: Setting + setting: CX.Setting } export default defineEventHandler(async (event) => { @@ -48,5 +48,5 @@ export default defineEventHandler(async (event) => { // } // } - return ResOp.success(result.setting as unknown as Setting) + return ResOp.success(result.setting as unknown as CX.Setting) }) diff --git a/server/api/cx/accounts/index.get.ts b/server/api/cx/accounts/index.get.ts index 1949119..0faa99b 100644 --- a/server/api/cx/accounts/index.get.ts +++ b/server/api/cx/accounts/index.get.ts @@ -45,7 +45,7 @@ export default defineEventHandler(async (event) => { uid: cx.user.uid, }, data: { - cookies: cx.getCookie('', 'json'), + cookies: cx.getCookie('', 'json') as any, info: cx.user as any, lastLoginTime: new Date(), }, diff --git a/server/utils/monitor.ts b/server/utils/monitor.ts index 5c2277a..e5a2c02 100644 --- a/server/utils/monitor.ts +++ b/server/utils/monitor.ts @@ -48,6 +48,7 @@ export async function handleListen(client: EasemobChat.Connection, cx: Cx, accou await new Promise((resolve, reject) => { client.listen({ onOpened: async () => { + console.log(cx.user.username, account.setting) await prisma.cxAccount.update({ where: { uid: cx.user.uid,