mirror of https://github.com/halo-dev/halo
Create initTheme method for StartedListener
parent
888c218643
commit
f041dfede4
|
@ -8,6 +8,7 @@ import cc.ryanc.halo.service.OptionService;
|
|||
import cc.ryanc.halo.service.ThemeService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
import cc.ryanc.halo.web.controller.content.base.BaseContentController;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import freemarker.template.TemplateModelException;
|
||||
|
@ -19,6 +20,7 @@ import org.springframework.context.ApplicationListener;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -63,6 +65,7 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
|||
this.cacheOwo();
|
||||
this.getActiveTheme();
|
||||
this.printStartInfo();
|
||||
this.initThemes();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,4 +137,25 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
|||
// TODO Consider to throw an exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Init internal themes
|
||||
*/
|
||||
private void initThemes() {
|
||||
// Whether the blog is initialized
|
||||
String isInstall = optionService.getByKeyOfNullable(BlogProperties.IS_INSTALL.getValue());
|
||||
try {
|
||||
if (null == isInstall) {
|
||||
File internalThemePath = new File(ResourceUtils.getURL("classpath:").getPath(), "templates/themes");
|
||||
File[] internalThemes = internalThemePath.listFiles();
|
||||
if (null != internalThemes) {
|
||||
for (File theme : internalThemes) {
|
||||
FileUtil.copy(theme, themeService.getThemeBasePath(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Init internal theme to user path error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ spring:
|
|||
password: 123456
|
||||
|
||||
#MySql配置
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://127.0.0.1:3306/halodb?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: 123456
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://127.0.0.1:3306/halodb?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: 123456
|
||||
|
||||
h2:
|
||||
console:
|
||||
|
|
|
@ -23,10 +23,10 @@ spring:
|
|||
password: 123456
|
||||
|
||||
#MySql配置
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://127.0.0.1:3306/halodb?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: 123456
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://127.0.0.1:3306/halodb?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: 123456
|
||||
|
||||
h2:
|
||||
console:
|
||||
|
|
Loading…
Reference in New Issue