mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: add provideModule and injectUI API
This commit is contained in:
1 parent
672c553f4c
commit
28f03dbcbd
18 files changed
+211
-97
No files matched your search
@@ -1,9 +1,8 @@
|
||||
import crypto from 'crypto';
|
||||
|
||||
function hash(password: string, salt: string) {
|
||||
return crypto.pbkdf2Sync(password, salt, 100000, 64, 'sha256').toString('hex').substr(0, 64);
|
||||
return crypto.pbkdf2Sync(password, salt, 100000, 64, 'sha256').toString('hex').substring(0, 64);
|
||||
}
|
||||
|
||||
export = hash;
|
||||
|
||||
global.Hydro.lib['hash.hydro'] = hash;
|
||||
global.Hydro.module.hash.hydro = hash;
|
||||
@@ -31,7 +31,9 @@ export const nodes = new Proxy({}, {
|
||||
},
|
||||
});
|
||||
export function inject(node: UIInjectableFields, name: string, args: Record<string, any> = {}, ...permPrivChecker: PermPrivChecker) {
|
||||
nodes[node].push({ name, args: args || {}, checker: buildChecker(...permPrivChecker) });
|
||||
const obj = { name, args: args || {}, checker: buildChecker(...permPrivChecker) };
|
||||
nodes[node].push(obj);
|
||||
return () => { nodes[node] = nodes[node].filter((i) => i !== obj); };
|
||||
}
|
||||
export function getNodes(name: UIInjectableFields) {
|
||||
return nodes[name];
|
||||
@@ -65,5 +67,4 @@ inject('ProblemAdd', 'problem_create', { icon: 'add', text: 'Create Problem' });
|
||||
global.Hydro.ui.inject = inject;
|
||||
global.Hydro.ui.nodes = nodes as any;
|
||||
global.Hydro.ui.getNodes = getNodes;
|
||||
global.Hydro.ui.Nav = Nav;
|
||||
global.Hydro.ui.ProblemAdd = ProblemAdd;
|
||||
Object.assign(global.Hydro.ui, { ProblemAdd, Nav });
|
||||
Reference in new issue
Block a user