ai_co_discuss 0.4.47 → 0.4.49
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 +1 -1
- package/runner/admin_panel.mjs +14 -6
- package/runner/cli_login.mjs +2 -1
- package/web/admin.css +1 -1
- package/web/admin.js +2 -2
- package/web/modern.js +1 -1
package/package.json
CHANGED
package/runner/admin_panel.mjs
CHANGED
|
@@ -810,8 +810,10 @@ async function entry_overview(data) {
|
|
|
810
810
|
async function set_entry_mode(data, mode) {
|
|
811
811
|
const settings = entry_settings(data);
|
|
812
812
|
if (mode === 'relay') {
|
|
813
|
-
|
|
814
|
-
if (!
|
|
813
|
+
const bound = bound_site(data);
|
|
814
|
+
if (!bound) throw new Error('这台电脑还没有接入线上站点:先用接入码接入');
|
|
815
|
+
// Bound without an access code (`codiscuss local connect`): the site it is bound to gives the entry address.
|
|
816
|
+
if (!settings.relay_url) await set_relay_url(data, await site_entry_url(bound.site));
|
|
815
817
|
}
|
|
816
818
|
if (mode === 'tunnel' && !settings.tunnel) throw new Error('还没有设好 Cloudflare 隧道:先点“设置”填写你的域名');
|
|
817
819
|
if (mode !== 'local' && process.platform === 'win32') {
|
|
@@ -881,15 +883,21 @@ async function join_relay(data, text) {
|
|
|
881
883
|
const steps = [];
|
|
882
884
|
if (bound_site(data)?.site === site) steps.push(`已接入 ${site}`);
|
|
883
885
|
else { await connect_site(data, site, token); steps.push(`已接入 ${site}`); }
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
steps.push(`入口地址 ${given.entry_url}`);
|
|
886
|
+
const entry_url = await site_entry_url(site);
|
|
887
|
+
await set_relay_url(data, entry_url);
|
|
888
|
+
steps.push(`入口地址 ${entry_url}`);
|
|
888
889
|
const overview = await set_entry_mode(data, 'relay');
|
|
889
890
|
steps.push('已切换到线上中转');
|
|
890
891
|
return { steps, entry: overview };
|
|
891
892
|
}
|
|
892
893
|
|
|
894
|
+
/** The entry Worker address an online site gives (`GET /api/entry`). */
|
|
895
|
+
async function site_entry_url(site) {
|
|
896
|
+
const given = await fetch(`${site}/api/entry`, { signal: AbortSignal.timeout(RELAY_CHECK_MS) }).then(answer => answer.json()).catch(() => ({}));
|
|
897
|
+
if (!given.entry_url) throw new Error(`${site} 没有提供入口地址:请部署线上站点的人在部署配置里设置 ENTRY_URL 并重新发布`);
|
|
898
|
+
return given.entry_url;
|
|
899
|
+
}
|
|
900
|
+
|
|
893
901
|
/** Save the relay's entry address after checking that it answers as one. */
|
|
894
902
|
async function set_relay_url(data, url) {
|
|
895
903
|
const origin = String(url || '').trim().replace(/\/+$/, '');
|
package/runner/cli_login.mjs
CHANGED
|
@@ -162,7 +162,8 @@ function start_console(data, target, exe) {
|
|
|
162
162
|
const files = { 'host.ps1': `${CONSOLE_HOST}`, 'command.txt': `"${exe}"` };
|
|
163
163
|
if (target) return run_as_user(data, target, "& (Join-Path $Job 'host.ps1') -Job $Job", { files, wait: false });
|
|
164
164
|
const folder = owner_folder(files);
|
|
165
|
-
|
|
165
|
+
// Not detached: a PowerShell started detached (no console) exits at once with code 0 without running its script.
|
|
166
|
+
spawn(POWERSHELL, ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', join(folder, 'host.ps1'), '-Job', folder], { stdio: 'ignore', windowsHide: true }).unref();
|
|
166
167
|
return { folder };
|
|
167
168
|
}
|
|
168
169
|
|