ai_co_discuss 0.4.42 → 0.4.43
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 +3 -2
- package/runner/hosting_tunnel.mjs +2 -1
- package/runner/launcher.mjs +12 -6
- package/web/codiscuss.ico +0 -0
- package/web/modern.js +1 -1
package/package.json
CHANGED
package/runner/admin_panel.mjs
CHANGED
|
@@ -961,8 +961,9 @@ function run_panel(data, port) {
|
|
|
961
961
|
process.stdout.write(`管理面板已启动:http://127.0.0.1:${port}\n`);
|
|
962
962
|
finish_update(data).catch(error => process.stderr.write(`更新收尾失败:${error.message}\n`));
|
|
963
963
|
});
|
|
964
|
-
|
|
965
|
-
const
|
|
964
|
+
// The icon that ships with the package, the same on every computer.
|
|
965
|
+
const icon = join(ROOT, 'web', 'codiscuss.ico');
|
|
966
|
+
const tray = show_tray({ title: '共议', icon_path: existsSync(icon) ? icon : '', window_title: WINDOW_TITLE,
|
|
966
967
|
host: join(data, 'launcher', '共议.exe'), on_action: action => {
|
|
967
968
|
if (action === 'open') open_panel_window(data, panel_url(state), false);
|
|
968
969
|
if (action === 'site') open_browser(site_url(data));
|
|
@@ -97,7 +97,8 @@ function run(cloudflared, args, shown = false) {
|
|
|
97
97
|
|
|
98
98
|
function find_tunnel(cloudflared, name) {
|
|
99
99
|
const text = run(cloudflared, ['tunnel', 'list', '--output', 'json']).trim();
|
|
100
|
-
|
|
100
|
+
// An account without any tunnel lists `null`, not an empty list.
|
|
101
|
+
return (text ? JSON.parse(text) || [] : []).find(item => item.name === name) || null;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
/**
|
package/runner/launcher.mjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* after moving them.
|
|
9
9
|
*/
|
|
10
10
|
import { spawnSync } from 'node:child_process';
|
|
11
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
12
12
|
import { homedir, tmpdir } from 'node:os';
|
|
13
13
|
import { dirname, join } from 'node:path';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
@@ -17,7 +17,11 @@ const RUNNER = dirname(fileURLToPath(import.meta.url));
|
|
|
17
17
|
const ROOT = dirname(RUNNER);
|
|
18
18
|
const EXE_NAME = '共议.exe';
|
|
19
19
|
const SHORTCUT_NAME = '共议.lnk';
|
|
20
|
-
|
|
20
|
+
// Every size Windows picks at the common scales (taskbar 24 at 100%, tray 16/20/24, shortcuts 32/40/48/64, large 256).
|
|
21
|
+
const ICON_SIZES = [256, 64, 48, 40, 32, 24, 20, 16];
|
|
22
|
+
// The icon ships with the package, drawn once where it renders right (see render_icon); drawing it on each computer gave
|
|
23
|
+
// opaque corners where that computer's Edge ignored the transparent background.
|
|
24
|
+
const PACKAGED_ICON = join(ROOT, 'web', 'codiscuss.ico');
|
|
21
25
|
const CSC = join(process.env.WINDIR || 'C:\\Windows', 'Microsoft.NET', 'Framework64', 'v4.0.30319', 'csc.exe');
|
|
22
26
|
const EDGE_PATHS = [join(process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)', 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
|
|
23
27
|
join(process.env.ProgramFiles || 'C:\\Program Files', 'Microsoft', 'Edge', 'Application', 'msedge.exe')];
|
|
@@ -429,9 +433,10 @@ function tile_svg() {
|
|
|
429
433
|
|
|
430
434
|
/**
|
|
431
435
|
* Draw the icon in every size with Edge in headless mode, which renders the SVG mark exactly; each size is drawn on its
|
|
432
|
-
* own rather than scaled down, so small sizes stay sharp.
|
|
436
|
+
* own rather than scaled down, so small sizes stay sharp. Run by hand to refresh the packaged icon after the mark changes
|
|
437
|
+
* (check its corners are transparent), e.g. node -e "import('./runner/launcher.mjs').then(m => m.render_icon('web'))".
|
|
433
438
|
*/
|
|
434
|
-
function render_icon(folder) {
|
|
439
|
+
export function render_icon(folder) {
|
|
435
440
|
const edge = EDGE_PATHS.find(path => existsSync(path));
|
|
436
441
|
if (!edge) return null;
|
|
437
442
|
const work = join(tmpdir(), `codiscuss-icon-${process.pid}`);
|
|
@@ -521,7 +526,8 @@ export function install_launcher(home = join(homedir(), '.codiscuss')) {
|
|
|
521
526
|
if (!existsSync(CSC)) throw new Error(`找不到 .NET Framework 自带的 C# 编译器:${CSC}`);
|
|
522
527
|
const folder = join(home, 'launcher');
|
|
523
528
|
mkdirSync(folder, { recursive: true });
|
|
524
|
-
const icon =
|
|
529
|
+
const icon = existsSync(PACKAGED_ICON) ? join(folder, 'codiscuss.ico') : null;
|
|
530
|
+
if (icon) copyFileSync(PACKAGED_ICON, icon);
|
|
525
531
|
const source = join(folder, 'launcher.cs'), exe = launcher_path(home);
|
|
526
532
|
writeFileSync(source, `\ufeff${launcher_source({ node: process.execPath, local_script: installed_script('discussion_local.mjs'),
|
|
527
533
|
panel_script: installed_script('admin_panel.mjs'), home })}`, 'utf8');
|
|
@@ -534,5 +540,5 @@ export function install_launcher(home = join(homedir(), '.codiscuss')) {
|
|
|
534
540
|
|
|
535
541
|
export function launcher_main() {
|
|
536
542
|
const { exe, icon, shortcuts } = install_launcher();
|
|
537
|
-
process.stdout.write(`已生成启动器:${exe}\n${icon ? '' : '
|
|
543
|
+
process.stdout.write(`已生成启动器:${exe}\n${icon ? '' : '(安装包里缺少图标,启动器使用默认图标)\n'}快捷方式:\n${shortcuts.map(path => ` ${path}`).join('\n')}\n双击即可启动共议。\n`);
|
|
538
544
|
}
|
|
Binary file
|