liufumingren 11ebb33966 feat(extension): 插件配置集中管理 + 桌面端策略安装 + 跨网下载修复
- 后端:sys_config 存插件配置(识别前缀/生效站点/模板),平台管理员 GET/PUT /api/web/admin/extension;
  插件读取 GET /api/web/extension/config(Redis 缓存 1 小时,保存即失效)
- 前端:平台管理 → 插件配置页(只维护前缀,单号正则由服务端生成)
- 插件:改为只拉取执行(每 5 分钟 + 手动同步),移除规则编辑/试跑/导入导出;安装包地址自动取最新发布
- 桌面端:工具 → 安装/卸载谷歌插件(生成 .reg + reg import 写 HKLM 策略,读注册表验证);
  跨网下载改走云端中转;局域网探测补排障日志;自动更新按包类型取 md5Exe/sizeExe
- 发布:npm run extension:publish(crx + updates.xml)、extension:zip(商店上传包),
  nginx 对 /download/extension/updates.xml 关缓存

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-01 03:16:26 +08:00

35 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const { Controller } = require('egg');
/**
* Chrome 插件读取配置(`GET /api/web/extension/config`)
*
* **公开只读**:插件装在员工浏览器里,没有用户令牌;下发的只有
* 识别前缀 / 生效站点 / 跳转模板 / 安装包地址,不含任何账号或业务数据。
*
* 两道保护:
* - `config.extension.appKey` 非空时要求 `?key=` 一致(env `EXTENSION_APP_KEY`),
* 避免站点清单被随便抓走;不设就完全公开(内网部署的常见做法);
* - 响应 `Cache-Control: no-cache`:配置改了要能马上生效,别被 nginx/浏览器缓存一小时。
*/
class WebExtensionController extends Controller {
/** GET /api/web/extension/config */
async config() {
const { ctx, app } = this;
const expected = (app.config.extension && app.config.extension.appKey) || '';
if (expected && String(ctx.query.key || '') !== expected) {
ctx.throw(403, '插件配置需要正确的 key');
}
const data = await ctx.service.extensionConfig.publicView();
ctx.set('Cache-Control', 'no-cache, max-age=0');
ctx.set('X-Config-Version', String(data.version));
ctx.body = { ok: true, data };
}
}
module.exports = WebExtensionController;