fixed: swagger-ui address redirect to 404.

pull/389/head
ruibaby 2019-11-18 11:45:42 +08:00
parent 381341a18b
commit 020fe50be9
3 changed files with 13 additions and 21 deletions

View File

@ -92,7 +92,7 @@ public class WebMvcAutoConfiguration implements WebMvcConfigurer {
.addResourceLocations(workDir + "upload/"); .addResourceLocations(workDir + "upload/");
registry.addResourceHandler(haloProperties.getBackupUrlPrefix() + "/**") registry.addResourceHandler(haloProperties.getBackupUrlPrefix() + "/**")
.addResourceLocations(workDir + "backup/", backupDir); .addResourceLocations(workDir + "backup/", backupDir);
registry.addResourceHandler(haloProperties.getAdminPath() + "/**") registry.addResourceHandler("/halo" + haloProperties.getAdminPath() + "/**")
.addResourceLocations(workDir + HALO_ADMIN_RELATIVE_PATH) .addResourceLocations(workDir + HALO_ADMIN_RELATIVE_PATH)
.addResourceLocations("classpath:/admin/"); .addResourceLocations("classpath:/admin/");

View File

@ -37,22 +37,21 @@ public class MainController {
this.haloProperties = haloProperties; this.haloProperties = haloProperties;
} }
@GetMapping("/{permlink}") @GetMapping("/halo/{permlink}")
@Deprecated @Deprecated
public String admin(@PathVariable(name = "permlink") String permlink) { public String admin(@PathVariable(name = "permlink") String permlink) {
// ###WARNING!!! Here will lead to redirect to swagger-ui/index.html while accessing swagger-ui.html return "redirect:/halo/" + permlink + "/index.html";
return "redirect:/" + permlink + "/index.html"; }
@GetMapping("/halo/version")
@ResponseBody
public String version() {
return HaloConst.HALO_VERSION;
} }
@GetMapping("/install") @GetMapping("/install")
public String installation() { public String installation() {
return "redirect:" + haloProperties.getAdminPath() + "/index.html#install"; return "redirect:/halo" + haloProperties.getAdminPath() + "/index.html#install";
}
@GetMapping("/version")
@ResponseBody
public String version() {
return HaloConst.HALO_VERSION;
} }
@GetMapping("/avatar") @GetMapping("/avatar")

View File

@ -44,7 +44,6 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
@Override @Override
public void onApplicationEvent(ApplicationStartedEvent event) { public void onApplicationEvent(ApplicationStartedEvent event) {
// save halo version to database
this.printStartInfo(); this.printStartInfo();
this.initThemes(); this.initThemes();
} }
@ -53,7 +52,7 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
String blogUrl = optionService.getBlogBaseUrl(); String blogUrl = optionService.getBlogBaseUrl();
log.info("Halo started at {}", blogUrl); log.info("Halo started at {}", blogUrl);
log.info("Halo admin started at {}{}", blogUrl, haloProperties.getAdminPath()); log.info("Halo admin started at {}/halo{}", blogUrl, haloProperties.getAdminPath());
if (!haloProperties.isDocDisabled()) { if (!haloProperties.isDocDisabled()) {
log.debug("Halo doc was enable at {}/swagger-ui.html", blogUrl); log.debug("Halo doc was enable at {}/swagger-ui.html", blogUrl);
} }
@ -65,12 +64,6 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
private void initThemes() { private void initThemes() {
// Whether the blog has initialized // Whether the blog has initialized
Boolean isInstalled = optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false); Boolean isInstalled = optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false);
/*if (haloProperties.isProductionEnv() && isInstalled) {
// Skip
return;
}*/
try { try {
String themeClassPath = ResourceUtils.CLASSPATH_URL_PREFIX + ThemeService.THEME_FOLDER; String themeClassPath = ResourceUtils.CLASSPATH_URL_PREFIX + ThemeService.THEME_FOLDER;
@ -94,9 +87,9 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
// Fix the problem that the project cannot start after moving to a new server // Fix the problem that the project cannot start after moving to a new server
if (!haloProperties.isProductionEnv() || Files.notExists(themePath) || !isInstalled) { if (!haloProperties.isProductionEnv() || Files.notExists(themePath) || !isInstalled) {
FileUtils.copyFolder(source, themePath); FileUtils.copyFolder(source, themePath);
log.info("Copied theme folder from [{}] to [{}]", source, themePath); log.debug("Copied theme folder from [{}] to [{}]", source, themePath);
} else { } else {
log.info("Skipped copying theme folder due to existence of theme folder"); log.debug("Skipped copying theme folder due to existence of theme folder");
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Initialize internal theme to user path error", e); throw new RuntimeException("Initialize internal theme to user path error", e);