intools-cli 1.0.4 → 1.0.6
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/PLUGIN_API.md +221 -4
- package/README.md +66 -10
- package/dist/commands/create/templates/react.js +8 -1
- package/dist/commands/pack.js +11 -0
- package/package.json +1 -1
package/PLUGIN_API.md
CHANGED
|
@@ -1,11 +1,201 @@
|
|
|
1
|
-
# InTools
|
|
1
|
+
# InTools 插件开发完整指南
|
|
2
2
|
|
|
3
|
-
> 本文档包含 InTools
|
|
3
|
+
> 本文档包含 InTools 插件开发所需的全部信息,包括 Manifest 配置规范和 API 参考。
|
|
4
4
|
> - **UI/渲染进程**:`window.intools.{模块名}`
|
|
5
5
|
> - **插件后端**:`context.api.{模块名}`
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
# 第一部分:Manifest 配置规范
|
|
10
|
+
|
|
11
|
+
## manifest.json 基本结构
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"name": "my-plugin",
|
|
16
|
+
"version": "1.0.0",
|
|
17
|
+
"type": "utility",
|
|
18
|
+
"displayName": "我的插件",
|
|
19
|
+
"description": "插件描述",
|
|
20
|
+
"main": "dist/main.js",
|
|
21
|
+
"ui": "ui/index.html",
|
|
22
|
+
"icon": "icon.png",
|
|
23
|
+
"pluginSetting": {
|
|
24
|
+
"single": true,
|
|
25
|
+
"height": 400
|
|
26
|
+
},
|
|
27
|
+
"window": {
|
|
28
|
+
"width": 800,
|
|
29
|
+
"height": 600
|
|
30
|
+
},
|
|
31
|
+
"features": [
|
|
32
|
+
{
|
|
33
|
+
"code": "main",
|
|
34
|
+
"explain": "主功能",
|
|
35
|
+
"cmds": [{ "type": "keyword", "value": "关键词" }]
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 顶层字段
|
|
42
|
+
|
|
43
|
+
| 字段 | 类型 | 必需 | 说明 |
|
|
44
|
+
|------|------|------|------|
|
|
45
|
+
| name | string | ✓ | 插件唯一标识 |
|
|
46
|
+
| version | string | ✓ | 版本号 |
|
|
47
|
+
| type | string | | 类型(utility/productivity/developer/system/media/network/ai/entertainment/other) |
|
|
48
|
+
| displayName | string | ✓ | 显示名称 |
|
|
49
|
+
| description | string | | 插件描述 |
|
|
50
|
+
| main | string | ✓ | 后端入口文件 |
|
|
51
|
+
| ui | string | | UI 入口文件 |
|
|
52
|
+
| preload | string | | 自定义 preload 脚本(可使用 Node.js) |
|
|
53
|
+
| icon | string/object | | 插件图标(路径/URL/SVG) |
|
|
54
|
+
| features | array | ✓ | 功能入口列表 |
|
|
55
|
+
| pluginSetting | object | | 插件行为设置 |
|
|
56
|
+
| window | object | | 独立窗口配置 |
|
|
57
|
+
|
|
58
|
+
## PluginSetting 配置
|
|
59
|
+
|
|
60
|
+
| 字段 | 类型 | 默认值 | 说明 |
|
|
61
|
+
|------|------|--------|------|
|
|
62
|
+
| single | boolean | true | 单例模式(不允许多开) |
|
|
63
|
+
| height | number | - | 初始高度 |
|
|
64
|
+
|
|
65
|
+
## Window 配置
|
|
66
|
+
|
|
67
|
+
| 字段 | 默认值 | 说明 |
|
|
68
|
+
|------|--------|------|
|
|
69
|
+
| width | 500 | 默认宽度 |
|
|
70
|
+
| height | 400 | 默认高度 |
|
|
71
|
+
| minWidth | 300 | 最小宽度 |
|
|
72
|
+
| minHeight | 200 | 最小高度 |
|
|
73
|
+
| maxWidth | - | 最大宽度 |
|
|
74
|
+
| maxHeight | - | 最大高度 |
|
|
75
|
+
|
|
76
|
+
## Feature 字段
|
|
77
|
+
|
|
78
|
+
| 字段 | 类型 | 必需 | 说明 |
|
|
79
|
+
|------|------|------|------|
|
|
80
|
+
| code | string | ✓ | 功能代码 |
|
|
81
|
+
| explain | string | ✓ | 功能说明 |
|
|
82
|
+
| cmds | array | ✓ | 触发命令列表 |
|
|
83
|
+
| mode | string | | 模式(ui/silent/detached) |
|
|
84
|
+
| route | string | | UI 路由路径 |
|
|
85
|
+
| icon | string/object | | 功能独立图标 |
|
|
86
|
+
| mainHide | boolean | | 触发时隐藏主窗口 |
|
|
87
|
+
| mainPush | boolean | | 向搜索框推送内容 |
|
|
88
|
+
|
|
89
|
+
## Cmd 命令类型
|
|
90
|
+
|
|
91
|
+
| type | 触发方式 | 可用字段 |
|
|
92
|
+
|------|----------|----------|
|
|
93
|
+
| keyword | 关键词匹配 | `value`(关键词) |
|
|
94
|
+
| regex | 正则匹配 | `match`(正则), `explain?`, `label?`(指令名称), `minLength?`, `maxLength?` |
|
|
95
|
+
| files | 文件拖入 | `exts?`, `fileType?`(file/directory/any, 默认 any), `match?`(文件名正则, 与 exts 二选一), `minLength?`, `maxLength?` |
|
|
96
|
+
| img | 图片拖入 | `exts?` |
|
|
97
|
+
| over | 选中文本 | `label?`(指令名称), `exclude?`(排除正则), `minLength?`, `maxLength?`(默认 10000) |
|
|
98
|
+
|
|
99
|
+
### 示例
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"features": [
|
|
104
|
+
{
|
|
105
|
+
"code": "format",
|
|
106
|
+
"explain": "格式化 JSON",
|
|
107
|
+
"cmds": [
|
|
108
|
+
{ "type": "keyword", "value": "json" },
|
|
109
|
+
{ "type": "regex", "match": "^\\s*[{\\[]", "explain": "检测到 JSON" }
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"code": "process-pdf",
|
|
114
|
+
"explain": "处理 PDF 文件",
|
|
115
|
+
"cmds": [
|
|
116
|
+
{ "type": "files", "exts": [".pdf"], "minLength": 1, "maxLength": 10 }
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"code": "folder-tool",
|
|
121
|
+
"explain": "文件夹工具",
|
|
122
|
+
"cmds": [
|
|
123
|
+
{ "type": "files", "fileType": "directory" }
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Icon 图标配置
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
// 字符串简写
|
|
134
|
+
"icon": "icon.png"
|
|
135
|
+
"icon": "https://example.com/icon.png"
|
|
136
|
+
"icon": "<svg>...</svg>"
|
|
137
|
+
|
|
138
|
+
// 对象形式
|
|
139
|
+
"icon": { "type": "file", "value": "assets/logo.png" }
|
|
140
|
+
"icon": { "type": "url", "value": "https://example.com/icon.png" }
|
|
141
|
+
"icon": { "type": "svg", "value": "<svg>...</svg>" }
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Preload 配置(自定义 Node.js 能力)
|
|
145
|
+
|
|
146
|
+
配置自定义 preload 脚本,可在渲染进程中直接使用 Node.js 能力。
|
|
147
|
+
|
|
148
|
+
### 配置方式
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"preload": "preload.js"
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### preload.js 示例
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
// preload.js - 遵循 CommonJS 规范
|
|
160
|
+
const fs = require('fs')
|
|
161
|
+
const os = require('os')
|
|
162
|
+
const path = require('path')
|
|
163
|
+
|
|
164
|
+
// 通过 window 暴露给前端
|
|
165
|
+
window.myApi = {
|
|
166
|
+
getHomeDir: () => os.homedir(),
|
|
167
|
+
readFile: (filePath) => fs.readFileSync(filePath, 'utf-8'),
|
|
168
|
+
platform: process.platform
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 前端调用
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
// 在 UI 组件中使用
|
|
176
|
+
const homeDir = window.myApi?.getHomeDir()
|
|
177
|
+
const content = window.myApi?.readFile('/path/to/file.txt')
|
|
178
|
+
|
|
179
|
+
// 核心 API 仍然可用
|
|
180
|
+
const text = await window.intools.clipboard.readText()
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 注意事项
|
|
184
|
+
|
|
185
|
+
| 项目 | 说明 |
|
|
186
|
+
|------|------|
|
|
187
|
+
| 文件格式 | CommonJS 格式,使用 `require()` 导入模块 |
|
|
188
|
+
| 代码规范 | 必须是清晰可读的源码,**不能压缩/混淆** |
|
|
189
|
+
| 可用模块 | Node.js 原生模块 + 第三方 npm 模块 |
|
|
190
|
+
| API 暴露 | 通过 `window.xxx` 暴露自定义 API |
|
|
191
|
+
| 核心 API | `window.intools` 核心 API 仍然可用 |
|
|
192
|
+
| 安全性 | 有完整 Node.js 权限,需注意安全风险 |
|
|
193
|
+
| 打包 | 运行 `intools pack` 会自动包含 preload 文件 |
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
# 第二部分:API 参考
|
|
198
|
+
|
|
9
199
|
## 1. 剪贴板 (clipboard)
|
|
10
200
|
|
|
11
201
|
| 方法 | 环境 | 说明 |
|
|
@@ -233,8 +423,35 @@
|
|
|
233
423
|
| `setFeature(feature)` | B | 注册动态指令 |
|
|
234
424
|
| `removeFeature(code)` | B | 删除动态指令 |
|
|
235
425
|
|
|
236
|
-
**DynamicFeatureInput**:
|
|
237
|
-
|
|
426
|
+
**DynamicFeatureInput**:
|
|
427
|
+
- `code` - 指令代码
|
|
428
|
+
- `explain` - 说明文字
|
|
429
|
+
- `icon` - 图标(路径/SVG/URL)
|
|
430
|
+
- `platform` - 平台限制
|
|
431
|
+
- `mode` - 模式:`'ui' | 'silent' | 'detached'`
|
|
432
|
+
- `route` - 路由路径
|
|
433
|
+
- `mainHide` - 触发时隐藏主窗口
|
|
434
|
+
- `mainPush` - 向搜索框推送内容
|
|
435
|
+
- `cmds` - 命令数组
|
|
436
|
+
|
|
437
|
+
### cmds 命令类型
|
|
438
|
+
|
|
439
|
+
| 类型 | 字段 | 说明 |
|
|
440
|
+
|------|------|------|
|
|
441
|
+
| `keyword` | `value` | 关键词匹配 |
|
|
442
|
+
| `regex` | `match`, `explain?`, `label?`, `minLength?`, `maxLength?` | 正则匹配 |
|
|
443
|
+
| `files` | `exts?`, `fileType?`, `match?`, `minLength?`, `maxLength?` | 文件匹配 |
|
|
444
|
+
| `img` | `exts?` | 图片匹配 |
|
|
445
|
+
| `over` | `label?`, `exclude?`, `minLength?`, `maxLength?` | 覆盖匹配 |
|
|
446
|
+
|
|
447
|
+
**files 特殊字段**:
|
|
448
|
+
- `fileType`: `'file' | 'directory' | 'any'` - 文件类型过滤 (默认 'any')
|
|
449
|
+
- `match`: 匹配文件名的正则表达式 (与 `exts` 二选一)
|
|
450
|
+
- `minLength` / `maxLength`: 文件数量限制
|
|
451
|
+
|
|
452
|
+
**regex / over 特殊字段**:
|
|
453
|
+
- `minLength` / `maxLength`: 输入文本长度限制 (over 默认为 10000)
|
|
454
|
+
- `exclude`: 排除的正则表达式(仅 over)
|
|
238
455
|
|
|
239
456
|
---
|
|
240
457
|
|
package/README.md
CHANGED
|
@@ -183,11 +183,20 @@ my-plugin/
|
|
|
183
183
|
"id": "my-plugin",
|
|
184
184
|
"name": "my-plugin",
|
|
185
185
|
"version": "1.0.0",
|
|
186
|
+
"type": "utility",
|
|
186
187
|
"displayName": "我的插件",
|
|
187
188
|
"description": "插件功能描述",
|
|
188
189
|
"main": "dist/main.js",
|
|
189
190
|
"ui": "ui/index.html",
|
|
190
191
|
"icon": "icon.png",
|
|
192
|
+
"pluginSetting": {
|
|
193
|
+
"single": true,
|
|
194
|
+
"height": 400
|
|
195
|
+
},
|
|
196
|
+
"window": {
|
|
197
|
+
"width": 800,
|
|
198
|
+
"height": 600
|
|
199
|
+
},
|
|
191
200
|
"features": [
|
|
192
201
|
{
|
|
193
202
|
"code": "main",
|
|
@@ -206,6 +215,7 @@ my-plugin/
|
|
|
206
215
|
|------|------|------|------|
|
|
207
216
|
| `name` | string | ✅ | 插件唯一标识(小写字母、数字、连字符) |
|
|
208
217
|
| `version` | string | ✅ | 语义化版本 (x.y.z) |
|
|
218
|
+
| `type` | string | ❌ | 插件类型 (utility/productivity/developer/system/media/network/ai/entertainment/other) |
|
|
209
219
|
| `displayName` | string | ✅ | 用户看到的名称 |
|
|
210
220
|
| `description` | string | ✅ | 功能描述 |
|
|
211
221
|
| `id` | string | ✅ | 插件唯一 ID(推荐,优先于 name) |
|
|
@@ -213,6 +223,8 @@ my-plugin/
|
|
|
213
223
|
| `ui` | string | ❌ | UI 文件路径(有界面时必填) |
|
|
214
224
|
| `icon` | string/object | ❌ | 插件图标 |
|
|
215
225
|
| `features` | array | ✅ | 功能入口列表 |
|
|
226
|
+
| `pluginSetting` | object | ❌ | 插件行为设置 (`single`, `height`) |
|
|
227
|
+
| `window` | object | ❌ | 独立窗口配置 (`width`, `height`, `minWidth`, etc.) |
|
|
216
228
|
| `author` | string | ❌ | 作者名 |
|
|
217
229
|
| `homepage` | string | ❌ | 项目主页 |
|
|
218
230
|
| `minAppVersion` | string | ❌ | 最低 InTools 版本要求 |
|
|
@@ -251,16 +263,20 @@ my-plugin/
|
|
|
251
263
|
| `cmds` | array | ✅ | 触发命令列表 |
|
|
252
264
|
| `mode` | string | ❌ | `ui` / `silent` / `detached` |
|
|
253
265
|
| `route` | string | ❌ | UI 路由(用于子窗口或页内路由) |
|
|
266
|
+
| `icon` | string/object | ❌ | 功能独立图标 |
|
|
267
|
+
| `mainHide` | boolean | ❌ | 触发时隐藏主窗口 |
|
|
268
|
+
| `mainPush` | boolean | ❌ | 向搜索框推送内容 |
|
|
269
|
+
|
|
254
270
|
|
|
255
271
|
#### 触发命令类型 (cmds)
|
|
256
272
|
|
|
257
|
-
| type | 说明 |
|
|
273
|
+
| type | 说明 | 可用字段 |
|
|
258
274
|
|------|------|----------|
|
|
259
275
|
| `keyword` | 关键词触发 | `value`: 关键词 |
|
|
260
|
-
| `regex` | 正则匹配 | `match`: 正则表达式, `explain`:
|
|
261
|
-
| `files` |
|
|
262
|
-
| `img` |
|
|
263
|
-
| `over` | 选中文本 |
|
|
276
|
+
| `regex` | 正则匹配 | `match`: 正则表达式, `explain`: 说明, `label?`: 指令名称, `minLength?`, `maxLength?` |
|
|
277
|
+
| `files` | 文件拖入 | `exts?`, `fileType?` (file/directory/any), `match?` (文件名正则), `minLength?`, `maxLength?` |
|
|
278
|
+
| `img` | 图片拖入 | `exts?` |
|
|
279
|
+
| `over` | 选中文本 | `label?` (指令名称), `exclude?` (排除正则), `minLength?`, `maxLength?` |
|
|
264
280
|
|
|
265
281
|
#### 图标配置
|
|
266
282
|
|
|
@@ -275,6 +291,10 @@ my-plugin/
|
|
|
275
291
|
|
|
276
292
|
// 3. 内联 SVG
|
|
277
293
|
"icon": "<svg viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"...\"/></svg>"
|
|
294
|
+
|
|
295
|
+
// 4. 对象形式(支持更多类型)
|
|
296
|
+
"icon": { "type": "file", "value": "assets/logo.png" }
|
|
297
|
+
"icon": { "type": "url", "value": "https://example.com/icon.png" }
|
|
278
298
|
```
|
|
279
299
|
|
|
280
300
|
> 💡 **提示:** 未设置 `icon` 时,会自动尝试加载插件目录下的 `icon.png`
|
|
@@ -368,9 +388,42 @@ npm run build
|
|
|
368
388
|
插件在沙箱中运行,通过 `context.api` 访问各种 API。
|
|
369
389
|
|
|
370
390
|
> 📚 **完整 API 参考请查看 [`PLUGIN_API.md`](./PLUGIN_API.md)**
|
|
371
|
-
>
|
|
391
|
+
>
|
|
372
392
|
> 该文件会在创建插件时自动生成,包含全部 28 个 API 模块的详细说明。
|
|
373
393
|
|
|
394
|
+
#### 可用 API 模块
|
|
395
|
+
|
|
396
|
+
| 模块 | 说明 | 常用方法 |
|
|
397
|
+
|------|------|----------|
|
|
398
|
+
| `clipboard` | 剪贴板 | `readText`, `writeText`, `readImage` |
|
|
399
|
+
| `filesystem` | 文件系统 | `readFile`, `writeFile`, `readdir` |
|
|
400
|
+
| `storage` | 数据存储 | `get`, `set`, `remove` |
|
|
401
|
+
| `dialog` | 系统对话框 | `showOpenDialog`, `showMessageBox` |
|
|
402
|
+
| `notification` | 通知 | `show` |
|
|
403
|
+
| `shell` | 系统外壳 | `openExternal`, `showItemInFolder` |
|
|
404
|
+
| `http` | 网络请求 | `get`, `post`, `request` |
|
|
405
|
+
| `system` | 系统信息 | `getSystemInfo`, `getPath` |
|
|
406
|
+
| `screen` | 屏幕控制 | `capture`, `colorPick`, `getAllDisplays` |
|
|
407
|
+
| `input` | 模拟输入 | `simulateKeyboardTap`, `hideMainWindowPasteText` |
|
|
408
|
+
| `window` | 窗口控制 | `hide`, `setSize`, `create` |
|
|
409
|
+
| `theme` | 主题 | `get`, `set` |
|
|
410
|
+
| `plugin` | 插件管理 | `run`, `redirect`, `outPlugin` |
|
|
411
|
+
| `features` | 动态功能 | `setFeature`, `removeFeature` |
|
|
412
|
+
| `shortcut` | 全局快捷键 | `register`, `unregister` |
|
|
413
|
+
| `permission` | 权限管理 | `request`, `getStatus` |
|
|
414
|
+
| `security` | 安全 | `encryptString`, `decryptString` |
|
|
415
|
+
| `tray` | 系统托盘 | `create`, `setIcon` |
|
|
416
|
+
| `menu` | 上下文菜单 | `showContextMenu` |
|
|
417
|
+
| `network` | 网络状态 | `isOnline` |
|
|
418
|
+
| `power` | 电源监控 | `getSystemIdleTime`, `onAC` |
|
|
419
|
+
| `media` | 媒体权限 | `hasCameraAccess` |
|
|
420
|
+
| `geolocation` | 地理位置 | `getCurrentPosition` |
|
|
421
|
+
| `tts` | 语音合成 | `speak` |
|
|
422
|
+
| `host` | 主机控制 | `invoke` |
|
|
423
|
+
| `sharp` | 图像处理 | `resize`, `toBuffer` |
|
|
424
|
+
| `ffmpeg` | 音视频处理 | `run`, `download` |
|
|
425
|
+
| `inbrowser` | 浏览器自动化 | `goto`, `click`, `evaluate` |
|
|
426
|
+
|
|
374
427
|
#### 常用 API 快速示例
|
|
375
428
|
|
|
376
429
|
```typescript
|
|
@@ -380,7 +433,6 @@ await clipboard.writeText('Hello')
|
|
|
380
433
|
|
|
381
434
|
// 通知
|
|
382
435
|
notification.show('操作成功')
|
|
383
|
-
notification.show('发生错误', 'error')
|
|
384
436
|
|
|
385
437
|
// 存储
|
|
386
438
|
await storage.set('key', { data: 'value' })
|
|
@@ -388,13 +440,17 @@ const data = await storage.get('key')
|
|
|
388
440
|
|
|
389
441
|
// 文件系统
|
|
390
442
|
const content = filesystem.readFile('/path/file.txt', 'utf-8')
|
|
391
|
-
filesystem.writeFile('/path/output.txt', 'content', 'utf-8')
|
|
392
443
|
|
|
393
444
|
// HTTP 请求
|
|
394
445
|
const response = await http.post('https://api.example.com', { key: 'value' })
|
|
395
446
|
|
|
396
|
-
//
|
|
397
|
-
const
|
|
447
|
+
// 屏幕取色
|
|
448
|
+
const color = await screen.colorPick()
|
|
449
|
+
|
|
450
|
+
// 浏览器自动化
|
|
451
|
+
await inbrowser.goto('https://google.com')
|
|
452
|
+
await inbrowser.type('input[name="q"]', 'intools')
|
|
453
|
+
await inbrowser.click('input[name="btnK"]')
|
|
398
454
|
```
|
|
399
455
|
|
|
400
456
|
---
|
|
@@ -122,7 +122,14 @@ function buildBackendMain(name) {
|
|
|
122
122
|
route?: string
|
|
123
123
|
mainHide?: boolean
|
|
124
124
|
mainPush?: boolean
|
|
125
|
-
cmds: Array<
|
|
125
|
+
cmds: Array<
|
|
126
|
+
| string
|
|
127
|
+
| { type: 'keyword'; value: string; explain?: string }
|
|
128
|
+
| { type: 'regex'; match: string; explain?: string; label?: string; minLength?: number; maxLength?: number }
|
|
129
|
+
| { type: 'files'; exts?: string[]; fileType?: 'file' | 'directory' | 'any'; match?: string; minLength?: number; maxLength?: number }
|
|
130
|
+
| { type: 'img'; exts?: string[] }
|
|
131
|
+
| { type: 'over'; label?: string; exclude?: string; minLength?: number; maxLength?: number }
|
|
132
|
+
>
|
|
126
133
|
}) => void
|
|
127
134
|
removeFeature: (code: string) => boolean
|
|
128
135
|
redirectHotKeySetting: (cmdLabel: string, autocopy?: boolean) => void
|
package/dist/commands/pack.js
CHANGED
|
@@ -81,6 +81,17 @@ async function createArchive(cwd, outputPath, manifest) {
|
|
|
81
81
|
if (fs.existsSync(uiDir)) {
|
|
82
82
|
archive.directory(uiDir, 'ui');
|
|
83
83
|
}
|
|
84
|
+
// 添加 preload 脚本(如果在 manifest 中配置了)
|
|
85
|
+
if (manifest.preload) {
|
|
86
|
+
const preloadPath = path.join(cwd, manifest.preload);
|
|
87
|
+
if (fs.existsSync(preloadPath)) {
|
|
88
|
+
archive.file(preloadPath, { name: manifest.preload });
|
|
89
|
+
console.log(chalk_1.default.gray(` + ${manifest.preload}`));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.log(chalk_1.default.yellow(`警告: preload 文件不存在: ${manifest.preload}`));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
84
95
|
// 添加 README.md(如果存在)
|
|
85
96
|
const readmePath = path.join(cwd, 'README.md');
|
|
86
97
|
if (fs.existsSync(readmePath)) {
|