mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: allow navigation sorting (#548)
This commit is contained in:
1 parent
335e8d6ee9
commit
39919a3214
1 file changed
+5
-1
@@ -32,7 +32,11 @@ export const nodes = new Proxy({}, {
|
||||
});
|
||||
export function inject(node: UIInjectableFields, name: string, args: Record<string, any> = {}, ...permPrivChecker: PermPrivChecker) {
|
||||
const obj = { name, args: args || {}, checker: buildChecker(...permPrivChecker) };
|
||||
nodes[node].push(obj);
|
||||
const idx = obj.args.before ? nodes[node].findIndex((i) => i.name === obj.args.before) : -1;
|
||||
if (idx !== -1) {
|
||||
if (obj.name in nodes[node]) nodes[node] = nodes[node].filter((i) => i.name !== obj.name);
|
||||
nodes[node].splice(idx, 0, obj);
|
||||
} else nodes[node].push(obj);
|
||||
return () => { nodes[node] = nodes[node].filter((i) => i !== obj); };
|
||||
}
|
||||
export function getNodes(name: UIInjectableFields) {
|
||||
|
||||
Reference in new issue
Block a user