Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IEQEFCR
halo
提交
919d7040
H
halo
项目概览
IEQEFCR
/
halo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
halo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
919d7040
编写于
9月 22, 2018
作者:
RYAN0UP
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🐛
bug修复
上级
378acf42
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
5 deletion
+17
-5
src/main/java/cc/ryanc/halo/config/FreeMarkerConfig.java
src/main/java/cc/ryanc/halo/config/FreeMarkerConfig.java
+0
-3
src/main/java/cc/ryanc/halo/config/StartupConfig.java
src/main/java/cc/ryanc/halo/config/StartupConfig.java
+11
-2
src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java
...a/cc/ryanc/halo/web/controller/admin/ThemeController.java
+6
-0
未找到文件。
src/main/java/cc/ryanc/halo/config/FreeMarkerConfig.java
浏览文件 @
919d7040
package
cc.ryanc.halo.config
;
import
cc.ryanc.halo.model.dto.HaloConst
;
import
cc.ryanc.halo.model.enums.BlogPropertiesEnum
;
import
cc.ryanc.halo.model.tag.ArticleTagDirective
;
import
cc.ryanc.halo.model.tag.CommonTagDirective
;
import
cc.ryanc.halo.service.OptionsService
;
...
...
@@ -48,7 +46,6 @@ public class FreeMarkerConfig {
configuration
.
setSharedVariable
(
"articleTag"
,
articleTagDirective
);
configuration
.
setSharedVariable
(
"options"
,
optionsService
.
findAllOptions
());
configuration
.
setSharedVariable
(
"user"
,
userService
.
findUser
());
configuration
.
setSharedVariable
(
"themeName"
,
HaloConst
.
OPTIONS
.
get
(
BlogPropertiesEnum
.
THEME
.
getProp
()));
}
catch
(
TemplateModelException
e
)
{
log
.
error
(
"自定义标签加载失败:{}"
,
e
.
getMessage
());
}
...
...
src/main/java/cc/ryanc/halo/config/StartupConfig.java
浏览文件 @
919d7040
...
...
@@ -7,6 +7,7 @@ import cc.ryanc.halo.service.OptionsService;
import
cc.ryanc.halo.utils.HaloUtils
;
import
cc.ryanc.halo.web.controller.core.BaseController
;
import
cn.hutool.cron.CronUtil
;
import
freemarker.template.TemplateModelException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -33,9 +34,16 @@ public class StartupConfig implements ApplicationListener<ApplicationStartedEven
@Autowired
private
OptionsService
optionsService
;
@Autowired
private
freemarker
.
template
.
Configuration
configuration
;
@Override
public
void
onApplicationEvent
(
ApplicationStartedEvent
event
)
{
this
.
loadActiveTheme
();
try
{
this
.
loadActiveTheme
();
}
catch
(
TemplateModelException
e
)
{
e
.
printStackTrace
();
}
this
.
loadOptions
();
this
.
loadThemes
();
this
.
loadOwo
();
...
...
@@ -47,7 +55,7 @@ public class StartupConfig implements ApplicationListener<ApplicationStartedEven
/**
* 加载主题设置
*/
private
void
loadActiveTheme
()
{
private
void
loadActiveTheme
()
throws
TemplateModelException
{
String
themeValue
=
optionsService
.
findOneOption
(
BlogPropertiesEnum
.
THEME
.
getProp
());
if
(
StringUtils
.
isNotEmpty
(
themeValue
)
&&
!
StringUtils
.
equals
(
themeValue
,
null
))
{
BaseController
.
THEME
=
themeValue
;
...
...
@@ -55,6 +63,7 @@ public class StartupConfig implements ApplicationListener<ApplicationStartedEven
//以防万一
BaseController
.
THEME
=
"anatole"
;
}
configuration
.
setSharedVariable
(
"themeName"
,
BaseController
.
THEME
);
}
/**
...
...
src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java
浏览文件 @
919d7040
...
...
@@ -19,6 +19,7 @@ import cn.hutool.core.io.file.FileWriter;
import
cn.hutool.core.util.RuntimeUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.hutool.extra.servlet.ServletUtil
;
import
freemarker.template.Configuration
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -53,6 +54,9 @@ public class ThemeController extends BaseController {
@Autowired
private
LogsService
logsService
;
@Autowired
private
Configuration
configuration
;
@Autowired
private
LocaleMessageUtil
localeMessageUtil
;
...
...
@@ -92,6 +96,8 @@ public class ThemeController extends BaseController {
BaseController
.
THEME
=
siteTheme
;
HaloConst
.
OPTIONS
.
clear
();
HaloConst
.
OPTIONS
=
optionsService
.
findAllOptions
();
configuration
.
setSharedVariable
(
"themeName"
,
siteTheme
);
configuration
.
setSharedVariable
(
"options"
,
HaloConst
.
OPTIONS
);
log
.
info
(
"已将主题改变为:{}"
,
siteTheme
);
logsService
.
saveByLogs
(
new
Logs
(
LogsRecord
.
CHANGE_THEME
,
"更换为"
+
siteTheme
,
ServletUtil
.
getClientIP
(
request
),
DateUtil
.
date
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录