mirror of https://github.com/halo-dev/halo
🎨 修改主题在线更新的逻辑
parent
918f3f5be7
commit
c5af7bfcc8
|
@ -6,6 +6,7 @@ import cc.ryanc.halo.model.dto.JsonResult;
|
||||||
import cc.ryanc.halo.model.dto.LogsRecord;
|
import cc.ryanc.halo.model.dto.LogsRecord;
|
||||||
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
import cc.ryanc.halo.model.enums.BlogPropertiesEnum;
|
||||||
import cc.ryanc.halo.model.enums.ResultCodeEnum;
|
import cc.ryanc.halo.model.enums.ResultCodeEnum;
|
||||||
|
import cc.ryanc.halo.model.enums.TrueFalseEnum;
|
||||||
import cc.ryanc.halo.service.LogsService;
|
import cc.ryanc.halo.service.LogsService;
|
||||||
import cc.ryanc.halo.service.OptionsService;
|
import cc.ryanc.halo.service.OptionsService;
|
||||||
import cc.ryanc.halo.utils.HaloUtils;
|
import cc.ryanc.halo.utils.HaloUtils;
|
||||||
|
@ -224,8 +225,15 @@ public class ThemeController extends BaseController {
|
||||||
* @param theme theme名称
|
* @param theme theme名称
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/options")
|
@GetMapping(value = "/options")
|
||||||
public String setting(Model model, @RequestParam("theme") String theme) {
|
public String setting(Model model,
|
||||||
|
@RequestParam("theme") String theme,
|
||||||
|
@RequestParam("hasUpdate") String hasUpdate) {
|
||||||
model.addAttribute("themeDir", theme);
|
model.addAttribute("themeDir", theme);
|
||||||
|
if (StringUtils.equals(hasUpdate, TrueFalseEnum.TRUE.getDesc())) {
|
||||||
|
model.addAttribute("hasUpdate", true);
|
||||||
|
} else {
|
||||||
|
model.addAttribute("hasUpdate", false);
|
||||||
|
}
|
||||||
return "themes/" + theme + "/module/options";
|
return "themes/" + theme + "/module/options";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,10 +81,7 @@
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<span class="theme-title">${theme.themeName?if_exists?upper_case}</span>
|
<span class="theme-title">${theme.themeName?if_exists?upper_case}</span>
|
||||||
<#if theme.hasOptions>
|
<#if theme.hasOptions>
|
||||||
<button class="btn btn-primary btn-sm pull-right btn-theme-setting" onclick="openSetting('${theme.themeName?if_exists}')" style="display: none">设置</button>
|
<button class="btn btn-primary btn-sm pull-right btn-theme-setting" onclick="openSetting('${theme.themeName?if_exists}','<#if theme.hasUpdate>true<#else>false</#if>')" style="display: none">设置</button>
|
||||||
</#if>
|
|
||||||
<#if theme.hasUpdate>
|
|
||||||
<button class="btn btn-warning btn-sm pull-right btn-theme-update" data-loading-text="更新中..." onclick="updateTheme('${theme.themeName?if_exists}',this)" style="display: none;margin-right: 3px">更新</button>
|
|
||||||
</#if>
|
</#if>
|
||||||
<#if activeTheme != "${theme.themeName}">
|
<#if activeTheme != "${theme.themeName}">
|
||||||
<button class="btn btn-default btn-sm pull-right btn-theme-enable" onclick="setTheme('${theme.themeName?if_exists}')" style="display: none;margin-right: 3px">启用</button>
|
<button class="btn btn-default btn-sm pull-right btn-theme-enable" onclick="setTheme('${theme.themeName?if_exists}')" style="display: none;margin-right: 3px">启用</button>
|
||||||
|
@ -191,61 +188,12 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新主题
|
|
||||||
*/
|
|
||||||
function updateTheme(theme,e) {
|
|
||||||
$(e).button('loading');
|
|
||||||
$.ajax({
|
|
||||||
type: 'get',
|
|
||||||
url: '/admin/themes/pull',
|
|
||||||
data: {
|
|
||||||
'themeName': theme
|
|
||||||
},
|
|
||||||
success: function (data) {
|
|
||||||
if(data.code==1){
|
|
||||||
$.toast({
|
|
||||||
text: data.msg,
|
|
||||||
heading: '提示',
|
|
||||||
icon: 'success',
|
|
||||||
showHideTransition: 'fade',
|
|
||||||
allowToastClose: true,
|
|
||||||
hideAfter: 1000,
|
|
||||||
stack: 1,
|
|
||||||
position: 'top-center',
|
|
||||||
textAlign: 'left',
|
|
||||||
loader: true,
|
|
||||||
loaderBg: '#ffffff',
|
|
||||||
afterHidden: function () {
|
|
||||||
window.location.href="/admin/themes";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
$.toast({
|
|
||||||
text: data.msg,
|
|
||||||
heading: '提示',
|
|
||||||
icon: 'error',
|
|
||||||
showHideTransition: 'fade',
|
|
||||||
allowToastClose: true,
|
|
||||||
hideAfter: 2000,
|
|
||||||
stack: 1,
|
|
||||||
position: 'top-center',
|
|
||||||
textAlign: 'left',
|
|
||||||
loader: true,
|
|
||||||
loaderBg: '#ffffff'
|
|
||||||
});
|
|
||||||
$(e).button('reset');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开主题设置
|
* 打开主题设置
|
||||||
*
|
*
|
||||||
* @param theme 主题名
|
* @param theme 主题名
|
||||||
*/
|
*/
|
||||||
function openSetting(theme) {
|
function openSetting(theme,hasUpdate) {
|
||||||
layer.open({
|
layer.open({
|
||||||
type: 2,
|
type: 2,
|
||||||
title: theme+'主题设置',
|
title: theme+'主题设置',
|
||||||
|
@ -253,7 +201,7 @@
|
||||||
shade: 0.5,
|
shade: 0.5,
|
||||||
maxmin: true,
|
maxmin: true,
|
||||||
area: ['90%', '90%'],
|
area: ['90%', '90%'],
|
||||||
content: '/admin/themes/options?theme='+theme,
|
content: '/admin/themes/options?theme='+theme+'&hasUpdate='+hasUpdate,
|
||||||
scrollbar: false
|
scrollbar: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue