mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
refactoring + fix subPages routePath
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
97068f4c07
commit
ac9adfbbb8
@ -44,13 +44,9 @@ export class LensExtension {
|
|||||||
return this.manifest.description
|
return this.manifest.description
|
||||||
}
|
}
|
||||||
|
|
||||||
getPageUrl(baseUrl = "") {
|
getPageRoute(suffixPathOrUrl = "") {
|
||||||
const validUrlName = this.name.replace("@", "").replace("/", "-");
|
const validUrlName = this.name.replace("@", "").replace("/", "-");
|
||||||
return compile(this.routePrefix)({ name: validUrlName }) + baseUrl;
|
return compile(this.routePrefix)({ name: validUrlName }) + suffixPathOrUrl;
|
||||||
}
|
|
||||||
|
|
||||||
getPageRoute(baseRoute = "") {
|
|
||||||
return this.getPageUrl() + baseRoute;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export class LensMainExtension extends LensExtension {
|
|||||||
|
|
||||||
async navigate(location?: string, frameId?: number) {
|
async navigate(location?: string, frameId?: number) {
|
||||||
const windowManager = WindowManager.getInstance<WindowManager>();
|
const windowManager = WindowManager.getInstance<WindowManager>();
|
||||||
const url = this.getPageUrl(location); // get full path to extension's page
|
const url = this.getPageRoute(location); // get full path to extension's page
|
||||||
await windowManager.navigate(url, frameId);
|
await windowManager.navigate(url, frameId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,6 @@ export class LensRendererExtension extends LensExtension {
|
|||||||
|
|
||||||
async navigate(location?: string) {
|
async navigate(location?: string) {
|
||||||
const { navigate } = await import("../renderer/navigation");
|
const { navigate } = await import("../renderer/navigation");
|
||||||
navigate(this.getPageUrl(location));
|
navigate(this.getPageRoute(location));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,10 +23,10 @@ export interface PageMenuComponents {
|
|||||||
|
|
||||||
export class PageMenuRegistry<T extends PageMenuRegistration> extends BaseRegistry<T> {
|
export class PageMenuRegistry<T extends PageMenuRegistration> extends BaseRegistry<T> {
|
||||||
getItems() {
|
getItems() {
|
||||||
return super.getItems().map(item => {
|
return super.getItems().map(menuItem => ({
|
||||||
item.url = item.extension.getPageUrl(item.url)
|
...menuItem,
|
||||||
return item
|
url: menuItem.extension.getPageRoute(menuItem.url),
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,9 +22,16 @@ export interface PageComponents {
|
|||||||
|
|
||||||
export class PageRegistry<T extends PageRegistration> extends BaseRegistry<T> {
|
export class PageRegistry<T extends PageRegistration> extends BaseRegistry<T> {
|
||||||
getItems() {
|
getItems() {
|
||||||
return super.getItems().map(item => {
|
return super.getItems().map(page => {
|
||||||
item.routePath = item.extension.getPageRoute(item.routePath)
|
const pageRoute = page.extension.getPageRoute(page.routePath);
|
||||||
return item
|
return {
|
||||||
|
...page,
|
||||||
|
routePath: pageRoute,
|
||||||
|
subPages: page?.subPages?.map(subPage => ({
|
||||||
|
...subPage,
|
||||||
|
routePath: pageRoute + subPage.routePath
|
||||||
|
}))
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user