From 3b3e4fb1eacdf50255a9f761525a2979565bf232 Mon Sep 17 00:00:00 2001 From: 1111 <11111@asd.c> Date: Sun, 19 Apr 2026 18:38:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BB=B6=E8=BF=9F=E5=8A=A0=E8=BD=BD=20w?= =?UTF-8?q?eixin=20=E7=99=BB=E5=BD=95=E4=BA=8C=E7=BB=B4=E7=A0=81=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/services/weixin/login.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/services/weixin/login.ts b/src/services/weixin/login.ts index ab7a4913b..23789c4ce 100644 --- a/src/services/weixin/login.ts +++ b/src/services/weixin/login.ts @@ -1,5 +1,3 @@ -import qrcode from 'qrcode-terminal' - export interface QRCodeResult { qrcodeUrl?: string qrcodeId: string @@ -15,6 +13,23 @@ export interface LoginResult { message: string } +async function renderQrCodeToTerminal(qrcodeUrl: string): Promise { + const moduleName = 'qrcode-terminal' + const { default: qrcode } = (await import(moduleName)) as { + default: { + generate: ( + text: string, + options?: { small?: boolean }, + callback?: (output: string) => void, + ) => void + } + } + + qrcode.generate(qrcodeUrl, { small: true }, output => { + process.stderr.write(`${output}\n`) + }) +} + export async function startLogin(apiBaseUrl: string): Promise { const response = await fetch(`${apiBaseUrl}/ilink/bot/get_bot_qrcode?bot_type=3`) if (!response.ok) { @@ -32,9 +47,7 @@ export async function startLogin(apiBaseUrl: string): Promise { const qrcodeUrl = data.qrcode_img_content || '' if (qrcodeUrl) { - qrcode.generate(qrcodeUrl, { small: true }, output => { - process.stderr.write(`${output}\n`) - }) + await renderQrCodeToTerminal(qrcodeUrl) } return {