build(desktop): 升级 electron-shell 版本至 1.6.3 并调整插件执行超时配置

- 插件执行超时默认延长至 6 小时,支持插件单独配置超时时间
- 新增插件根目录迁移逻辑,解决旧版权限问题
- 新增多个服务端实体、DTO、配置模块等基础代码
- 新增插件 UI 模板及相关静态资源
This commit is contained in:
2026-10-15 11:38:45 +08:00
parent 872d3dc5c8
commit f0a94bf523
717 changed files with 88647 additions and 17543 deletions
@@ -0,0 +1,85 @@
import { CoolController, BaseController } from '@cool-midway/core';
import { Get, Headers, Inject, Provide, Query } from '@midwayjs/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { PluginEntity, AccountPluginEntity, AccountPlatformEntity } from '../../entity/plugin';
import { CenterAuthService, ApiError } from '../../service/auth';
/**
* 客户端插件清单接口(对齐旧 FastAPI apis/plugins.py /api/plugins、/api/platforms/allowed)
* 身份:优先 Authorization: Bearer <cloud_token>,兜底 account + X-API-Token
*/
@Provide()
@CoolController('/api')
export class ApiPluginsController extends BaseController {
@Inject()
centerAuthService: CenterAuthService;
@InjectEntityModel(PluginEntity)
pluginRepo: Repository<PluginEntity>;
@InjectEntityModel(AccountPluginEntity)
accountPluginRepo: Repository<AccountPluginEntity>;
@InjectEntityModel(AccountPlatformEntity)
accountPlatformRepo: Repository<AccountPlatformEntity>;
/** 解析账号身份;无有效身份抛 400 */
private async resolveAcct(
account: string,
xApiToken: string,
authorization: string
): Promise<string> {
let acct = await this.centerAuthService.cloudAccount(authorization);
if (!acct) {
this.centerAuthService.checkApiToken(xApiToken);
acct = (account || '').trim();
}
if (!acct) throw new ApiError(400, '缺少有效会话或 account');
return acct;
}
/** GET /api/plugins — 按账号返回可用插件清单(权限隔离) */
@Get('/plugins')
async plugins(
@Query('account') account: string = '',
@Headers('X-API-Token') xApiToken: string = '',
@Headers('Authorization') authorization: string = ''
) {
const acct = await this.resolveAcct(account, xApiToken, authorization);
if (await this.centerAuthService.accountDisabled(acct)) {
return { account: acct, plugins: [] };
}
const rows = await this.accountPluginRepo
.createQueryBuilder('ap')
.innerJoin(PluginEntity, 'p', 'p.id = ap.pluginId')
.select(['p.id AS id', 'p.name AS name', 'p.latestVersion AS version'])
.where('ap.account = :account', { account: acct })
.orderBy('p.id', 'ASC')
.getRawMany();
return {
account: acct,
plugins: rows.map(r => ({ id: r.id, name: r.name, version: r.version })),
};
}
/** GET /api/platforms/allowed — 按账号返回可登录平台白名单 */
@Get('/platforms/allowed')
async platformsAllowed(
@Query('account') account: string = '',
@Headers('X-API-Token') xApiToken: string = '',
@Headers('Authorization') authorization: string = ''
) {
const acct = await this.resolveAcct(account, xApiToken, authorization);
if (await this.centerAuthService.accountDisabled(acct)) {
return { account: acct, allowed: [] };
}
const rows = await this.accountPlatformRepo
.createQueryBuilder('ap')
.select('ap.platformId', 'platformId')
.where('ap.account = :account', { account: acct })
.orderBy('ap.platformId', 'ASC')
.getRawMany();
return { account: acct, allowed: rows.map(r => r.platformId) };
}
}