fix: Theme refresh issue #553 (#554)

pull/556/head
Ryan Wang 2020-02-10 16:20:13 +08:00 committed by GitHub
parent 2327aafc1c
commit 491ff98916
2 changed files with 12 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import run.halo.app.event.options.OptionUpdatedEvent;
import run.halo.app.event.theme.ThemeActivatedEvent;
import run.halo.app.event.theme.ThemeUpdatedEvent;
import run.halo.app.event.user.UserUpdatedEvent;
import run.halo.app.handler.theme.config.support.ThemeProperty;
import run.halo.app.model.properties.OtherProperties;
@ -23,7 +24,8 @@ import run.halo.app.service.UserService;
* Freemarker config aware listener.
*
* @author johnniang
* @date 19-4-20
* @author ryanwang
* @date 2019-04-20
*/
@Slf4j
@Component
@ -68,6 +70,13 @@ public class FreemarkerConfigAwareListener {
loadThemeConfig();
}
@EventListener
public void onThemeUpdatedEvent(ThemeUpdatedEvent event) throws TemplateModelException {
log.debug("Received theme updated event");
loadThemeConfig();
}
@EventListener
public void onUserUpdate(UserUpdatedEvent event) throws TemplateModelException {
log.debug("Received user updated event, user id: [{}]", event.getUserId());

View File

@ -597,6 +597,8 @@ public class ThemeServiceImpl implements ThemeService {
// Coping new theme files to old theme folder.
FileUtils.copyFolder(preparePath, Paths.get(updatingTheme.getThemePath()));
eventPublisher.publishEvent(new ThemeUpdatedEvent(this));
// Gets theme property again.
return getProperty(Paths.get(updatingTheme.getThemePath()));
} catch (IOException e) {