huoxingren 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huoxingren",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "火星人范式助学平台 CLI - 训练进度管理工具",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,13 +22,16 @@ export async function login(opts) {
22
22
  const anonKey = url.searchParams.get('anon_key');
23
23
  if (token) {
24
24
  saveConfig({ token, apiUrl: platformUrl, ...(anonKey ? { anonKey } : {}) });
25
- res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
26
- res.end('<html><body style="font-family:sans-serif;text-align:center;padding:60px"><h1>登录成功!</h1><p>可以关闭此页面了。</p></body></html>');
27
- console.log('登录成功!');
25
+ const dashboardUrl = `${platformUrl}/#/dashboard`;
26
+ res.writeHead(302, { Location: dashboardUrl });
27
+ res.end();
28
+ console.log('✔ 登录成功!凭证已保存到 ~/.huoxingren/config.json');
29
+ server.closeAllConnections();
28
30
  server.close();
29
31
  resolve();
32
+ setTimeout(() => process.exit(0), 200);
30
33
  } else {
31
- res.writeHead(400);
34
+ res.writeHead(400, { 'Content-Type': 'text/plain; charset=utf-8' });
32
35
  res.end('缺少 token');
33
36
  }
34
37
  } else {
@@ -47,8 +50,10 @@ export async function login(opts) {
47
50
 
48
51
  setTimeout(() => {
49
52
  console.log('登录超时(2分钟)。请重试。');
50
- server.close();
51
- resolve();
53
+ server.close(() => {
54
+ resolve();
55
+ process.exit(1);
56
+ });
52
57
  }, 120000);
53
58
  });
54
59
  }
package/src/index.js CHANGED
@@ -13,7 +13,7 @@ const program = new Command();
13
13
  program
14
14
  .name('huoxingren')
15
15
  .description('火星人范式助学平台 CLI')
16
- .version('0.1.0');
16
+ .version('0.1.2');
17
17
 
18
18
  program
19
19
  .command('login')