mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
core: hot reload for ui modules
This commit is contained in:
1 parent
26364a717c
commit
d9a28d9152
5 files changed
+43
-34
No files matched your search
@@ -32,18 +32,6 @@ export function addon(addonPath: string, prepend = false) {
|
||||
const name = payload.name.startsWith('@hydrooj/') ? payload.name.split('@hydrooj/')[1] : payload.name;
|
||||
global.Hydro.version[name] = payload.version;
|
||||
const modulePath = path.dirname(packagejson);
|
||||
const publicPath = path.resolve(modulePath, 'public');
|
||||
if (fs.existsSync(publicPath)) {
|
||||
global.publicDirs[prepend ? 'push' : 'unshift'](publicPath);
|
||||
const targets = fs.readdirSync(publicPath);
|
||||
for (const target of targets) {
|
||||
if (global.Hydro.ui.manifest[target] && !prepend) {
|
||||
global.Hydro.ui.manifest[target] = publicPath;
|
||||
} else if (!global.Hydro.ui.manifest[target]) {
|
||||
global.Hydro.ui.manifest[target] = publicPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
global.addons[prepend ? 'unshift' : 'push'](modulePath);
|
||||
} catch (e) {
|
||||
logger.error(`Addon not found: ${addonPath}`);
|
||||
|
||||
Reference in new issue
Block a user