dsh-windows-tray 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jankin_lv
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # dsh-windows-tray
2
+
3
+ > DeepSeek Harness(dsh)的 Windows 系统托盘管家:**官方鲸鱼状态图标 + Web/TUI 双状态显示 + 一键启停**。
4
+ > 纯 PowerShell + WinForms 实现,零依赖、无编译、不改 dsh 源码,卸载即还原。
5
+
6
+ [![npm](https://img.shields.io/npm/v/dsh-windows-tray?style=flat-square)](https://www.npmjs.com/package/dsh-windows-tray)
7
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-windows-tray?style=flat-square)](https://www.npmjs.com/package/dsh-windows-tray)
8
+ [![Platform](https://img.shields.io/badge/platform-Windows%2010%2F11-blue?style=flat-square)](https://www.npmjs.com/package/dsh-windows-tray)
9
+ [![License](https://img.shields.io/npm/l/dsh-windows-tray?style=flat-square)](https://github.com/)
10
+
11
+ ## 是什么
12
+
13
+ dsh 默认在终端前台运行 `dsh web`——必须留着一个命令行窗口。本工具把它变成**一个标准的 Windows 托盘应用**:
14
+
15
+ - 🐋 **状态一目了然**:品牌蓝鲸鱼 = Web 运行中;灰鲸鱼 = 未运行(图标由官方 favicon 渲染生成)
16
+ - 📊 **DSH / TUI 双状态**:菜单顶部同屏显示 Web 与 TUI 各自的运行状态(含 PID),互不干扰
17
+ - 🖱️ **零窗口操作**:双击开界面,右键通过 DSH / TUI 分组子菜单一键启停,不用再碰命令行
18
+ - 👁️ **独立旁观者**:托盘是独立常驻进程,dsh 停止时它依然在(显示未运行 + 一键启动),退出托盘不影响 dsh
19
+ - 🎨 **浅色圆角菜单**:白底、圆角、投影阴影,贴合现代桌面应用审美
20
+
21
+ ## 功能特性
22
+
23
+ | 交互 | 行为 |
24
+ | :--- | :--- |
25
+ | **图标** | 蓝鲸鱼 = Web 运行中(PID);灰鲸鱼 = 未运行 |
26
+ | **悬停提示** | `Web UI 运行中 · 127.0.0.1:3088` / `Web UI 未运行 · 右键可启动` |
27
+ | **双击** | 打开 Web UI(未运行先提示启动) |
28
+ | **右键菜单** | 顶部 `Web UI 状态` / `TUI 状态` 双状态行;`Web UI ▸`(打开 Web UI / 启动 / 停止(带确认) / 重启);`TUI ▸`(启动 / 停止);打开日志目录 / `版本信息 ▸`(版本 / 检查更新 / 更新到最新版)/ 退出托盘 |
29
+ | **菜单智能禁用** | Web 运行中禁用「启动 Web UI」;TUI 运行中禁用「启动 TUI」 |
30
+ | **自更新** | 「版本信息 ▸」子菜单(位于退出托盘上方,非日常功能区):查看版本 / 检查更新 / 一键更新到最新版(自动重部署 + 重启托盘) |
31
+ | **状态通知** | Web/TUI 启动与停止瞬间弹系统通知;托盘就绪弹一次提示 |
32
+ | **开机自启** | 登录后托盘自动出现(启动文件夹快捷方式,安装时自动创建) |
33
+
34
+ ## 适配与依赖
35
+
36
+ | 项 | 说明 |
37
+ | :--- | :--- |
38
+ | **dsh 内核** | 适配 `@deepseek-ai/dsh` **v0.1.1-rc.2 系列**(共享核心 `@deepseek-ai/dsh-base` 同版本);dsh 升级不影响托盘 |
39
+ | **Web 服务** | dsh web 默认监听 `127.0.0.1:3088`(即浏览器里的 Web UI)——托盘通过 TCP 探测该端口判断 Web 状态(端口被改时同步修改 `dsh-lib.ps1` 的 `$PORT` 即可) |
40
+ | **TUI 插件** | 适配 `@deepseek-harness-tui/dsh-tui` **^0.9.2**(通过 dsh-profile `dsh-profile-dsh-tui` 挂载);托盘按进程命令行 `dsh-tui` 检测,与插件版本解耦 |
41
+ | **Node.js** | ≥ 18(dsh 本体运行所需) |
42
+ | **PowerShell** | 7(托盘常驻进程;缺省回退 Windows PowerShell 5.1) |
43
+ | **运行时依赖** | **零 npm 依赖**——纯 PowerShell + WinForms + 系统 API;托盘不修改 dsh、不注入任何内容,纯旁观者 |
44
+
45
+ ## 界面预览
46
+
47
+ | 运行中(品牌蓝 `#4176E6`) | 未运行(中性灰 `#81858C`) |
48
+ | :---: | :---: |
49
+ | ![running](build/dsh-tray-running-preview.png) | ![stopped](build/dsh-tray-stopped-preview.png) |
50
+
51
+ > 图标源 = dsh Web 前端官方 favicon(鲸鱼),多尺寸 16~256px;可随时用 `dsh-tray icons` 重新生成。
52
+
53
+ ## 快速开始
54
+
55
+ 前置:Windows 10/11 + [PowerShell 7](https://github.com/PowerShell/PowerShell/releases) + Node.js + 已安装 dsh(任意位置)。
56
+
57
+ ```powershell
58
+ # 1. 全局安装
59
+ npm i -g dsh-windows-tray
60
+
61
+ # 2. 一键部署(自动探测 dsh/pwsh/node 路径 → 安装到 ~\.dsh\launcher
62
+ # → 按本机路径改写配置 → 创建开机自启+桌面快捷方式 → 启动托盘)
63
+ dsh-tray install
64
+
65
+ # 3. 首次使用:把任务栏 ^ 溢出区里的鲸鱼拖到任务栏(一次性,Windows 会记住)
66
+ ```
67
+
68
+ 部署完成后即可双击鲸鱼打开 Web UI,右键管理一切。
69
+
70
+ ## 常用命令
71
+
72
+ | 命令 | 作用 |
73
+ | :--- | :--- |
74
+ | `dsh-tray` | 启动托盘(已有实例则提示,不重复启动) |
75
+ | `dsh-tray install` | 一键部署 / 重新部署(可透传 `-DshRoot` 等参数) |
76
+ | `dsh-tray icons` | 重新生成鲸鱼图标(内置 512px 源图,无需浏览器) |
77
+ | `dsh-tray info` | 查看版本 / 安装位置 / 部署状态 |
78
+ | `npm up -g dsh-windows-tray` | 命令行更新(更新后建议 `dsh-tray install` 重部署) |
79
+
80
+ ## 如何更新
81
+
82
+ 两种方式任选:
83
+
84
+ **方式一:托盘一键更新(推荐)**——托盘菜单「版本信息 ▸」→「检查更新」对比 npm 最新版,发现新版后点「更新到最新版」:自动 `npm install -g` → 重新部署(含本机路径改写)→ 自动重启托盘,全程约 1 分钟,失败不影响当前托盘。
85
+
86
+ **方式二:npm 标准流程**——与普通 npm 包一致:
87
+
88
+ ```powershell
89
+ npm up -g dsh-windows-tray # 拉取最新版
90
+ dsh-tray install # 重新部署(自动改写本机路径 + 刷新快捷方式)
91
+ dsh-tray # 重启托盘(或右键「退出托盘」后重新登录/双击快捷方式)
92
+ ```
93
+
94
+ > 部署目录固定为 `~\.dsh\launcher`,重装/更新都会覆盖旧文件,不会残留;`dsh-tray info` 可查看当前版本与部署状态。
95
+
96
+ ## 工作原理
97
+
98
+ ```
99
+ 托盘(pwsh 常驻) ──2s 轮询──► 127.0.0.1:3088 (Web UI 端口)
100
+ │ └──────────────► node 进程命令行含 'dsh-tui' (TUI 进程)
101
+ ├── 菜单动作 ──► dsh-actions.ps1 (独立隐藏进程, 不卡 UI)
102
+ ├── 自更新 ──► dsh-update.ps1 (npm 安装→重部署→重启)
103
+ └── 单实例 ──► 命名互斥锁 (被强杀遗留的锁自动接管)
104
+ ```
105
+
106
+ - **状态检测**:Web 用 TCP 端口探测(物理单实例);TUI 按命令行匹配(多实例安全:全查全杀);TUI 检测 20s 节流,打开菜单时强制刷新
107
+ - **动作隔离**:启动/停止/重启在独立进程执行,托盘 UI 永不卡顿
108
+ - **日志**:`~\.dsh\logs\dsh-tray.log`(状态变化)+ `dsh-tray-actions.log`(动作)
109
+ - **单点配置**:端口/路径等常量集中在 `launcher/dsh-lib.ps1`,安装时按本机自动改写——**包本身与机器无关**
110
+
111
+ ## 配置
112
+
113
+ | 项 | 位置 | 默认 |
114
+ | :--- | :--- | :--- |
115
+ | 监控端口 | `~\.dsh\launcher\dsh-lib.ps1` 顶部 `$PORT` | `3088` |
116
+ | dsh 路径 | 同上(安装时自动改写) | 自动探测 |
117
+ | 图标颜色 | `build/build-tray-icons.ps1`(运行蓝/停止灰) | `#4176E6` / `#81858C` |
118
+
119
+ ## 常见问题
120
+
121
+ | 问题 | 处理 |
122
+ | :--- | :--- |
123
+ | 任务栏看不到鲸鱼 | 点开 `^` 溢出区,把鲸鱼拖到任务栏(一次性) |
124
+ | 停止 Web UI 会关掉浏览器界面 | 对——停止前有确认框;Web 与当前会话在 3088 端口上 |
125
+ | 托盘退出了怎么唤回 | 双击桌面「DSH 系统托盘」快捷方式 / 重新登录(开机自启)/ `dsh-tray` |
126
+ | 怎么更新到新版 | 托盘菜单「版本信息 ▸ → 更新到最新版」一键完成;或 `npm up -g dsh-windows-tray` + `dsh-tray install`(见「如何更新」) |
127
+ | 检查更新失败 | 网络或 npm 不可用;托盘继续正常工作,稍后再试 |
128
+ | dsh 内核升级了,托盘要动吗 | 不用——托盘只探测 3088 端口与 TUI 进程命令行,与内核版本解耦 |
129
+ | 想彻底卸载 | `npm rm -g dsh-windows-tray` + 删除两个「DSH 系统托盘.lnk」+ 删除 `~\.dsh\launcher` |
130
+
131
+ ## 文档
132
+
133
+ - `docs/system-tray-guide.md` — 使用手册(安装部署 / 功能一览 / 更新 / 卸载 / 故障排查)
134
+ - `docs/tray-dev-archive.md` — 开发归档(架构决策与历史记录)
135
+
136
+ ## 许可
137
+
138
+ MIT
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ // dsh-tray —— DSH 系统托盘的 npm 命令行入口
3
+ // 用法:
4
+ // dsh-tray 启动托盘 (后台, 从已部署目录 ~\.dsh\launcher 运行)
5
+ // dsh-tray install 一键部署到 ~\.dsh\launcher (自动探测路径+快捷方式+启动)
6
+ // dsh-tray icons 重新生成鲸鱼图标 (build/build-tray-icons.ps1)
7
+ // dsh-tray info 显示版本/安装位置/pwsh 路径
8
+ 'use strict';
9
+ const { spawn } = require('child_process');
10
+ const path = require('path');
11
+ const fs = require('fs');
12
+
13
+ const root = path.join(__dirname, '..');
14
+ const pkg = require(path.join(root, 'package.json'));
15
+ const home = process.env.USERPROFILE || process.env.HOME || '';
16
+ const deployDir = path.join(home, '.dsh', 'launcher');
17
+
18
+ function findPwsh() {
19
+ const candidates = [
20
+ process.env.PWSH,
21
+ 'C:\\Program Files\\PowerShell\\7\\pwsh.exe',
22
+ 'D:\\Program Files (x86)\\PowerShell-7.6.4\\pwsh.exe',
23
+ path.join(process.env.ProgramW6432 || 'C:\\Program Files', 'PowerShell\\7\\pwsh.exe'),
24
+ ].filter(Boolean);
25
+ for (const c of candidates) { try { if (fs.existsSync(c)) return c; } catch (_) { /* ignore */ } }
26
+ return 'pwsh'; // 最后让 PATH 解析
27
+ }
28
+
29
+ const cmd = process.argv[2] || 'run';
30
+ const pwsh = findPwsh();
31
+
32
+ switch (cmd) {
33
+ case 'install':
34
+ // 交互式部署: 继承终端, 等安装完成
35
+ spawn(pwsh, ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
36
+ path.join(root, 'install.ps1'), ...process.argv.slice(3)],
37
+ { stdio: 'inherit', windowsHide: true })
38
+ .on('exit', (code) => process.exit(code == null ? 1 : code));
39
+ break;
40
+
41
+ case 'icons':
42
+ spawn(pwsh, ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
43
+ path.join(root, 'build', 'build-tray-icons.ps1')],
44
+ { stdio: 'inherit', windowsHide: true })
45
+ .on('exit', (code) => process.exit(code == null ? 1 : code));
46
+ break;
47
+
48
+ case 'info':
49
+ console.log(`dsh-tray v${pkg.version}`);
50
+ console.log(`包安装位置: ${root}`);
51
+ console.log(`部署目录: ${deployDir}`);
52
+ console.log(`pwsh: ${pwsh}`);
53
+ console.log(`部署状态: ${fs.existsSync(path.join(deployDir, 'dsh-tray.ps1')) ? '已部署' : '未部署 (先运行 dsh-tray install)'}`);
54
+ break;
55
+
56
+ case 'run':
57
+ default: {
58
+ // 托盘是常驻进程: 优先跑已部署(路径已改写)的副本
59
+ const script = fs.existsSync(path.join(deployDir, 'dsh-tray.ps1'))
60
+ ? path.join(deployDir, 'dsh-tray.ps1')
61
+ : path.join(root, 'launcher', 'dsh-tray.ps1');
62
+ const fromDeploy = script.startsWith(deployDir);
63
+ // 反馈模式: 快速退出(单实例锁/失败)立即报告; 存活 3 秒 = 挂载成功
64
+ const child = spawn(pwsh, ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-WindowStyle', 'Hidden', '-File', script], {
65
+ stdio: ['ignore', 'ignore', 'pipe'],
66
+ windowsHide: true,
67
+ });
68
+ let errText = '';
69
+ let settled = false;
70
+ child.stderr.on('data', (d) => (errText += d));
71
+ child.on('error', (e) => {
72
+ if (settled) return;
73
+ settled = true;
74
+ console.error(`dsh-tray: 启动失败 — ${e.message}`);
75
+ process.exit(1);
76
+ });
77
+ child.on('exit', (code) => {
78
+ if (settled) return;
79
+ settled = true;
80
+ if (code === 0) {
81
+ console.log('dsh-tray: 已有托盘实例在运行(单实例保护),本次不重复启动。');
82
+ process.exit(0);
83
+ }
84
+ const lastLine = errText.trim().split(/\r?\n/).pop();
85
+ console.error(`dsh-tray: 启动失败(退出码 ${code})${lastLine ? ' — ' + lastLine : ''}`);
86
+ console.error(fromDeploy ? ' 提示: 日志见 ~\\.dsh\\logs\\dsh-tray.log' : ' 提示: 先运行 dsh-tray install 部署');
87
+ process.exit(1);
88
+ });
89
+ // 子进程存活超过观察窗口 = 托盘已挂载, 视为启动成功
90
+ setTimeout(() => {
91
+ if (settled) return;
92
+ settled = true;
93
+ console.log(fromDeploy
94
+ ? 'dsh-tray: 托盘已后台运行(找不到图标就点任务栏 ^ 折叠区)。'
95
+ : 'dsh-tray: 托盘已后台运行。提示: 未检测到部署, 建议先运行 dsh-tray install 适配本机路径');
96
+ process.exit(0);
97
+ }, 3000);
98
+ break;
99
+ }
100
+ }
@@ -0,0 +1,98 @@
1
+ # build-tray-icons.ps1 —— 从官方鲸鱼 favicon.svg 生成系统托盘图标 (.ico)
2
+ # 用法: pwsh -NoProfile -File build-tray-icons.ps1 [-OutDir <dir>]
3
+ # 输入: whale-render.html 的截图 whale-512.png (浏览器渲染, 黑鲸/白底)
4
+ # 输出: dsh-tray-running.ico (品牌蓝 #4176e6) / dsh-tray-stopped.ico (灰 #81858c)
5
+ # 算法: 灰度 -> 透明度 (白=全透明, 黑=不透明), 整体填充目标色, 保留抗锯齿边缘
6
+ param(
7
+ [string]$OutDir = (Join-Path $PSScriptRoot 'icons')
8
+ )
9
+ $ErrorActionPreference = 'Stop'
10
+ Add-Type -AssemblyName System.Drawing
11
+
12
+ $srcPath = Join-Path $PSScriptRoot 'whale-512.png'
13
+ if (-not (Test-Path $srcPath)) { throw "missing $srcPath (先用浏览器打开 whale-render.html 并截图保存) " }
14
+ New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
15
+
16
+ # 1) 裁出左上角 512x512
17
+ $raw = New-Object System.Drawing.Bitmap($srcPath)
18
+ $crop = New-Object System.Drawing.Bitmap 512, 512, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
19
+ $g = [System.Drawing.Graphics]::FromImage($crop)
20
+ $g.DrawImage($raw, (New-Object System.Drawing.Rectangle(0, 0, 512, 512)), (New-Object System.Drawing.Rectangle(0, 0, 512, 512)), [System.Drawing.GraphicsUnit]::Pixel)
21
+ $g.Dispose(); $raw.Dispose()
22
+
23
+ # 2) 灰度 -> 透明度 + 目标色填充 (LockBits 逐像素, 512x512 约 1~2 秒)
24
+ function Convert-GrayToTint([System.Drawing.Bitmap]$src, [int]$tr, [int]$tg, [int]$tb) {
25
+ $rect = New-Object System.Drawing.Rectangle(0, 0, $src.Width, $src.Height)
26
+ $data = $src.LockBits($rect, [System.Drawing.Imaging.ImageLockMode]::ReadOnly, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
27
+ $bytes = New-Object byte[] ($data.Stride * $src.Height)
28
+ [System.Runtime.InteropServices.Marshal]::Copy($data.Scan0, $bytes, 0, $bytes.Length)
29
+ $src.UnlockBits($data)
30
+ $out = New-Object System.Drawing.Bitmap $src.Width, $src.Height, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
31
+ $outData = $out.LockBits($rect, [System.Drawing.Imaging.ImageLockMode]::WriteOnly, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
32
+ $outBytes = New-Object byte[] ($outData.Stride * $out.Height)
33
+ for ($y = 0; $y -lt $src.Height; $y++) {
34
+ $row = $y * $data.Stride
35
+ $oRow = $y * $outData.Stride
36
+ for ($x = 0; $x -lt $src.Width; $x++) {
37
+ $i = $row + $x * 4
38
+ $lum = [int](($bytes[$i] + $bytes[$i + 1] + $bytes[$i + 2]) / 3)
39
+ $a = 255 - $lum
40
+ $j = $oRow + $x * 4
41
+ $outBytes[$j] = [byte]$tb
42
+ $outBytes[$j + 1] = [byte]$tg
43
+ $outBytes[$j + 2] = [byte]$tr
44
+ $outBytes[$j + 3] = [byte]$a
45
+ }
46
+ }
47
+ [System.Runtime.InteropServices.Marshal]::Copy($outBytes, 0, $outData.Scan0, $outBytes.Length)
48
+ $out.UnlockBits($outData)
49
+ return $out
50
+ }
51
+
52
+ # 3) 多尺寸 ICO (内嵌 PNG)
53
+ function Write-TrayIco([string]$path, [System.Drawing.Bitmap]$tint512, [int[]]$sizes) {
54
+ $blobs = @()
55
+ foreach ($s in $sizes) {
56
+ $bmp = New-Object System.Drawing.Bitmap $s, $s, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
57
+ $g = [System.Drawing.Graphics]::FromImage($bmp)
58
+ $g.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
59
+ $g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
60
+ $g.DrawImage($tint512, 0, 0, $s, $s)
61
+ $g.Dispose()
62
+ $ms = New-Object System.IO.MemoryStream
63
+ $bmp.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
64
+ $blobs += , $ms.ToArray()
65
+ $ms.Dispose(); $bmp.Dispose()
66
+ }
67
+ $fs = [System.IO.File]::Create($path)
68
+ $bw = New-Object System.IO.BinaryWriter($fs)
69
+ $bw.Write([uint16]0); $bw.Write([uint16]1); $bw.Write([uint16]$sizes.Count)
70
+ $offset = 6 + 16 * $sizes.Count
71
+ for ($i = 0; $i -lt $sizes.Count; $i++) {
72
+ $s = $sizes[$i]
73
+ $dim = if ($s -ge 256) { 0 } else { $s }
74
+ $bw.Write([byte]$dim); $bw.Write([byte]$dim)
75
+ $bw.Write([byte]0); $bw.Write([byte]0)
76
+ $bw.Write([uint16]1); $bw.Write([uint16]32)
77
+ $bw.Write([uint32]$blobs[$i].Length); $bw.Write([uint32]$offset)
78
+ $offset += $blobs[$i].Length
79
+ }
80
+ foreach ($b in $blobs) { $bw.Write($b) }
81
+ $bw.Close(); $fs.Close()
82
+ }
83
+
84
+ # 品牌蓝 = DSH 主题 deepseek-500 #4176e6 ; 停止灰 = neutral-bluish-600 #81858c
85
+ $blue = Convert-GrayToTint $crop 0x41 0x76 0xE6
86
+ $gray = Convert-GrayToTint $crop 0x81 0x85 0x8C
87
+ $sizes = @(16, 24, 32, 48, 64, 256)
88
+
89
+ Write-TrayIco (Join-Path $OutDir 'dsh-tray-running.ico') $blue $sizes
90
+ Write-TrayIco (Join-Path $OutDir 'dsh-tray-stopped.ico') $gray $sizes
91
+
92
+ # 256px PNG 预览
93
+ $blue.Save((Join-Path $OutDir 'dsh-tray-running-preview.png'), [System.Drawing.Imaging.ImageFormat]::Png)
94
+ $gray.Save((Join-Path $OutDir 'dsh-tray-stopped-preview.png'), [System.Drawing.Imaging.ImageFormat]::Png)
95
+
96
+ $crop.Dispose(); $blue.Dispose(); $gray.Dispose()
97
+ Get-ChildItem $OutDir | Select-Object Name, Length | Format-Table -AutoSize
98
+ Write-Host "icons written to $OutDir"
Binary file
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html><html><head><meta charset='utf-8'><style>html,body{margin:0;padding:0;background:#ffffff;overflow:hidden}</style></head><body><svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 50 50" fill="none">
2
+ <style>
3
+ @media (prefers-color-scheme: dark) {
4
+ path { fill: #fff; }
5
+ }
6
+ </style>
7
+ <path id="path" d="M48.8354 10.0479C48.3232 9.79199 48.1025 10.2798 47.8032 10.5278C47.7007 10.6079 47.6143 10.7119 47.5273 10.8076C46.7793 11.624 45.9048 12.1597 44.7622 12.0957C43.0923 12 41.666 12.5356 40.4058 13.8398C40.1377 12.2319 39.2476 11.272 37.8926 10.6558C37.1836 10.3359 36.4668 10.0156 35.9702 9.31982C35.6235 8.82373 35.5293 8.27197 35.356 7.72754C35.2456 7.3999 35.1353 7.06396 34.7651 7.00781C34.3633 6.94385 34.2056 7.2876 34.0479 7.57568C33.418 8.75195 33.1733 10.0479 33.1973 11.3599C33.2524 14.312 34.4736 16.6641 36.8999 18.3359C37.1758 18.5278 37.2466 18.7197 37.1597 19C36.9946 19.5757 36.7974 20.1357 36.624 20.7119C36.5137 21.0801 36.3486 21.1597 35.9624 21C34.6309 20.4321 33.481 19.5918 32.4644 18.5757C30.7393 16.8721 29.1792 14.9917 27.2334 13.52C26.7764 13.1758 26.3193 12.856 25.8467 12.5518C23.8618 10.584 26.1069 8.96777 26.627 8.77588C27.1704 8.57568 26.8159 7.8877 25.0591 7.896C23.3022 7.90381 21.6953 8.50391 19.647 9.30371C19.3477 9.42383 19.0322 9.51172 18.7095 9.58398C16.8501 9.22363 14.9199 9.14355 12.9033 9.37598C9.10596 9.80762 6.07275 11.6396 3.84326 14.7681C1.16455 18.5278 0.53418 22.7998 1.30664 27.2559C2.11768 31.9521 4.46582 35.8398 8.07373 38.8799C11.8159 42.0322 16.1255 43.5762 21.041 43.2803C24.0269 43.104 27.3516 42.6963 31.1016 39.4561C32.0469 39.936 33.0396 40.1279 34.686 40.272C35.9546 40.3921 37.1758 40.208 38.1211 40.0078C39.6021 39.688 39.4995 38.2881 38.9639 38.0322C34.623 35.9678 35.5762 36.8081 34.71 36.1279C36.9155 33.4639 40.2402 30.6958 41.54 21.728C41.6426 21.0161 41.5557 20.5679 41.54 19.9917C41.5322 19.6396 41.6108 19.5039 42.0049 19.4639C43.0923 19.3359 44.1479 19.0317 45.1167 18.4878C47.9292 16.9199 49.064 14.3438 49.3315 11.2559C49.3711 10.7837 49.3237 10.2959 48.8354 10.0479ZM24.3262 37.8398C20.1196 34.4639 18.0791 33.3521 17.2358 33.3999C16.4482 33.4482 16.5898 34.3682 16.7632 34.9678C16.9443 35.5601 17.1812 35.9683 17.5117 36.4878C17.7402 36.832 17.8979 37.3442 17.2832 37.728C15.9282 38.584 13.5728 37.4399 13.4624 37.3838C10.7207 35.7358 8.42822 33.5601 6.81348 30.584C5.25342 27.7197 4.34766 24.6479 4.19775 21.3677C4.1582 20.5757 4.38672 20.2959 5.15869 20.1519C6.17529 19.96 7.22314 19.9199 8.23926 20.0718C12.5327 20.7119 16.1885 22.6719 19.2529 25.7759C21.002 27.5439 22.3252 29.6558 23.6885 31.7202C25.1377 33.9121 26.6978 36 28.6831 37.7119C29.3843 38.312 29.9434 38.7681 30.479 39.104C28.8643 39.2881 26.1699 39.3281 24.3262 37.8398ZM26.3433 24.6001C26.3433 24.248 26.6191 23.9678 26.9658 23.9678C27.0444 23.9678 27.1152 23.9839 27.1782 24.0078C27.2651 24.04 27.3438 24.0879 27.4067 24.1602C27.5171 24.272 27.5801 24.4321 27.5801 24.6001C27.5801 24.9521 27.3042 25.2319 26.9575 25.2319C26.6108 25.2319 26.3433 24.9521 26.3433 24.6001ZM32.6064 27.8799C32.2046 28.0479 31.8027 28.1919 31.4165 28.208C30.8179 28.2397 30.1641 27.9922 29.8096 27.688C29.2583 27.2158 28.8643 26.9521 28.6987 26.1279C28.6279 25.7759 28.6675 25.2319 28.7305 24.9199C28.8721 24.248 28.7144 23.8159 28.2495 23.4238C27.8716 23.104 27.3911 23.0161 26.8633 23.0161C26.666 23.0161 26.4849 22.9277 26.3511 22.856C26.1304 22.7441 25.9492 22.4639 26.1226 22.1201C26.1777 22.0078 26.4458 21.7358 26.5088 21.688C27.2256 21.272 28.0527 21.4077 28.8169 21.7197C29.5259 22.0161 30.0615 22.5601 30.834 23.3281C31.6216 24.2559 31.7632 24.5117 32.2124 25.208C32.5669 25.752 32.8901 26.312 33.1104 26.9521C33.2446 27.3521 33.0713 27.6802 32.6064 27.8799Z" fill="#000" fill-opacity="1.000000" fill-rule="nonzero"/>
8
+ </svg>
9
+ </body></html>
@@ -0,0 +1,102 @@
1
+ # DSH 系统托盘(Windows)—— npm 包使用手册
2
+
3
+ > 包名: **`dsh-windows-tray`** · 部署位置: `~\.dsh\launcher` · 技术栈: PowerShell 7 + WinForms,零 npm 依赖、纯旁观者、不改 dsh 源码。
4
+ > 安装 / 更新 / 卸载全部走 npm 标准流程;开发归档见 [tray-dev-archive.md](tray-dev-archive.md),相关踩坑见 [powershell-pitfalls.md](powershell-pitfalls.md)。
5
+
6
+ ---
7
+
8
+ ## 一、安装与部署
9
+
10
+ 前置:Windows 10/11 + [PowerShell 7](https://github.com/PowerShell/PowerShell/releases) + Node.js + 已安装 dsh(任意位置)。
11
+
12
+ ```powershell
13
+ # 1. 全局安装
14
+ npm i -g dsh-windows-tray
15
+
16
+ # 2. 一键部署:自动探测 dsh/pwsh/node 路径 → 安装到 ~\.dsh\launcher
17
+ # → 按本机路径改写配置 → 创建开机自启 + 桌面快捷方式 → 启动托盘
18
+ dsh-tray install
19
+
20
+ # 3. 首次使用:把任务栏 ^ 溢出区里的鲸鱼拖到任务栏(一次性,Windows 会记住)
21
+ ```
22
+
23
+ 常用命令:
24
+
25
+ | 命令 | 作用 |
26
+ | :--- | :--- |
27
+ | `dsh-tray` | 启动托盘(已有实例则提示,不重复启动) |
28
+ | `dsh-tray install` | 一键部署 / 重新部署(可透传 `-DshRoot` 等参数) |
29
+ | `dsh-tray icons` | 重新生成鲸鱼图标(内置 512px 源图,无需浏览器) |
30
+ | `dsh-tray info` | 查看版本 / 安装位置 / 部署状态 |
31
+
32
+ ## 二、功能一览
33
+
34
+ | 交互 | 行为 |
35
+ | :--- | :--- |
36
+ | **图标** | 🐋 品牌蓝鲸鱼 = Web 运行中;灰鲸鱼 = 未运行(官方 favicon 渲染,多尺寸 16~256px) |
37
+ | **悬停提示** | `Web UI 运行中 · 127.0.0.1:3088` / `Web UI 未运行 · 右键可启动` |
38
+ | **双击** | 打开 Web UI(未运行时提示先启动) |
39
+ | **右键菜单** | 顶部 `Web UI 状态` / `TUI 状态` 双状态行(含 PID);`Web UI ▸`(打开 Web UI / 启动 / 停止(带确认) / 重启);`TUI ▸`(启动 / 停止);打开日志目录 / `版本信息 ▸`(版本 / 检查更新 / 更新到最新版)/ 退出托盘 |
40
+ | **菜单智能禁用** | Web 运行中禁用「启动 Web UI」;TUI 运行中禁用「启动 TUI」 |
41
+ | **状态通知** | Web/TUI 启动与停止瞬间弹系统通知;托盘就绪弹一次提示 |
42
+ | **开机自启** | 登录后托盘自动出现(启动文件夹快捷方式,安装时自动创建) |
43
+
44
+ 托盘每 2 秒探测一次 `127.0.0.1:3088`(TCP 连接,500ms 超时,开销可忽略);菜单动作在独立隐藏进程执行,托盘 UI 永不卡顿。
45
+
46
+ ## 三、日常使用
47
+
48
+ 1. **自动跟随**:在 dsh 控制台(`~\.dsh\launcher\dsh-control.ps1`)执行 启动/重启 Web 时,托盘会自动拉起(幂等)。
49
+ 2. **手动唤起**:双击桌面「DSH 系统托盘」快捷方式;或 `dsh-tray`。
50
+ 3. **退出托盘**:右键 → 退出托盘(只退出托盘本身,不影响 dsh;下次登录/双击快捷方式可重新唤起)。
51
+ 4. **取消自启**:删除启动文件夹里的「DSH 系统托盘.lnk」。
52
+
53
+ ## 四、更新
54
+
55
+ 两种方式任选:
56
+
57
+ **方式一:托盘一键更新(推荐)**——托盘菜单「版本信息 ▸」→「检查更新」对比 npm 最新版,发现新版后点「更新到最新版」:自动 `npm install -g` → 重新部署(含本机路径改写)→ 自动重启托盘,失败不影响当前托盘。
58
+
59
+ **方式二:npm 标准流程**:
60
+
61
+ ```powershell
62
+ npm up -g dsh-windows-tray # 拉取最新版
63
+ dsh-tray install # 重新部署(自动改写本机路径 + 刷新快捷方式)
64
+ dsh-tray # 重启托盘
65
+ ```
66
+
67
+ > 部署目录固定为 `~\.dsh\launcher`,重装/更新会覆盖旧文件,不会残留;`dsh-tray info` 可查看当前版本与部署状态。
68
+
69
+ ## 五、卸载
70
+
71
+ ```powershell
72
+ npm rm -g dsh-windows-tray # 移除 npm 包本体
73
+ # 删除两个「DSH 系统托盘.lnk」(启动文件夹 + 桌面)
74
+ # 删除 ~\.dsh\launcher 目录(托盘部署文件;如与 dsh 控制台共用,确认无需保留再删)
75
+ ```
76
+
77
+ ## 六、配置
78
+
79
+ | 项 | 位置 | 默认 |
80
+ | :--- | :--- | :--- |
81
+ | 监控端口 | `~\.dsh\launcher\dsh-lib.ps1` 顶部 `$PORT` | `3088` |
82
+ | dsh 路径 | 同上(安装时自动改写) | 自动探测 |
83
+ | 图标颜色 | 包内 `build/build-tray-icons.ps1`(运行蓝/停止灰) | `#4176E6` / `#81858C` |
84
+
85
+ > 注意:`~\.dsh\launcher` 是部署产物,`dsh-tray install` 每次会整体覆盖——自定义修改请在重部署后重新应用(端口这类常量只有 `$PORT` 一处)。
86
+
87
+ ## 七、故障排查
88
+
89
+ | 现象 | 处理 |
90
+ | :--- | :--- |
91
+ | 任务栏看不到鲸鱼 | 点开 `^` 溢出区查找;若在,拖到任务栏(一次性)。 |
92
+ | 托盘图标消失 / 进程死了 | `dsh-tray` 或双击桌面快捷方式重新唤起;托盘退出不影响 dsh。 |
93
+ | 动作没反应 | 看 `~\.dsh\logs\dsh-tray-actions.log`(菜单动作)与 `dsh-tray.log`(状态变化)。 |
94
+ | 重复实例 | 命名互斥锁单实例保护(被强杀遗留的锁自动接管),正常不会重复。 |
95
+ | 检查更新失败 | 网络或 npm 不可用;托盘继续正常工作,稍后再试。 |
96
+ | dsh 内核升级了,托盘要动吗 | 不用——托盘只探测 3088 端口与 TUI 进程命令行,与内核版本解耦。 |
97
+
98
+ ## 八、已知边界
99
+
100
+ - 通知弹窗受 Windows「通知设置/专注助手」控制,被系统屏蔽时图标与菜单不受影响。
101
+ - 托盘进程是 `pwsh`,`taskkill /T` 杀进程树会连托盘一起结束(下次登录/快捷方式/控制台操作时恢复)。
102
+ - 端口探测只区分 运行/停止:3088 被其他程序占用时会误判"运行中"。
@@ -0,0 +1,57 @@
1
+ # 系统托盘开发归档(v1.0.0 · 2026-08-27)
2
+
3
+ > 托盘已发布为 npm 包 **`dsh-windows-tray`**,日常安装 / 使用 / 更新 / 卸载见 [system-tray-guide.md](system-tray-guide.md)。
4
+ > 本文仅归档开发期的**架构决策与历史记录**(源码细节、文件清单不再维护);通用踩坑已归入 [powershell-pitfalls.md](powershell-pitfalls.md)。
5
+
6
+ ---
7
+
8
+ ## 1. 架构决策(仍生效)
9
+
10
+ | 决策 | 理由 |
11
+ | :--- | :--- |
12
+ | **独立常驻进程**(不嵌入 dsh) | 需求是"看到未启动状态"——进程内嵌图标会随 dsh 消失;旁观者进程才能表达 运行/停止 两态,且能重启已死的 dsh |
13
+ | **端口探测**(每 2s TCP 连 127.0.0.1:3088,500ms 超时) | 不持有进程句柄;dsh 重启 PID 变化也不误判;对 dsh 实现零依赖 |
14
+ | **动作独立进程**(隐藏执行) | 菜单动作(含 taskkill、等待轮询)不阻塞托盘 UI 线程 |
15
+ | **静态 .ico 图标资源** | 不依赖 dsh 运行时接口;缺失时 `New-FallbackIcon` 画纯色圆点兜底 |
16
+ | **命名互斥锁单实例** | 替代 WMI 扫描,无竞态;被强杀遗留的锁自动接管(AbandonedMutexException) |
17
+ | **TUI 单实例锁**(仅启动侧) | 防连点误开多窗口;检测/停止侧本就支持多实例(全查全杀);物理上 TUI 可多开,放开只需移除启动锁 |
18
+
19
+ 进程模型:
20
+
21
+ ```
22
+ 托盘(pwsh) ──2s 轮询──► 端口 3088 (dsh web)
23
+ │ └──────────────► node 进程命令行含 'dsh-tui' (TUI)
24
+ ├── 菜单动作 ──► 独立隐藏进程 (带日志)
25
+ └── 自更新 ──► npm install -g → 重部署 → 重启托盘
26
+ ```
27
+
28
+ ## 2. 图标渲染管线(摘要)
29
+
30
+ 官方 `favicon.svg`(鲸鱼)→ 浏览器渲染 512px → PowerShell 逐像素"亮度转透明度 + 填充目标色" → 多尺寸 ICO(16/24/32/48/64/256)。运行态品牌蓝 `#4176E6`,停止态中性灰 `#81858C`。源图与脚本已内置 npm 包 `build/`,`dsh-tray icons` 可随时再生成。
31
+
32
+ ## 3. 社区借鉴(发布前调研)
33
+
34
+ npm 上两个同思路项目(`dsh-tray`、`dsh-tray-launcher`,均一周内发布),落地到本项目:
35
+
36
+ - **命名互斥锁单实例**(替代 WMI 扫描,无竞态)
37
+ - **浅色圆角菜单**(白底 + 圆角 hover + 细分隔线 + P/Invoke 圆角窗口 + CS_DROPSHADOW 投影,主/子菜单通用)
38
+ - **菜单打开时强制刷新** TUI 状态(`add_Opening`),平时 TUI 检测 20s 节流
39
+ - **停止 DSH 前 MessageBox 确认**、**版本烙印**(启动日志显示 v1.0.0,npm 安装版优先读 package.json)
40
+
41
+ 不照搬的差异化设计:**旁观者架构**(退出托盘不影响 dsh)、**2s 端口轮询状态图标**、**TUI 启停集成 / 官方鲸鱼图标 / 控制台共享公共库**。
42
+
43
+ ## 4. 需求变更决策记录
44
+
45
+ | 时间 | 需求 | 决策 |
46
+ | :--- | :--- | :--- |
47
+ | 2026-08-27 | 托盘内 npm 自更新 | 曾按"更新应由 npm 标准流程承担"移除 → 用户决定恢复("更新加回去吧")→ 菜单「版本信息 ▸」(位于退出托盘上方,非日常功能区)提供 检查更新 / 一键更新;README 同时保留 npm CLI 路径 |
48
+ | 2026-08-27 | 菜单太长 | DSH / TUI 收进子菜单(借鉴更新子菜单收纳思路) |
49
+ | 2026-08-27 | 只显示 dsh 状态 | 顶部双状态行:`DSH 状态: …` / `TUI 状态: …`(独立检测、互不干扰) |
50
+ | 2026-08-27 | 一级/二级菜单间隔大 | 根因:箭头预留撑宽父项 + 事件闭包 $null(详见 powershell-pitfalls §1.1 / §4.2) |
51
+
52
+ ## 5. 已知边界
53
+
54
+ 1. 3088 被其他程序占用时托盘误判"运行中"(属端口问题,与托盘无关)
55
+ 2. 二态检测:只区分 运行/停止,无法区分"忙/卡死"(可扩展 HTTP 探测做三态)
56
+ 3. TUI 单实例是策略而非物理限制(见 §1 决策表)
57
+ 4. 单实例互斥锁在极端竞态下仍有极小双启动概率(影响可忽略)
package/install.ps1 ADDED
@@ -0,0 +1,110 @@
1
+ # install.ps1 —— DSH 系统托盘 一键部署(便携包内运行)
2
+ # 用法: pwsh -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 [-DshRoot <目录>] [-PwshPath <路径>] [-NodePath <路径>] [-NoTrayStart] [-NoShortcuts]
3
+ # 流程: 探测本机路径 -> 安装到 ~\.dsh\launcher -> 改写 dsh-lib.ps1 常量 -> 创建开机自启+桌面快捷方式 -> 启动托盘
4
+ param(
5
+ [string]$DshRoot, # dsh 安装根目录 (含 dsh.cmd); 缺省自动探测
6
+ [string]$PwshPath, # pwsh.exe 路径; 缺省自动探测
7
+ [string]$NodePath, # node.exe 路径; 缺省自动探测
8
+ [switch]$NoTrayStart, # 部署后不自动启动托盘
9
+ [switch]$NoShortcuts # 不创建快捷方式
10
+ )
11
+ $ErrorActionPreference = 'Stop'
12
+ $pkgRoot = $PSScriptRoot
13
+ $dst = Join-Path $env:USERPROFILE '.dsh\launcher'
14
+
15
+ Write-Host '== DSH 系统托盘 一键部署 ==' -ForegroundColor Cyan
16
+
17
+ # 1) 探测 dsh 安装根目录
18
+ if (-not $DshRoot) {
19
+ $candidates = @(
20
+ (Join-Path $pkgRoot '..\..'), # 包直接放在 dsh 安装根内: <根>\dist\dsh-tray-package\
21
+ 'D:\Program Files (x86)\dsh',
22
+ 'C:\Program Files\dsh',
23
+ (Join-Path $env:USERPROFILE 'dsh'),
24
+ (Join-Path $env:LOCALAPPDATA 'dsh')
25
+ )
26
+ foreach ($c in $candidates) {
27
+ $c = [System.IO.Path]::GetFullPath($c)
28
+ if (Test-Path (Join-Path $c 'dsh.cmd')) { $DshRoot = $c; break }
29
+ }
30
+ }
31
+ $dsdCmd = Join-Path $DshRoot 'dsh.cmd'
32
+ if (-not (Test-Path $dsdCmd)) { throw "未找到 dsh 安装目录 (缺少 dsh.cmd: $dsdCmd)。请用 -DshRoot 指定。" }
33
+ Write-Host "[1/5] dsh 根目录: $DshRoot" -ForegroundColor Green
34
+
35
+ # 2) 探测 pwsh (PowerShell 7)
36
+ if (-not $PwshPath) {
37
+ $cmd = Get-Command pwsh -ErrorAction SilentlyContinue
38
+ if ($cmd) { $PwshPath = $cmd.Source }
39
+ elseif (Test-Path 'C:\Program Files\PowerShell\7\pwsh.exe') { $PwshPath = 'C:\Program Files\PowerShell\7\pwsh.exe' }
40
+ elseif (Test-Path 'D:\Program Files (x86)\PowerShell-7.6.4\pwsh.exe') { $PwshPath = 'D:\Program Files (x86)\PowerShell-7.6.4\pwsh.exe' }
41
+ }
42
+ if (-not $PwshPath -or -not (Test-Path $PwshPath)) { throw "未找到 pwsh (PowerShell 7)。请用 -PwshPath 指定。" }
43
+ Write-Host "[2/5] pwsh: $PwshPath" -ForegroundColor Green
44
+
45
+ # 3) 探测 node
46
+ if (-not $NodePath) {
47
+ $cmd = Get-Command node -ErrorAction SilentlyContinue
48
+ if ($cmd) { $NodePath = $cmd.Source }
49
+ elseif (Test-Path 'C:\Program Files\nodejs\node.exe') { $NodePath = 'C:\Program Files\nodejs\node.exe' }
50
+ }
51
+ if (-not $NodePath -or -not (Test-Path $NodePath)) { throw "未找到 node.exe。请用 -NodePath 指定。" }
52
+ Write-Host "[3/5] node: $NodePath" -ForegroundColor Green
53
+
54
+ # 4) 安装到 ~\.dsh\launcher
55
+ New-Item -ItemType Directory -Force -Path $dst | Out-Null
56
+ Copy-Item -Path (Join-Path $pkgRoot 'launcher\*') -Destination $dst -Recurse -Force
57
+ Write-Host "[4/5] 已安装到 $dst" -ForegroundColor Green
58
+
59
+ # 5) 按本机路径改写 dsh-lib.ps1 常量 (源文件带工作机默认值, 这里就地修正)
60
+ $lib = Join-Path $dst 'dsh-lib.ps1'
61
+ $bin = Join-Path $DshRoot 'node_modules\@deepseek-ai\dsh\lib\bin.js'
62
+ if (-not (Test-Path $bin)) { Write-Host "警告: 未找到 $bin (dsh 包结构可能不同), 请检查 dsh-lib.ps1 的 \$BIN" -ForegroundColor Yellow }
63
+ $map = [ordered]@{
64
+ '$DSH_CMD = ' = "`$DSH_CMD = '$($DshRoot -replace "'", "''")\dsh.cmd'"
65
+ '$NODE = ' = "`$NODE = '$($NodePath -replace "'", "''")'"
66
+ '$BIN = ' = "`$BIN = '$($bin -replace "'", "''")'"
67
+ '$WORKDIR = ' = "`$WORKDIR = '$($DshRoot -replace "'", "''")'"
68
+ '$PWSH = ' = "`$PWSH = '$($PwshPath -replace "'", "''")'"
69
+ }
70
+ $lines = Get-Content $lib
71
+ for ($i = 0; $i -lt $lines.Count; $i++) {
72
+ foreach ($k in $map.Keys) {
73
+ if ($lines[$i].StartsWith($k)) { $lines[$i] = $map[$k]; break }
74
+ }
75
+ }
76
+ Set-Content -Path $lib -Value $lines -Encoding utf8
77
+ Write-Host '[5/5] dsh-lib.ps1 路径常量已改写' -ForegroundColor Green
78
+
79
+ # 快捷方式: 开机自启 + 桌面
80
+ if (-not $NoShortcuts) {
81
+ $ws = New-Object -ComObject WScript.Shell
82
+ $icon = Join-Path $dst 'icons\dsh-tray-running.ico,0'
83
+ $argsLine = '-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "' + (Join-Path $dst 'dsh-tray.ps1') + '"'
84
+ foreach ($target in @(
85
+ @{ Dir = [Environment]::GetFolderPath('Startup'); Name = 'DSH 系统托盘.lnk'; Desc = 'DSH 系统托盘 - 鲸鱼图标=运行状态, 右键控制' },
86
+ @{ Dir = [Environment]::GetFolderPath('Desktop'); Name = 'DSH 系统托盘.lnk'; Desc = 'DSH 系统托盘 - 双击唤起' }
87
+ )) {
88
+ $lnk = $ws.CreateShortcut((Join-Path $target.Dir $target.Name))
89
+ $lnk.TargetPath = $PwshPath
90
+ $lnk.Arguments = $argsLine
91
+ $lnk.WorkingDirectory = $dst
92
+ $lnk.IconLocation = $icon
93
+ $lnk.WindowStyle = 7
94
+ $lnk.Description = $target.Desc
95
+ $lnk.Save()
96
+ }
97
+ Write-Host '快捷方式: 开机自启 + 桌面 已创建' -ForegroundColor Green
98
+ }
99
+
100
+ # 启动托盘
101
+ if (-not $NoTrayStart) {
102
+ Start-Process -FilePath $PwshPath -ArgumentList @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-WindowStyle', 'Hidden', '-File', (Join-Path $dst 'dsh-tray.ps1')) -WindowStyle Hidden
103
+ Write-Host '托盘已启动 (若图标在 ^ 溢出区, 拖到任务栏即可)' -ForegroundColor Green
104
+ }
105
+
106
+ Write-Host ''
107
+ Write-Host '部署完成! 常用命令:' -ForegroundColor Cyan
108
+ Write-Host ' 手动唤起托盘: 桌面「DSH 系统托盘」/ 控制台选项 5'
109
+ Write-Host ' 取消自启: 删除启动文件夹里的「DSH 系统托盘.lnk」'
110
+ Write-Host ' 卸载: 删除快捷方式 + 删除 ~\.dsh\launcher'