mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
framework: server.registerRenderer
This commit is contained in:
6 files changed
+24
-11
No files matched your search
@@ -802,7 +802,6 @@ export interface ModuleInterfaces {
|
||||
callback: (this: Handler, args: Record<string, any>) => Promise<OAuthUserResponse>;
|
||||
};
|
||||
hash: (password: string, salt: string, user: User) => boolean | string | Promise<string>;
|
||||
render: (name: string, state: any) => string | Promise<string>;
|
||||
}
|
||||
|
||||
export interface HydroGlobal {
|
||||
|
||||
@@ -78,6 +78,12 @@ export class Handler extends HandlerOriginal {
|
||||
constructor(_, ctx: Context) {
|
||||
super(_, ctx);
|
||||
this.ctx = ctx.extend({ domain: this.domain });
|
||||
this.renderHTML = ((orig) => function (name: string, args: Record<string, any>) {
|
||||
const s = name.split('.');
|
||||
let templateName = `${s[0]}.${args.domainId}.${s[1]}`;
|
||||
if (!global.Hydro.ui.template[templateName]) templateName = name;
|
||||
return orig(templateName, args);
|
||||
})(this.renderHTML).bind(this);
|
||||
}
|
||||
|
||||
async onerror(error: HydroError) {
|
||||
|
||||
Reference in new issue
Block a user