@iflyrpa/playwright 1.0.15 → 1.1.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.
- package/README.md +77 -1
- package/dist/index.cjs +169 -472
- package/dist/index.d.cts +38 -89
- package/dist/index.d.mts +38 -89
- package/dist/index.d.ts +38 -89
- package/dist/index.mjs +166 -468
- package/package.json +37 -30
package/README.md
CHANGED
|
@@ -2,4 +2,80 @@
|
|
|
2
2
|
|
|
3
3
|
iflyrpa 封装的一组特定场景的自动化脚本,支持的场景如下:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
| 平台 | 脚本 | 说明 | 支持的方式 |
|
|
6
|
+
| ---------------------------- | ---------------------- | -------------------------------------------------- | -------------- |
|
|
7
|
+
| 头条 | toutiaoPublish | 发布/保存草稿 | Mock Api |
|
|
8
|
+
| 头条 | getToutiaoConfig | 获取头条发布配置的话题信息、位置信息和原创首发信息 | Mock Api |
|
|
9
|
+
| 头条 | searchToutiaoTopicList | 搜索头条话题 | Mock Api |
|
|
10
|
+
| 微头条 | weitoutiaoPublish | 发布 | Mock Api / RPA |
|
|
11
|
+
| 百家号 | getBaijiahaoActivity | 查询百家号活动投稿 | Mock Api |
|
|
12
|
+
| 百家号 | baijiahaoPublish | 发布/保存草稿 | Mock Api |
|
|
13
|
+
| 小绿书(微信公众号图文模式) | weixinmpPublish | 发布 | Mock Api / RPA |
|
|
14
|
+
| 小红书 | xiaohongshuPublish | 发布 | Mock Api / RPA |
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# npm
|
|
20
|
+
npm i @iflyrpa/playwright
|
|
21
|
+
|
|
22
|
+
# yarn
|
|
23
|
+
yarn add @iflyrpa/playwright
|
|
24
|
+
|
|
25
|
+
# pnpm
|
|
26
|
+
pnpm install @iflyrpa/playwright
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 使用方法
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { RpaTask } from "@iflyrpa/playwright";
|
|
33
|
+
|
|
34
|
+
// 1. 创建缓存目录
|
|
35
|
+
const cachePath = join(__dirname, "../main/cache");
|
|
36
|
+
|
|
37
|
+
// 2. 初始化
|
|
38
|
+
const automateTask = new RpaTask({
|
|
39
|
+
cachePath, // 缓存目录
|
|
40
|
+
debug: true, // debug 模式下可视化展示所有操作
|
|
41
|
+
forceUpdate: false, // 是否使用远程最新版本
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// 3. 执行脚本,支持的脚本如上
|
|
45
|
+
automateTask.actions.xiaohongshuPublish(xiaohonshuPublishParams)
|
|
46
|
+
|
|
47
|
+
// 4. 应用关闭前,清除副作用
|
|
48
|
+
app.on("before-quit", (event) => {
|
|
49
|
+
if (!automateTask.isClosed) {
|
|
50
|
+
// 阻止应用立即退出
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
|
|
53
|
+
automateTask.close().finally(() => {
|
|
54
|
+
console.log("close app");
|
|
55
|
+
app.quit();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 注意事项
|
|
62
|
+
|
|
63
|
+
**1. 缓存目录包含以下文件:**
|
|
64
|
+
|
|
65
|
+
- packages:运行时依赖和脚本缓存目录
|
|
66
|
+
- tmp:运行时缓存目录
|
|
67
|
+
- rpa.log:运行日志文件
|
|
68
|
+
|
|
69
|
+
**2. 如何获取脚本入参类型:**
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import type { ActionMethodParams } from "@iflyrpa/playwright";
|
|
73
|
+
|
|
74
|
+
export const xiaohonshuPublishParams: ActionMethodParams['xiaohongshuPublish'] = {}
|
|
75
|
+
|
|
76
|
+
automateTask.actions.xiaohongshuPublish(xiaohonshuPublishParams)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**3. 云端日志**
|
|
80
|
+
|
|
81
|
+
<https://sentry-new.iflyrpa.com/rpa/turbodesk-rpa>
|