@wendongfly/myhi 1.3.158 → 1.3.160
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/bin/myhi.js +23 -0
- package/dist/index.html +11 -5
- package/dist/index.js +1 -1
- package/dist/index.min.js +3 -3
- package/package.json +1 -1
package/bin/myhi.js
CHANGED
|
@@ -12,6 +12,7 @@ const __dirname = dirname(__filename);
|
|
|
12
12
|
const args = process.argv.slice(2);
|
|
13
13
|
let cmd = null;
|
|
14
14
|
let httpOnlyFlag = null; // null=不改;true=切 HTTP-only;false=切回 HTTPS
|
|
15
|
+
let hostFlag = null; // null=不改;否则持久化监听地址到 config.json(如 Tailscale IP,公网不可达)
|
|
15
16
|
for (let i = 0; i < args.length; i++) {
|
|
16
17
|
if ((args[i] === '-p' || args[i] === '--port') && args[i + 1]) {
|
|
17
18
|
process.env.PORT = args[i + 1];
|
|
@@ -19,6 +20,10 @@ for (let i = 0; i < args.length; i++) {
|
|
|
19
20
|
} else if (args[i].startsWith('--port=')) {
|
|
20
21
|
process.env.PORT = args[i].split('=')[1];
|
|
21
22
|
args.splice(i, 1); i--;
|
|
23
|
+
} else if ((args[i] === '--host' || args[i].startsWith('--host=')) && args[i].includes('=')) {
|
|
24
|
+
hostFlag = args[i].split('=')[1]; args.splice(i, 1); i--;
|
|
25
|
+
} else if (args[i] === '--host' && args[i + 1]) {
|
|
26
|
+
hostFlag = args[i + 1]; args.splice(i, 2); i--;
|
|
22
27
|
} else if (args[i] === '--http' || args[i] === '--no-https') {
|
|
23
28
|
httpOnlyFlag = true; args.splice(i, 1); i--;
|
|
24
29
|
} else if (args[i] === '--https') {
|
|
@@ -63,6 +68,24 @@ if (httpOnlyFlag !== null) {
|
|
|
63
68
|
if (!cmd) cmd = 'restart'; // 无显式命令 → 切完直接重启使其生效
|
|
64
69
|
}
|
|
65
70
|
|
|
71
|
+
// --host <addr>:持久化监听地址到 config.json(server 启动时读取,任何重启都保留)。
|
|
72
|
+
// 典型用法:`myhi --host <Tailscale IP>` 把 myhi 只绑内网,公网不可达。设完自动 restart。
|
|
73
|
+
if (hostFlag !== null) {
|
|
74
|
+
try {
|
|
75
|
+
mkdirSync(configDir, { recursive: true });
|
|
76
|
+
let cfg = {};
|
|
77
|
+
try { cfg = JSON.parse(readFileSync(configFile, 'utf8')); } catch {}
|
|
78
|
+
cfg.host = hostFlag.trim() || undefined; // 空串 = 回到默认 0.0.0.0
|
|
79
|
+
if (!cfg.host) delete cfg.host;
|
|
80
|
+
writeFileSync(configFile, JSON.stringify(cfg, null, 2));
|
|
81
|
+
console.log(`[myhi] 监听地址已设为 ${cfg.host || '0.0.0.0(全部接口)'},重启后仍保留`);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.error('[myhi] 写入 config.json 失败:', e.message);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
if (!cmd) cmd = 'restart';
|
|
87
|
+
}
|
|
88
|
+
|
|
66
89
|
// ── 工具函数 ──────────────────────────────────────────────
|
|
67
90
|
|
|
68
91
|
function readPid() {
|
package/dist/index.html
CHANGED
|
@@ -640,6 +640,11 @@
|
|
|
640
640
|
document.getElementById('drive-bar').style.display = 'none';
|
|
641
641
|
renderRecentDirs();
|
|
642
642
|
}
|
|
643
|
+
if (data.defaultRoot) {
|
|
644
|
+
_serverRoot = data.defaultRoot;
|
|
645
|
+
// fetch 晚于用户开始输入时补一次同步(用户已手改目录则不覆盖)
|
|
646
|
+
if (!_cwdTouched) syncCwdToTitle();
|
|
647
|
+
}
|
|
643
648
|
}).catch(() => {});
|
|
644
649
|
|
|
645
650
|
async function showUsage() {
|
|
@@ -1229,17 +1234,18 @@
|
|
|
1229
1234
|
}
|
|
1230
1235
|
|
|
1231
1236
|
// ── 工作目录默认跟随任务名 ─────────────────────────────────
|
|
1232
|
-
// 任务名 → <根目录>/<任务名>,如
|
|
1237
|
+
// 任务名 → <根目录>/<任务名>,如 test → /home/dev/test(服务端会自动 mkdir)。
|
|
1238
|
+
// 根目录以服务端为准(/api/me 的 defaultRoot:绑定目录 > MYHI_CWD > server cwd),
|
|
1239
|
+
// 不按浏览器 OS 猜——Windows 浏览器访问 Linux 主机时猜 D:\project 是错的。
|
|
1233
1240
|
// 手改目录 / 📁 选择 / 点最近目录 = 用户接管,本次弹窗内不再自动覆盖;📌 把当前目录
|
|
1234
|
-
// 的上级记为根目录(localStorage
|
|
1241
|
+
// 的上级记为根目录(localStorage 持久,优先级最高)。
|
|
1235
1242
|
const ROOT_KEY = 'myhi_newtask_root';
|
|
1236
|
-
|
|
1237
|
-
const ROOT_DEFAULT = IS_WIN ? 'D:\\project' : '';
|
|
1243
|
+
let _serverRoot = null;
|
|
1238
1244
|
let _cwdTouched = false;
|
|
1239
1245
|
|
|
1240
1246
|
function taskRoot() {
|
|
1241
1247
|
try { const v = localStorage.getItem(ROOT_KEY); if (v) return v; } catch {}
|
|
1242
|
-
return
|
|
1248
|
+
return _serverRoot || ''; // 没拿到服务端根:不猜,留空自选
|
|
1243
1249
|
}
|
|
1244
1250
|
function sanitizeTaskName(name) {
|
|
1245
1251
|
// 与服务端 taskCwdFromTitle 同款清洗:Windows 目录非法字符 → '_',掐头尾点和空白
|