mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: optimize service worker cache load
This commit is contained in:
8 files changed
+34
-23
No files matched your search
@@ -177,6 +177,7 @@ class SystemConfigHandler extends SystemHandler {
|
||||
let value = this.ctx.setting.configSource;
|
||||
|
||||
const processNode = (node: any, schema: Schema<any, any>, parent?: any, accessKey?: string) => {
|
||||
if (!node) return;
|
||||
if (['union', 'intersect'].includes(schema.type)) {
|
||||
for (const item of schema.list) processNode(node, item, parent, accessKey);
|
||||
}
|
||||
@@ -193,7 +194,9 @@ class SystemConfigHandler extends SystemHandler {
|
||||
const temp = yaml.load(this.ctx.setting.configSource);
|
||||
for (const schema of this.ctx.setting.settings) processNode(temp, schema);
|
||||
value = yaml.dump(temp);
|
||||
} catch (e) { }
|
||||
} catch (e) {
|
||||
logger.error('Failed to process config', e.message);
|
||||
}
|
||||
this.response.body = {
|
||||
schema: Schema.intersect(this.ctx.setting.settings).toJSON(),
|
||||
value,
|
||||
|
||||
@@ -172,12 +172,10 @@ export class SettingService extends Service {
|
||||
});
|
||||
const that = this;
|
||||
const getAccess = (path: (string | symbol)[]) => {
|
||||
if (path.some((p) => SettingService.blacklist.includes(p.toString()))) throw new Error('Invalid path');
|
||||
if (path.some((p) => SettingService.blacklist.includes(p.toString()))) throw new Error(`Invalid path: ${path.join('.')}`);
|
||||
let currentValue = curValue;
|
||||
for (const p of path) {
|
||||
currentValue = currentValue[p];
|
||||
}
|
||||
if (typeof currentValue !== 'object' || !currentValue) return currentValue;
|
||||
for (const p of path) currentValue = currentValue[p];
|
||||
if (typeof currentValue !== 'object' || !currentValue || Array.isArray(currentValue)) return currentValue;
|
||||
return new Proxy(currentValue, {
|
||||
get(self, key: string) {
|
||||
return getAccess(path.concat(key));
|
||||
|
||||
Reference in new issue
Block a user