@wendongfly/myhi 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/bin/myhi.js +23 -4
  2. package/package.json +1 -1
package/bin/myhi.js CHANGED
@@ -7,7 +7,22 @@ import { homedir } from 'os';
7
7
 
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = dirname(__filename);
10
- const cmd = process.argv[2];
10
+
11
+ // 解析 -p / --port 参数
12
+ const args = process.argv.slice(2);
13
+ let cmd = null;
14
+ for (let i = 0; i < args.length; i++) {
15
+ if ((args[i] === '-p' || args[i] === '--port') && args[i + 1]) {
16
+ process.env.PORT = args[i + 1];
17
+ args.splice(i, 2); i--;
18
+ } else if (args[i].startsWith('--port=')) {
19
+ process.env.PORT = args[i].split('=')[1];
20
+ args.splice(i, 1); i--;
21
+ } else if (!cmd && !args[i].startsWith('-')) {
22
+ cmd = args[i];
23
+ }
24
+ }
25
+ if (!cmd) cmd = args[0];
11
26
 
12
27
  const configDir = join(homedir(), '.myhi');
13
28
  const pidFile = join(configDir, 'daemon.pid');
@@ -90,12 +105,13 @@ if (cmd === 'attach') {
90
105
 
91
106
  } else if (cmd === 'help' || cmd === '--help' || cmd === '-h') {
92
107
  console.log(`
93
- myhi v1.0.0 — 基于 Web 的终端共享工具
108
+ myhi — 基于 Web 的终端共享工具
94
109
  通过局域网或 Tailscale 在手机/平板上控制电脑终端,无需中继服务器。
95
110
 
96
111
  服务器:
97
112
  myhi 前台启动服务器
98
113
  myhi start 前台启动服务器
114
+ myhi -p <port> 指定监听端口(默认 3000)
99
115
  myhi -d, --daemon 后台启动服务器(日志写入 ~/.myhi/daemon.log)
100
116
  myhi stop 停止后台服务器
101
117
  myhi restart 重启后台服务器
@@ -110,10 +126,12 @@ myhi v1.0.0 — 基于 Web 的终端共享工具
110
126
  快捷键(attach 模式):
111
127
  Ctrl+] 分离终端(退出但不关闭会话)
112
128
 
129
+ 选项:
130
+ -p, --port <port> 监听端口(默认 3000)
131
+
113
132
  环境变量:
114
133
  PORT 监听端口(默认 3000)
115
134
  HOST 监听地址(默认 0.0.0.0)
116
- HTTPS_PORT HTTPS 端口(默认 3443)
117
135
  MYHI_AUTO_ATTACH 启动时自动创建会话(默认 1,设 0 关闭)
118
136
  MYHI_CWD 会话工作目录(默认当前目录)
119
137
  MYHI_SERVER attach 连接的服务器地址(默认 http://localhost:3000)
@@ -128,7 +146,8 @@ myhi v1.0.0 — 基于 Web 的终端共享工具
128
146
 
129
147
  示例:
130
148
  myhi # 启动后扫描二维码即可在手机上操作
131
- PORT=8080 myhi -d # 8080 端口后台启动
149
+ myhi -p 8080 # 指定 8080 端口启动
150
+ myhi -p 8080 -d # 8080 端口后台启动
132
151
  MYHI_CWD=/project myhi # 指定会话工作目录
133
152
  myhi attach # 从另一台机器连接到会话
134
153
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wendongfly/myhi",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Web-based terminal sharing with chat UI — control your terminal from phone via LAN/Tailscale",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",