taskbar-progress 1.0.0 → 1.0.1

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/README.md +153 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # taskbar-progress
2
+
3
+ > **Windows 任务栏进度条(Taskbar Progress)的最小 C++ Addon**
4
+ >
5
+ > ✅ 体积小(~50KB)
6
+ > ✅ 无 Electron 依赖
7
+ > ✅ CommonJS / pkg 友好
8
+ > ✅ Windows 10 / 11 稳定
9
+
10
+ ---
11
+
12
+ ## ✅ 效果
13
+
14
+ | 状态 | 表现 |
15
+ |---|---|
16
+ | 🟩 正常进度 | 绿色进度条填充 |
17
+ | 🌀 不确定进度 | 滚动绿光动画 |
18
+ | 🔴 错误状态 | 红色进度条 |
19
+ | ⬜ 清除进度 | 恢复正常图标 |
20
+
21
+ ---
22
+
23
+ ## 📦 安装
24
+
25
+ ```bash
26
+ npm install taskbar-progress
27
+ ```
28
+
29
+ > **前置要求**:Windows + Visual Studio Build Tools + Python(用于 `node-gyp` 编译)
30
+
31
+ ---
32
+
33
+ ## 🚀 快速使用
34
+
35
+ ```js
36
+ const { setProgress, setIndeterminate, setError } = require('taskbar-progress');
37
+
38
+ // 设置 42% 进度
39
+ setProgress(0.42);
40
+
41
+ // 不确定进度(滚动动画)
42
+ setIndeterminate();
43
+
44
+ // 错误状态(红色)
45
+ setError();
46
+
47
+ // 清除进度条
48
+ setProgress(-1);
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 📖 API 文档
54
+
55
+ ### `setProgress(value: number)`
56
+
57
+ 控制任务栏进度条的显示状态。
58
+
59
+ | 参数值 | 效果 |
60
+ |---|---|
61
+ | `-1` | 清除进度条 |
62
+ | `0.0 ~ 1.0` | 显示对应百分比的绿色进度条 |
63
+ | `>= 1.0` | 显示满格进度条 |
64
+
65
+ ### `setIndeterminate()`
66
+
67
+ 显示不确定进度(滚动绿光动画),适用于无法预估剩余时间的场景。
68
+
69
+ ### `setError()`
70
+
71
+ 显示错误状态(红色进度条),适用于任务失败的场景。
72
+
73
+ ---
74
+
75
+ ## 📁 目录结构
76
+
77
+ ```
78
+ taskbar-progress/
79
+ ├── package.json
80
+ ├── binding.gyp
81
+ ├── src/
82
+ │ └── taskbar.cc
83
+ ├── index.js
84
+ └── README.md
85
+ ```
86
+
87
+ ---
88
+
89
+ ## ⚙️ 手动编译
90
+
91
+ 如果你需要自行编译(而非通过 `npm install` 自动编译):
92
+
93
+ ```bash
94
+ npm install -g node-gyp
95
+ node-gyp configure
96
+ node-gyp build
97
+ ```
98
+
99
+ 编译产物:`build/Release/taskbar_progress.node`
100
+
101
+ ---
102
+
103
+ ## 📦 pkg 打包支持
104
+
105
+ 在 `package.json` 中声明需要打包的 native 文件:
106
+
107
+ ```json
108
+ {
109
+ "pkg": {
110
+ "assets": ["node_modules/taskbar-progress/build/Release/taskbar_progress.node"]
111
+ }
112
+ }
113
+ ```
114
+
115
+ 代码中已内置路径自适应逻辑,pkg 环境下会自动定位到正确的 `.node` 文件路径。
116
+
117
+ ---
118
+
119
+ ## 📝 注意事项
120
+
121
+ - **仅支持 Windows 平台**(会自动跳过其他平台)
122
+ - 需要程序在任务栏有可见按钮(控制台窗口或 GUI 宿主)
123
+ - 在 Windows Terminal 下效果可能不如经典控制台(conhost)明显
124
+ - 如果从隐藏窗口或纯后台服务调用,可能无法显示进度条
125
+
126
+ ---
127
+
128
+ ## 🔧 故障排查
129
+
130
+ ### 编译失败
131
+
132
+ 确保已安装:
133
+ - [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/)(勾选「C++ 桌面开发」)
134
+ - [Python 3.x](https://www.python.org/)(`node-gyp` 依赖)
135
+
136
+ 然后执行:
137
+
138
+ ```bash
139
+ npm config set msvs_version 2022
140
+ npm rebuild
141
+ ```
142
+
143
+ ### 运行时无效果
144
+
145
+ 1. 确认程序是从**有窗口的上下文**运行的(非后台服务)
146
+ 2. 检查 `process.platform === 'win32'` 是否为 `true`
147
+ 3. 尝试从开始菜单快捷方式启动(而非直接双击 exe)
148
+
149
+ ---
150
+
151
+ ## 📄 License
152
+
153
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskbar-progress",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "任务栏进度",
5
5
  "main": "index.js",
6
6
  "keywords": [