feat: 新增多插件 UI 支持及运行日志集中回传功能
本次提交包含多项功能更新: 1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持 2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储 3. 新增插件分类字段支持,用于场景库分组管理 4. 优化 xq0034/0037/0048 等插件的功能及描述 5. 修复控制面响应兼容问题,支持新旧版本数据格式 6. 新增 xq0033 插件的状态存储模块,用于历史记录管理 7. 优化 CRM 登录窗口模式,支持全屏置顶
This commit is contained in:
@@ -28,6 +28,26 @@ async function accountAllowedPlatforms(account) {
|
||||
}
|
||||
}
|
||||
|
||||
// 调中心机获取后台维护的场景分类;控制面不可达返回 null(调用方回退本地 plugin.json)
|
||||
async function accountPluginCategories(account) {
|
||||
if (!config.CONTROLPLANE_URL) return null;
|
||||
try {
|
||||
const r = await cp.request("GET", "/api/plugins", {
|
||||
headers: cp.machineHeaders(),
|
||||
params: { account },
|
||||
timeout: 5,
|
||||
});
|
||||
const map = new Map();
|
||||
for (const p of r.plugins || []) {
|
||||
const cat = String(p.category || "").trim();
|
||||
if (cat) map.set(p.id, cat);
|
||||
}
|
||||
return map;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// /api/meta 聚合响应
|
||||
async function buildMeta(account) {
|
||||
let authExpired = false;
|
||||
@@ -43,16 +63,29 @@ async function buildMeta(account) {
|
||||
authExpired = true;
|
||||
}
|
||||
}
|
||||
const allowedPlats = account ? await accountAllowedPlatforms(account) : null;
|
||||
const platforms = [];
|
||||
for (const [pid, m] of Object.entries(state.PLATFORMS)) {
|
||||
platforms.push({
|
||||
id: pid,
|
||||
label: m.label,
|
||||
online: await platformAuth.isOnline(pid, account), // 按当前账号的会话校验
|
||||
allowed: allowedPlats === null ? true : allowedPlats.has(pid),
|
||||
const [cloudCats, allowedPlats] = account
|
||||
? await Promise.all([
|
||||
plugins.length ? accountPluginCategories(account) : Promise.resolve(null),
|
||||
accountAllowedPlatforms(account),
|
||||
])
|
||||
: [null, null];
|
||||
// 后台分类优先,未配置则保留插件包内 plugin.json 的分类
|
||||
if (cloudCats) {
|
||||
plugins = plugins.map((p) => {
|
||||
const cat = cloudCats.get(p.id);
|
||||
return cat ? { ...p, category: cat } : p;
|
||||
});
|
||||
}
|
||||
// 平台在线态:并行 + 单平台 2.5s 兜底,避免外网校验慢时整屏元数据被拖住
|
||||
// (超时先按未登录展示,后台校验完成后会回填缓存,平台账号页再读即为最新)
|
||||
const platforms = await Promise.all(
|
||||
Object.entries(state.PLATFORMS).map(async ([pid, m]) => ({
|
||||
id: pid,
|
||||
label: m.label,
|
||||
online: await platformAuth.isOnlineQuick(pid, account), // 按当前账号的会话校验
|
||||
allowed: allowedPlats === null ? true : allowedPlats.has(pid),
|
||||
}))
|
||||
);
|
||||
return {
|
||||
appName: "37du 自动化工作台",
|
||||
dingtalkScan: !!config.CONTROLPLANE_URL,
|
||||
|
||||
Reference in New Issue
Block a user