31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
const { Client } = require('ssh2');
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 测试后端价格接口 ===');
|
|
|
|
conn.exec('curl -s http://127.0.0.1:4000/api/prices', (err, stream) => {
|
|
if (err) { console.log('ERR:', err); conn.end(); return; }
|
|
let data = '';
|
|
stream.on('data', (d) => data += d.toString());
|
|
stream.on('close', () => {
|
|
const result = JSON.parse(data);
|
|
console.log('价格列表:', result.prices.map(p => `${p.name} (${p.category}) - ¥${p.price}/${p.unit}`));
|
|
|
|
console.log('\n=== 测试H5页面 ===');
|
|
conn.exec('curl -s -o /dev/null -w "%{http_code}" https://hs.yifenbao.cn/', (err2, stream2) => {
|
|
if (err2) { console.log('ERR2:', err2); conn.end(); return; }
|
|
stream2.on('data', (d) => {
|
|
console.log('H5页面状态码:', d.toString().trim());
|
|
});
|
|
stream2.on('close', () => {
|
|
console.log('\n✅ 部署验证完成!');
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' }); |