fix: 改用 qrcode 生成 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:
1111
2026-04-19 18:49:57 +08:00
parent 3b3e4fb1ea
commit dbc8a85cd7
4 changed files with 8 additions and 29 deletions

View File

@@ -1,3 +1,5 @@
import { toString as qrToString } from 'qrcode'
export interface QRCodeResult {
qrcodeUrl?: string
qrcodeId: string
@@ -14,20 +16,12 @@ export interface LoginResult {
}
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`)
const output = await qrToString(qrcodeUrl, {
type: 'terminal',
errorCorrectionLevel: 'L',
small: true,
})
process.stderr.write(`${output}\n`)
}
export async function startLogin(apiBaseUrl: string): Promise<QRCodeResult> {