const { Client } = require('ssh2'); const config = { host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' }; const conn = new Client(); conn.on('ready', () => { console.log('SSH连接成功'); // 检查容器内首页JS的完整逻辑 conn.exec('docker exec huishou grep -o "新商户\\|新个人\\|custom-region" /usr/share/nginx/html/h5/assets/pages-index-index.Dfg3o6TQ.js | head -20', (err, stream) => { if (err) { console.error('执行命令错误:', err.message); conn.end(); return; } let output = ''; stream.stdout.on('data', (data) => { output += data.toString(); }); stream.on('close', () => { console.log('容器内首页JS内容:'); console.log(output); // 检查CSS中custom-region的样式 conn.exec('docker exec huishou grep -A 5 "custom-region" /usr/share/nginx/html/h5/assets/index-D9Orwm5e.css', (err, stream) => { if (err) { console.error('执行命令错误:', err.message); conn.end(); return; } let cssOutput = ''; stream.stdout.on('data', (data) => { cssOutput += data.toString(); }); stream.on('close', () => { console.log('\n容器内custom-region CSS样式:'); console.log(cssOutput || '未找到'); conn.end(); }); }); }); }); }); conn.on('error', (err) => { console.error('SSH连接错误:', err.message); }); conn.connect(config);