fix: bundle QR dependencies for channel login
This commit is contained in:
@@ -6,7 +6,7 @@ import { homedir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { deflateSync } from 'node:zlib';
|
||||
import { normalizeOpenClawAccountId } from './channel-alias';
|
||||
import { getOpenClawResolvedDir } from './paths';
|
||||
import { getOpenClawDir, getOpenClawResolvedDir } from './paths';
|
||||
|
||||
export const DEFAULT_WECHAT_BASE_URL = 'https://ilinkai.weixin.qq.com';
|
||||
const DEFAULT_ILINK_BOT_TYPE = '3';
|
||||
@@ -44,8 +44,16 @@ function getQrRenderDeps(): QrRenderDeps {
|
||||
}
|
||||
|
||||
const openclawRequire = createRequire(join(getOpenClawResolvedDir(), 'package.json'));
|
||||
const qrCodeModulePath = openclawRequire.resolve('qrcode-terminal/vendor/QRCode/index.js');
|
||||
const qrErrorCorrectLevelPath = openclawRequire.resolve('qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js');
|
||||
const fallbackRequire = createRequire(join(getOpenClawDir(), 'package.json'));
|
||||
const resolveOpenClawModule = (specifier: string) => {
|
||||
try {
|
||||
return openclawRequire.resolve(specifier);
|
||||
} catch {
|
||||
return fallbackRequire.resolve(specifier);
|
||||
}
|
||||
};
|
||||
const qrCodeModulePath = resolveOpenClawModule('qrcode-terminal/vendor/QRCode/index.js');
|
||||
const qrErrorCorrectLevelPath = resolveOpenClawModule('qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js');
|
||||
qrRenderDeps = {
|
||||
QRCode: require(qrCodeModulePath),
|
||||
QRErrorCorrectLevel: require(qrErrorCorrectLevelPath),
|
||||
|
||||
Reference in New Issue
Block a user