core&ui: remove Hydro.service.bus, Hydro.ui.template

This commit is contained in:
undefined committed 2025-03-09 16:05:02 +08:00
1 parent a459b9a1fd
commit 1a7b08e56e
8 files changed
+193 -178

No files matched your search

-34
View File
@@ -14,17 +14,6 @@ import { unwrapExports } from '../utils';
const logger = new Logger('common');
async function getFiles(folder: string, base = ''): Promise<string[]> {
const files = [];
const f = await fs.readdir(folder);
for (const i of f) {
if ((await fs.stat(path.join(folder, i))).isDirectory()) {
files.push(...await getFiles(path.join(folder, i), path.join(base, i)));
} else files.push(path.join(base, i));
}
return files.map((item) => item.replace(/\\/gmi, '/'));
}
function locateFile(basePath: string, filenames: string[]) {
for (const i of filenames) {
const p = path.resolve(basePath, i);
@@ -136,26 +125,3 @@ export async function setting(pending: string[], fail: string[], modelSetting: t
}
}
}
export async function template(pending: string[], fail: string[]) {
for (const i of pending) {
const p = locateFile(i, ['template', 'templates']);
if (p && (await fs.stat(p)).isDirectory() && !fail.includes(i)) {
try {
const files = await getFiles(p);
for (const file of files) {
const l = path.resolve(p, file);
if (file.endsWith('.tsx')) global.Hydro.ui.template[file] = require(l);
global.Hydro.ui.template[file] = await fs.readFile(l, 'utf-8');
if (process.env.DEV) global.Hydro.ui.template[`${file}.source`] = l;
}
logger.info('Template init: %s', i);
} catch (e) {
fail.push(i);
app.injectUI('Notification', 'Template load fail: {0}', { args: [i], type: 'warn' }, PRIV.PRIV_VIEW_SYSTEM_NOTIFICATION);
logger.error('Template Load Fail: %s', i);
logger.error(e);
}
}
}
}