@peninsula-med/beisen-ehr-plugin 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.
- package/package.json +6 -2
- package/scripts/configure.js +162 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peninsula-med/beisen-ehr-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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
|
+
});
|