You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/08-pageInjections.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -556,6 +556,55 @@ new AdminForth({
556
556
557
557
If you hide the logo with `showBrandLogoInSidebar:false`, components injected via `sidebarTop` will take the whole line width.
558
558
559
+
## Injection order
560
+
561
+
Most of injections accept an array of components. By defult the order of components is the same as in the array. You can use standard array methods e.g. `push`, `unshift`, `splice` to put item in desired place.
562
+
563
+
However, if you want to control the order of injections dynamically, which is very handly for plugins, you can use `meta.afOrder` property in the injection instantiation. The higher the number, the earlier the component will be rendered. For example
564
+
565
+
```ts title="/index.ts"
566
+
{
567
+
...
568
+
customization: {
569
+
globalInjections: {
570
+
userMenu: [
571
+
{
572
+
file:'@@/CustomUserMenuItem.vue',
573
+
meta: { afOrder:10 }
574
+
},
575
+
{
576
+
file:'@@/AnotherCustomUserMenuItem.vue',
577
+
meta: { afOrder:20 }
578
+
},
579
+
{
580
+
file:'@@/LastCustomUserMenuItem.vue',
581
+
meta: { afOrder:5 }
582
+
},
583
+
]
584
+
}
585
+
}
586
+
...
587
+
}
588
+
```
589
+
590
+
## Order of components inserted by plugins
591
+
592
+
For plugins, the plugin developers encouraged to use `meta.afOrder` to control the order of injections and allow to pass it from plugin options.
593
+
594
+
For example "OAuth2 plugin", when registers a login button component for login page injection, uses `meta.afOrder` and sets it equal to 'YYY' passed in plugin options:
595
+
596
+
```ts title="/index.ts"
597
+
// plugin CODE
598
+
YYY.push({
599
+
file:'@@/..vue',
600
+
meta: {
601
+
afOrder:this.pluginOptions.YYY||0
602
+
}
603
+
})
604
+
```
605
+
606
+
So you can jsut pass `YYY` option to the plugin to control the order of the injection.
0 commit comments