feat: 协助平台登录支持自动保存钉钉二维码
在钉钉扫码登录流程中,自动将生成的登录二维码图片保存到本地 `~/Downloads/dingtalk-login.png`,方便用户在终端无法直接识别或使用二维码时,直接从下载目录打开图片进行扫码。
This commit is contained in:
1 parent
35a118c456
commit
c63ec24344
3 files changed
+79
No files matched your search
@@ -11,6 +11,9 @@ import {
|
||||
import { booleanOption, stringOption } from "../../parser.js";
|
||||
import { printJson, printKeyValue } from "../../printer.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
||||
// ... other imports ...
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
|
||||
export async function handleLogin(
|
||||
parsed: CliParsedArgs,
|
||||
@@ -184,6 +187,18 @@ export async function handleLogin(
|
||||
process.stdout.write(`\n====== 合思协助平台钉钉扫码登录 ======\n`);
|
||||
process.stdout.write(`请使用钉钉 App 扫描下方二维码确认登录(有效期 60 秒):\n\n`);
|
||||
process.stdout.write(`${qrText}\n\n`);
|
||||
|
||||
// 自动保存二维码
|
||||
const downloadsDir = path.join(os.homedir(), "Downloads");
|
||||
const qrPath = path.join(downloadsDir, "dingtalk-login.png");
|
||||
(async () => {
|
||||
const QRCode = await import("qrcode");
|
||||
await QRCode.toFile(qrPath, dingUrl);
|
||||
process.stdout.write(`💡 二维码已自动保存至: ${qrPath}\n\n`);
|
||||
})().catch((e: Error) => {
|
||||
process.stdout.write(`[WARN] 自动保存二维码失败: ${e.message}\n\n`);
|
||||
});
|
||||
|
||||
process.stdout.write(`🔗 快捷授权链接: ${dingUrl}\n\n`);
|
||||
process.stdout.write(`等待钉钉扫码并确认中... (最长等待 60 秒)\n`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user