[英]How do I change the jhipster default ("/") page?
我創建了一個 angular 2 模塊並將其成功路由到“儀表板”。 我想用我的模塊替換默認的 jHipster 主頁,但我似乎無法讓它工作。 我需要了解主路由或主組件或路由的特殊之處,以便將它們交換為不同的模塊?
順便說一句,我想使用 jHipster 作為我的 angular2/webpack/spring-boot 應用程序的基礎,但我無法找到有關所有花里胡哨的文檔。 一份徹底參考的建議(如果有的話,將不勝感激)
蒂亞!
這取決於你想怎么做,JHipster 生成代碼,然后由你來修改它。
src/main/webapp/app/home
下生成的文件,其中定義了*HomeModule
。 然后yo jhipster:upgrade
命令將在將 JHipster 代碼更新到較新版本時盡量使用 git merge 保留您的修改。*HomeModule
不變,使用相同的組件選擇器添加一個新模塊,並將其在src/main/webapp/app/app.module.ts
對*HomeModule
引用替換為您的新模塊。要在登錄后重定向,您應該更改 login.component.ts 文件中的 login()。 添加
this.router.navigate(['dashboard']);
login () {
this.loginService.login({
username: this.username,
password: this.password,
rememberMe: this.rememberMe
}).then(() => {
this.authenticationError = false;
this.activeModal.dismiss('login success');
if (this.router.url === '/register' || this.router.url === '/activate' ||
this.router.url === '/finishReset' || this.router.url === '/requestReset') {
this.router.navigate(['']);
}
this.eventManager.broadcast({
name: 'authenticationSuccess',
content: 'Sending Authentication Success'
});
// // previousState was set in the authExpiredInterceptor before being redirected to login modal.
// // since login is succesful, go to stored previousState and clear previousState
let previousState = this.stateStorageService.getPreviousState();
if (previousState) {
this.stateStorageService.resetPreviousState();
this.router.navigate([previousState.name], { queryParams: previousState.params });
}
this.router.navigate(['dashboard']); // <-Add here
}).catch(() => {
this.authenticationError = true;
});
}
我也有問題,您是否設法在儀表板上放置了兩個實體組件?
1st 通過搜索確定路線路徑
小路: ''
你會在 app/home/home.route.ts 中找到它
將您選擇的一些字符添加到空字符串以將 Jhipster 主頁組件放在不同的 URI 路徑上。
因為它被設置為一個空字符串,所以如果沒有指定 URI,它就是默認顯示的內容。
2nd 如果你想將不同的組件設置為默認值,你需要創建一個新模塊(“dashboard.module”)、組件(“dashboard.component”)和路由(“dashboard.route”)你可以使用 home組件作為代碼參考。
在新的登陸頁面路由(dashboard.route.ts)中設置一個空字符串作為路徑
小路: ''
3rd 在 app.module 和 viola 中注冊模塊。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.