fix: 修复不稳定的更新状态和错误的 preset (#985)

Reviewed-on: daoyoucloud/tachybase#985
This commit is contained in:
sealday 2024-05-15 13:12:55 +08:00
parent b46c9ee827
commit f08c5b6332
18 changed files with 38 additions and 18 deletions

View File

@ -52,6 +52,7 @@
"@tachybase/build": "workspace:*",
"@tachybase/cli": "workspace:*",
"@tachybase/preset-hera-rental": "workspace:*",
"@tachybase/preset-hera-sancongtou": "workspace:*",
"@tachybase/preset-tachybase": "workspace:*",
"@tachybase/test": "workspace:*",
"@types/react": "^18.2.79",

View File

@ -8,7 +8,7 @@
"dependencies": {
"@tachybase/database": "workspace:*",
"@tachybase/preset-hera-rental": "workspace:*",
"@tachybase/preset-sancongtou": "workspace:*",
"@tachybase/preset-hera-sancongtou": "workspace:*",
"@tachybase/preset-tachybase": "workspace:*",
"@tachybase/server": "workspace:*"
},

View File

@ -1,5 +1,5 @@
import { CleanOptions, Collection, SyncOptions } from '@tachybase/database';
import { importModule, isURL } from '@tachybase/utils';
import { Container, importModule, isURL } from '@tachybase/utils';
import { fsExists } from '@tachybase/utils/plugin-symlink';
import execa from 'execa';
import fg from 'fast-glob';
@ -381,6 +381,10 @@ export class PluginManager {
}
async load(options: any = {}) {
// FIXME
Container.reset();
Container.set({ id: 'db', value: this.app.db });
Container.set({ id: 'app', value: this.app });
this.app.setMaintainingMessage('loading plugins...');
const total = this.pluginInstances.size;

View File

@ -32,16 +32,12 @@ export class PluginCoreServer extends Plugin {
async load() {
await this.pluginDepartments.load();
await this.pluginInterception.load();
Container.reset();
try {
Container.set({ id: 'db', value: this.db });
Container.set({ id: 'app', value: this.app });
await Container.get(ConnectionManager).load();
const fontManger = Container.get(FontManager);
const sqlLoader = Container.get(SqlLoader);
await sqlLoader.loadSqlFiles(path.join(__dirname, './sqls'));
await fontManger.loadFonts();
await Container.get(HomePageService).load();
// init web controllers
await Container.get(WebService).load();
this.app.acl.allow('link-manage', 'init', 'public');
@ -52,6 +48,7 @@ export class PluginCoreServer extends Plugin {
}
async install(options?: InstallOptions) {
await this.pluginDepartments.install(options);
await Container.get(HomePageService).install();
}
async afterEnable() {}
async afterDisable() {}

View File

@ -20,7 +20,7 @@ export class ConnectionManager {
async unload() {
for (const client of [this.redisClient, this.redisPubClient, this.redisSubClient]) {
if (client.isOpen) {
await this.redisClient.disconnect();
await client.disconnect();
}
}
}
@ -32,6 +32,9 @@ export class ConnectionManager {
await this.redisClient.connect();
await this.redisPubClient.connect();
await this.redisSubClient.connect();
this.app.on('afterStop', () => {
this.unload();
});
if (isMain()) {
const keysToDelete: any = await this.redisClient.KEYS(`${KEY_ONLINE_USERS}*`);
if (keysToDelete.length > 0) {

View File

@ -10,7 +10,7 @@ export class HomePageService {
@Db()
private db: Database;
async load() {
async install() {
this.app.acl.allow('home_page_presentations', 'list', 'public');
const repo = this.db.getRepository<any>('collections');
if (repo) {

View File

@ -2,11 +2,17 @@ import PresetTachyBase from '@tachybase/preset-tachybase';
import _ from 'lodash';
export class PluginRental extends PresetTachyBase {
#builtInPlugins = ['approval-mobile', 'core', 'rental', 'mobile-client'];
#builtInPlugins = ['approval-mobile', 'core'];
get builtInPlugins() {
return super.builtInPlugins.concat(this.#builtInPlugins);
}
#localPlugins = ['rental>=0.21.0'];
get localPlugins() {
return super.localPlugins.concat(this.#localPlugins);
}
}
export default PresetTachyBase;
export default PluginRental;

View File

@ -1,5 +1,5 @@
{
"name": "@tachybase/preset-sancongtou",
"name": "@tachybase/preset-hera-sancongtou",
"version": "0.21.20",
"license": "Apache-2.0",
"main": "./lib/server/index.js",

View File

@ -1,12 +1,18 @@
import PresetTachyBase from '@tachybase/preset-tachybase';
import _ from 'lodash';
export class PluginRental extends PresetTachyBase {
#builtInPlugins = ['approval-mobile', 'core', 'rental', 'mobile-client', 'sancongtou'];
export class PluginSancongtou extends PresetTachyBase {
#builtInPlugins = ['approval-mobile', 'core'];
get builtInPlugins() {
return super.builtInPlugins.concat(this.#builtInPlugins);
}
#localPlugins = ['sancongtou>=0.21.0'];
get localPlugins() {
return super.localPlugins.concat(this.#localPlugins);
}
}
export default PresetTachyBase;
export default PluginSancongtou;

View File

@ -51,7 +51,10 @@ importers:
version: link:packages/core/cli
'@tachybase/preset-hera-rental':
specifier: workspace:*
version: link:packages/presets/hera-rental
version: link:packages/presets/rental
'@tachybase/preset-hera-sancongtou':
specifier: workspace:*
version: link:packages/presets/sancongtou
'@tachybase/preset-tachybase':
specifier: workspace:*
version: link:packages/presets/base
@ -169,8 +172,8 @@ importers:
version: link:../database
'@tachybase/preset-hera-rental':
specifier: workspace:*
version: link:../../presets/hera-rental
'@tachybase/preset-sancongtou':
version: link:../../presets/rental
'@tachybase/preset-hera-sancongtou':
specifier: workspace:*
version: link:../../presets/sancongtou
'@tachybase/preset-tachybase':
@ -4174,7 +4177,7 @@ importers:
specifier: ^4.17.0
version: 4.17.0
packages/presets/hera-rental:
packages/presets/rental:
dependencies:
'@hera/plugin-approval':
specifier: workspace:*