mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: 优化钩子逻辑
This commit is contained in:
1 parent
03dc8903e2
commit
f2f0212947
27 files changed
+205
-124
No files matched your search
@@ -3,6 +3,7 @@ import moment from 'moment-timezone';
|
||||
import { Dictionary } from 'lodash';
|
||||
import * as builtin from './builtin';
|
||||
import { Setting as _Setting } from '../interface';
|
||||
import * as bus from '../service/bus';
|
||||
|
||||
type SettingDict = Dictionary<_Setting>;
|
||||
|
||||
@@ -139,18 +140,16 @@ SystemSetting(
|
||||
Setting('setting_storage', 'user', null, 1, 'number', 'User Counter', null, FLAG_DISABLED | FLAG_HIDDEN),
|
||||
);
|
||||
|
||||
global.Hydro.postInit.push(
|
||||
async () => {
|
||||
for (const setting of SYSTEM_SETTINGS) {
|
||||
if (setting.value) {
|
||||
const current = await global.Hydro.model.system.get(setting.key);
|
||||
if (current === null || current === '') {
|
||||
await global.Hydro.model.system.set(setting.key, setting.value);
|
||||
}
|
||||
bus.once('app/started', async () => {
|
||||
for (const setting of SYSTEM_SETTINGS) {
|
||||
if (setting.value) {
|
||||
const current = await global.Hydro.model.system.get(setting.key);
|
||||
if (current === null || current === '') {
|
||||
await global.Hydro.model.system.set(setting.key, setting.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
global.Hydro.model.setting = {
|
||||
langRange,
|
||||
|
||||
Reference in new issue
Block a user