mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: storage: 热重载
This commit is contained in:
1 parent
99ac6e545d
commit
8c8dcb89eb
5 files changed
+24
-12
No files matched your search
@@ -36,9 +36,10 @@ export function getMany(keys: string[]): any[] {
|
||||
return keys.map((key) => cache[key]);
|
||||
}
|
||||
|
||||
export async function set<K extends keyof SystemKeys>(_id: K, value: SystemKeys[K]): Promise<SystemKeys[K]>
|
||||
export async function set<K>(_id: string, value: K): Promise<K>
|
||||
export async function set(_id: string, value: any) {
|
||||
export async function set<K extends keyof SystemKeys>(_id: K, value: SystemKeys[K], boardcast?: boolean): Promise<SystemKeys[K]>
|
||||
export async function set<K>(_id: string, value: K, boardcast?: boolean): Promise<K>
|
||||
export async function set(_id: string, value: any, boardcast = true) {
|
||||
if (boardcast) bus.boardcast('system/setting', { [_id]: value });
|
||||
const res = await coll.findOneAndUpdate(
|
||||
{ _id },
|
||||
{ $set: { value } },
|
||||
@@ -69,6 +70,10 @@ export async function runConfig() {
|
||||
bus.emit('database/config');
|
||||
}
|
||||
|
||||
bus.on('system/setting', (args) => {
|
||||
for (const key in args) set(key, args[key], false);
|
||||
});
|
||||
|
||||
global.Hydro.model.system = {
|
||||
runConfig,
|
||||
get,
|
||||
|
||||
Reference in new issue
Block a user