mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25: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 {
|
export interface QRCodeResult {
|
||||||
qrcodeUrl?: string
|
qrcodeUrl?: string
|
||||||
qrcodeId: string
|
qrcodeId: string
|
||||||
@@ -15,6 +13,23 @@ export interface LoginResult {
|
|||||||
message: string
|
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> {
|
export async function startLogin(apiBaseUrl: string): Promise<QRCodeResult> {
|
||||||
const response = await fetch(`${apiBaseUrl}/ilink/bot/get_bot_qrcode?bot_type=3`)
|
const response = await fetch(`${apiBaseUrl}/ilink/bot/get_bot_qrcode?bot_type=3`)
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -32,9 +47,7 @@ export async function startLogin(apiBaseUrl: string): Promise<QRCodeResult> {
|
|||||||
|
|
||||||
const qrcodeUrl = data.qrcode_img_content || ''
|
const qrcodeUrl = data.qrcode_img_content || ''
|
||||||
if (qrcodeUrl) {
|
if (qrcodeUrl) {
|
||||||
qrcode.generate(qrcodeUrl, { small: true }, output => {
|
await renderQrCodeToTerminal(qrcodeUrl)
|
||||||
process.stderr.write(`${output}\n`)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user