QLAPI 支持操作环境变量和系统通知

This commit is contained in:
whyour
2025-01-11 01:59:46 +08:00
parent 4667af4ebe
commit 647ed3b66c
18 changed files with 2032 additions and 81 deletions
+8 -9
View File
@@ -159,16 +159,15 @@ export default class OpenService {
value: string;
expiration: number;
}> {
let systemApp = (
await AppModel.findOne({
where: { name: 'system' },
})
)?.get({ plain: true });
const apps = await shareStore.getApps();
const systemApp = apps?.find((x) => x.name === 'system');
if (!systemApp) {
systemApp = await this.create({
name: 'system',
scopes: ['crons', 'system'],
} as App);
throw new Error('system app not found');
}
const now = Math.round(Date.now() / 1000);
const currentToken = systemApp.tokens?.find((x) => x.expiration > now);
if (currentToken) {
return currentToken;
}
const { data } = await this.authToken({
client_id: systemApp.client_id,