[英]How do I change the jhipster default ("/") page?
I created an angular 2 module and routed it successfully to "dashboard."我创建了一个 angular 2 模块并将其成功路由到“仪表板”。 I'd like to replace the default jHipster homepage with my module, but I can't seem to make it work.
我想用我的模块替换默认的 jHipster 主页,但我似乎无法让它工作。 Is there something special about the home route or home component or route that I need to know about to swap them for a different module?
我需要了解主路由或主组件或路由的特殊之处,以便将它们交换为不同的模块?
Parenthetically, I would like to use jHipster as he basis for my angular2/webpack/spring-boot app, but I am having trouble finding documentation on all the bells and whistles.顺便说一句,我想使用 jHipster 作为我的 angular2/webpack/spring-boot 应用程序的基础,但我无法找到有关所有花里胡哨的文档。 A recommendation for a thorough reference (if there is one, wold be appreciated)
一份彻底参考的建议(如果有的话,将不胜感激)
TIA!蒂亚!
It depends on how you want to do it, JHipster generates code and then it's up to you to modify it.这取决于你想怎么做,JHipster 生成代码,然后由你来修改它。
src/main/webapp/app/home
which defines *HomeModule
.src/main/webapp/app/home
下生成的文件,其中定义了*HomeModule
。 Then yo jhipster:upgrade
command will do its best to keep your modifications using git merge when updating JHipster code to newer version.yo jhipster:upgrade
命令将在将 JHipster 代码更新到较新版本时尽量使用 git merge 保留您的修改。*HomeModule
unchanged, add a new one using same component selector and replace its reference to *HomeModule
in src/main/webapp/app/app.module.ts
to your new module.*HomeModule
不变,使用相同的组件选择器添加一个新模块,并将其在src/main/webapp/app/app.module.ts
对*HomeModule
引用替换为您的新模块。Is this what you're asking for?这是你要的吗? How does one modify the JHipster home page?
如何修改 JHipster 主页?
This wasn't "swapped out".这不是“换出”。 I started modifying the JHipster app after generation.
我一代又一代地开始修改 JHipster 应用程序。 Gael has provided good answers but I think you're expecting an Angular lesson.
Gael 提供了很好的答案,但我认为您正在期待 Angular 课程。 The great feature that JHipster provides is a template for your application.
JHipster 提供的强大功能是您的应用程序模板。 It's up to you to modify it.
由您来修改它。
To redirect after login you should change login() in login.component.ts file.要在登录后重定向,您应该更改 login.component.ts 文件中的 login()。 Add
添加
this.router.navigate(['dashboard']);
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;
});
}
I also have question, did you manage to put two entities component on dashboard?我也有问题,您是否设法在仪表板上放置了两个实体组件?
1st Identify the route path by searching for 1st 通过搜索确定路线路径
path: ''小路: ''
You will find it in the app/home/home.route.ts你会在 app/home/home.route.ts 中找到它
add some characters of your choice to the empty string to put the Jhipster home component on a different URI path.将您选择的一些字符添加到空字符串以将 Jhipster 主页组件放在不同的 URI 路径上。
since it is set to an empty string it is what is displayed by default if no URI is specified.因为它被设置为一个空字符串,所以如果没有指定 URI,它就是默认显示的内容。
2nd if you want to set a different component to the default you will need to create a new module ("dashboard.module"), component ("dashboard.component") and route ("dashboard.route") you can use the home component as a code reference. 2nd 如果你想将不同的组件设置为默认值,你需要创建一个新模块(“dashboard.module”)、组件(“dashboard.component”)和路由(“dashboard.route”)你可以使用 home组件作为代码参考。
In the new landing pages route (dashboard.route.ts) set an empty string as the path在新的登陆页面路由(dashboard.route.ts)中设置一个空字符串作为路径
path: ''小路: ''
3rd register the module in the app.module and viola. 3rd 在 app.module 和 viola 中注册模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.