mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 05:45:51 +00:00
fix: 延迟加载 weixin 登录二维码依赖
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -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<void> {
|
||||
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<QRCodeResult> {
|
||||
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<QRCodeResult> {
|
||||
|
||||
const qrcodeUrl = data.qrcode_img_content || ''
|
||||
if (qrcodeUrl) {
|
||||
qrcode.generate(qrcodeUrl, { small: true }, output => {
|
||||
process.stderr.write(`${output}\n`)
|
||||
})
|
||||
await renderQrCodeToTerminal(qrcodeUrl)
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user