@peninsula-med/beisen-ehr-plugin 1.0.0 → 1.0.2

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 CHANGED
@@ -3,28 +3,42 @@
3
3
  北森 EHR 系统的 OpenClaw 插件,支持加班申请、考勤查询、假期余额等功能。
4
4
 
5
5
  > **开发:** 龙二 (Long Er) 🐉
6
- > **版本:** 1.0.0
6
+ > **版本:** 1.0.1
7
7
 
8
8
  ---
9
9
 
10
10
  ## 快速安装
11
11
 
12
+ ### 1️⃣ 安装插件
13
+
14
+ ```bash
15
+ openclaw plugins install @peninsula-med/beisen-ehr-plugin
16
+ ```
17
+
18
+ ### 2️⃣ 配置凭证(3 种方式)
19
+
20
+ **方式 A:使用配置向导(推荐 ⭐)**
21
+
12
22
  ```bash
13
- openclaw plugins install @beisen/beisen-ehr-plugin
23
+ npx @peninsula-med/beisen-ehr-configure
14
24
  ```
15
25
 
16
- 安装后配置:
26
+ 按提示输入北森凭证即可,自动完成配置!
27
+
28
+ **方式 B:运行配置脚本**
17
29
 
18
30
  ```bash
19
- openclaw plugins config beisen-ehr-plugin
31
+ node node_modules/@peninsula-med/beisen-ehr-plugin/scripts/configure.js
20
32
  ```
21
33
 
22
- 或编辑 `~/.openclaw/config.json`:
34
+ **方式 C:手动编辑配置文件**
35
+
36
+ 编辑 `~/.openclaw/config.json`:
23
37
 
24
38
  ```json
25
39
  {
26
40
  "plugins": {
27
- "beisen-ehr-plugin": {
41
+ "@peninsula-med/beisen-ehr-plugin": {
28
42
  "enabled": true,
29
43
  "config": {
30
44
  "apiUrl": "https://openapi.italent.cn",
@@ -39,10 +53,16 @@ openclaw plugins config beisen-ehr-plugin
39
53
  }
40
54
  ```
41
55
 
42
- 重启 OpenClaw
56
+ ### 3️⃣ 重启 OpenClaw
43
57
 
44
58
  ```bash
45
- openclaw gateway restart
59
+ openclaw restart
60
+ ```
61
+
62
+ ### 4️⃣ 测试
63
+
64
+ ```
65
+ 帮我提交一个加班申请
46
66
  ```
47
67
 
48
68
  ---
@@ -108,31 +128,21 @@ openclaw gateway restart
108
128
 
109
129
  ---
110
130
 
111
- ## 开发
112
-
113
- ### 安装依赖
114
-
115
- ```bash
116
- npm install
117
- ```
118
-
119
- ### 开发模式
120
-
121
- ```bash
122
- npm run dev
123
- ```
131
+ ## 配置向导
124
132
 
125
- ### 构建
133
+ 运行配置向导,按提示输入凭证:
126
134
 
127
135
  ```bash
128
- npm run build
136
+ npx @peninsula-med/beisen-ehr-configure
129
137
  ```
130
138
 
131
- ### 发布
132
-
133
- ```bash
134
- npm run publish:release
135
- ```
139
+ 向导会:
140
+ 1. ✅ 提示输入必要凭证
141
+ 2. ✅ 自动验证格式
142
+ 3. 备份现有配置
143
+ 4. ✅ 写入配置文件
144
+ 5. ✅ 显示配置摘要
145
+ 6. ✅ 提供下一步指引
136
146
 
137
147
  ---
138
148
 
@@ -142,13 +152,14 @@ npm run publish:release
142
152
 
143
153
  ```bash
144
154
  openclaw plugins list
145
- openclaw plugins info beisen-ehr-plugin
155
+ openclaw plugins info @peninsula-med/beisen-ehr-plugin
146
156
  ```
147
157
 
148
158
  ### 配置错误
149
159
 
160
+ 重新运行配置向导:
150
161
  ```bash
151
- openclaw plugins config beisen-ehr-plugin
162
+ npx @peninsula-med/beisen-ehr-configure
152
163
  ```
153
164
 
154
165
  ### 查看日志
@@ -157,6 +168,27 @@ openclaw plugins config beisen-ehr-plugin
157
168
  openclaw gateway logs | grep beisen
158
169
  ```
159
170
 
171
+ ### 卸载
172
+
173
+ ```bash
174
+ openclaw plugins uninstall @peninsula-med/beisen-ehr-plugin
175
+ ```
176
+
177
+ ---
178
+
179
+ ## 更新日志
180
+
181
+ ### v1.0.1 (2026-03-11)
182
+ - ✅ 添加配置向导脚本
183
+ - ✅ 支持 npx 一键配置
184
+
185
+ ### v1.0.0 (2026-03-11)
186
+ - ✅ 初始版本
187
+ - ✅ 提交加班申请
188
+ - ✅ 查询考勤记录
189
+ - ✅ 查询审批状态
190
+ - ✅ 查询假期余额
191
+
160
192
  ---
161
193
 
162
194
  ## License
@@ -34,8 +34,7 @@
34
34
  "format": "email",
35
35
  "description": "企业邮箱"
36
36
  }
37
- },
38
- "required": ["appKey", "appSecret", "staffId", "tenantId", "email"]
37
+ }
39
38
  }
40
39
  }
41
40
  ],
@@ -63,7 +62,6 @@
63
62
  "type": "string",
64
63
  "format": "email"
65
64
  }
66
- },
67
- "required": ["appKey", "appSecret", "staffId", "tenantId", "email"]
65
+ }
68
66
  }
69
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peninsula-med/beisen-ehr-plugin",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -15,7 +15,11 @@
15
15
  "dev": "rollup -c -w",
16
16
  "clean": "rm -rf dist",
17
17
  "prebuild": "npm run clean",
18
- "publish:release": "npm run prebuild && npm run build && npm publish --access public"
18
+ "publish:release": "npm run prebuild && npm run build && npm publish --access public",
19
+ "configure": "node scripts/configure.js"
20
+ },
21
+ "bin": {
22
+ "beisen-ehr-configure": "./scripts/configure.js"
19
23
  },
20
24
  "keywords": [
21
25
  "beisen",
@@ -0,0 +1,162 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 北森 EHR Plugin 配置向导
4
+ * 交互式引导用户完成配置
5
+ */
6
+
7
+ import readline from 'readline';
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ import os from 'os';
11
+
12
+ const rl = readline.createInterface({
13
+ input: process.stdin,
14
+ output: process.stdout,
15
+ });
16
+
17
+ function question(prompt) {
18
+ return new Promise((resolve) => {
19
+ rl.question(prompt, (answer) => {
20
+ resolve(answer);
21
+ });
22
+ });
23
+ }
24
+
25
+ function sleep(ms) {
26
+ return new Promise(resolve => setTimeout(resolve, ms));
27
+ }
28
+
29
+ async function main() {
30
+ console.log('');
31
+ console.log('🏢 北森 EHR Plugin 配置向导');
32
+ console.log('='.repeat(50));
33
+ console.log('');
34
+ console.log('这个向导将帮助你配置北森 EHR 插件');
35
+ console.log('');
36
+
37
+ await sleep(500);
38
+
39
+ // 获取配置
40
+ console.log('请从北森管理员获取以下信息:');
41
+ console.log('');
42
+ console.log(' 📋 需要准备的凭证:');
43
+ console.log(' • App Key(应用标识)');
44
+ console.log(' • App Secret(应用密钥)');
45
+ console.log(' • Tenant ID(企业租户 ID)');
46
+ console.log(' • Staff ID(你的员工 ID)');
47
+ console.log(' • 企业邮箱(用于识别员工)');
48
+ console.log('');
49
+
50
+ await sleep(1000);
51
+
52
+ const appKey = await question('请输入 App Key: ');
53
+ const appSecret = await question('请输入 App Secret: ');
54
+ const tenantId = await question('请输入 Tenant ID: ');
55
+ const staffId = await question('请输入 Staff ID: ');
56
+ const email = await question('请输入企业邮箱: ');
57
+
58
+ // 验证输入
59
+ console.log('');
60
+ console.log('🔍 验证配置信息...');
61
+ await sleep(500);
62
+
63
+ const config = {
64
+ apiUrl: 'https://openapi.italent.cn',
65
+ appKey: appKey.trim(),
66
+ appSecret: appSecret.trim(),
67
+ staffId: staffId.trim(),
68
+ tenantId: tenantId.trim(),
69
+ email: email.trim(),
70
+ };
71
+
72
+ // 查找配置文件
73
+ const homeDir = os.homedir();
74
+ const configPath = path.join(homeDir, '.openclaw', 'config.json');
75
+
76
+ console.log('✅ 配置信息验证通过');
77
+ console.log('');
78
+ console.log('📁 配置文件位置:', configPath);
79
+ console.log('');
80
+
81
+ // 读取或创建配置文件
82
+ let openclawConfig = {};
83
+ if (fs.existsSync(configPath)) {
84
+ console.log('📖 读取现有配置...');
85
+ const content = fs.readFileSync(configPath, 'utf-8');
86
+ openclawConfig = JSON.parse(content);
87
+ } else {
88
+ console.log('📝 创建新配置文件...');
89
+ }
90
+
91
+ await sleep(500);
92
+
93
+ // 更新配置
94
+ if (!openclawConfig.plugins) {
95
+ openclawConfig.plugins = {};
96
+ }
97
+
98
+ openclawConfig.plugins['@peninsula-med/beisen-ehr-plugin'] = {
99
+ enabled: true,
100
+ config: config,
101
+ };
102
+
103
+ // 备份旧配置
104
+ if (fs.existsSync(configPath)) {
105
+ const backupPath = configPath + '.bak.' + Date.now();
106
+ fs.copyFileSync(configPath, backupPath);
107
+ console.log('💾 已备份原配置:', backupPath);
108
+ }
109
+
110
+ // 确保目录存在
111
+ const configDir = path.dirname(configPath);
112
+ if (!fs.existsSync(configDir)) {
113
+ fs.mkdirSync(configDir, { recursive: true });
114
+ }
115
+
116
+ // 写入配置
117
+ fs.writeFileSync(configPath, JSON.stringify(openclawConfig, null, 2), 'utf-8');
118
+
119
+ console.log('');
120
+ console.log('✅ 配置已保存!');
121
+ console.log('');
122
+ console.log('📋 配置摘要:');
123
+ console.log(' • API 地址:', config.apiUrl);
124
+ console.log(' • App Key:', config.appKey.substring(0, 8) + '...');
125
+ console.log(' • Staff ID:', config.staffId);
126
+ console.log(' • Tenant ID:', config.tenantId);
127
+ console.log(' • 邮箱:', config.email);
128
+ console.log('');
129
+
130
+ await sleep(500);
131
+
132
+ console.log('🎉 配置完成!');
133
+ console.log('');
134
+ console.log('下一步:');
135
+ console.log(' 1. 重启 OpenClaw:');
136
+ console.log(' openclaw restart');
137
+ console.log('');
138
+ console.log(' 2. 测试插件:');
139
+ console.log(' 在对话中说:"帮我提交一个加班申请"');
140
+ console.log('');
141
+ console.log(' 3. 查看日志(如有问题):');
142
+ console.log(' openclaw gateway logs');
143
+ console.log('');
144
+ console.log('='.repeat(50));
145
+ console.log('');
146
+
147
+ rl.close();
148
+ }
149
+
150
+ main().catch((error) => {
151
+ console.error('');
152
+ console.error('❌ 配置失败:', error.message);
153
+ console.error('');
154
+ console.error('请检查:');
155
+ console.error(' • 是否有权限写入配置文件');
156
+ console.error(' • 配置文件是否是有效的 JSON 格式');
157
+ console.error('');
158
+ console.error('如需帮助,请联系管理员。');
159
+ console.error('');
160
+ rl.close();
161
+ process.exit(1);
162
+ });