mirror of https://github.com/halo-dev/halo
🍎 新增api可关闭选项
parent
77f1dda005
commit
129106a2ae
|
@ -1,5 +1,6 @@
|
|||
package cc.ryanc.halo.config;
|
||||
|
||||
import cc.ryanc.halo.web.interceptor.ApiInterceptor;
|
||||
import cc.ryanc.halo.web.interceptor.InstallInterceptor;
|
||||
import cc.ryanc.halo.web.interceptor.LoginInterceptor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -30,6 +31,9 @@ public class MvcConfig implements WebMvcConfigurer {
|
|||
@Autowired
|
||||
private InstallInterceptor installInterceptor;
|
||||
|
||||
@Autowired
|
||||
private ApiInterceptor apiInterceptor;
|
||||
|
||||
/**
|
||||
* 注册拦截器
|
||||
*
|
||||
|
@ -48,6 +52,8 @@ public class MvcConfig implements WebMvcConfigurer {
|
|||
.excludePathPatterns("/install")
|
||||
.excludePathPatterns("/install/do")
|
||||
.excludePathPatterns("/static/**");
|
||||
registry.addInterceptor(apiInterceptor)
|
||||
.addPathPatterns("/api/**");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -325,7 +325,7 @@ public class HaloUtils {
|
|||
*
|
||||
* @param hostIp ip
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @param password password
|
||||
* @param savePath 保存路径
|
||||
* @param fileName 文件名
|
||||
* @param databaseName 数据库名
|
||||
|
@ -470,7 +470,7 @@ public class HaloUtils {
|
|||
*
|
||||
* @param smtpHost smtpHost
|
||||
* @param userName 邮件地址
|
||||
* @param password 密码
|
||||
* @param password password
|
||||
*/
|
||||
public static void configMail(String smtpHost, String userName, String password) {
|
||||
Properties properties = OhMyEmail.defaultConfig(false);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package cc.ryanc.halo.web.interceptor;
|
||||
|
||||
import cc.ryanc.halo.model.dto.HaloConst;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author : RYAN0UP
|
||||
* @date : 2018/6/28
|
||||
*/
|
||||
@Component
|
||||
public class ApiInterceptor implements HandlerInterceptor {
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
if (StringUtils.equals("true", HaloConst.OPTIONS.get("api_status"))) {
|
||||
return true;
|
||||
}
|
||||
response.sendRedirect("/404");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ server:
|
|||
port: 8090
|
||||
use-forward-headers: true
|
||||
undertow:
|
||||
io-threads : 2
|
||||
io-threads: 2
|
||||
worker-threads: 36
|
||||
buffer-size: 1024
|
||||
directBuffers: true
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</style>
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
设置
|
||||
博客设置
|
||||
<small></small>
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
|
@ -26,7 +26,7 @@
|
|||
<i class="fa fa-dashboard"></i> 首页</a>
|
||||
</li>
|
||||
<li><a data-pjax="true" href="#">设置</a></li>
|
||||
<li class="active">网站设置</li>
|
||||
<li class="active">博客设置</li>
|
||||
</ol>
|
||||
</section>
|
||||
<!-- tab选项卡 -->
|
||||
|
@ -395,12 +395,66 @@
|
|||
<!-- 附件设置 -->
|
||||
<div class="tab-pane" id="attach">
|
||||
<form method="post" class="form-horizontal" id="attachOptions">
|
||||
<div class="box-body">
|
||||
<p>
|
||||
开发中...<br/>
|
||||
可选图片存储在本地或者七牛云等云...
|
||||
</p>
|
||||
</div>
|
||||
<#--<div class="box-body">-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label class="col-sm-2 control-label">存储位置:</label>-->
|
||||
<#--<div class="col-sm-4">-->
|
||||
<#--<label class="radio-inline">-->
|
||||
<#--<input type="radio" name="attach_loc" value="server" ${((options.attach_loc?default('server'))=='server')?string('checked','')}> 本地服务器-->
|
||||
<#--</label>-->
|
||||
<#--<label class="radio-inline">-->
|
||||
<#--<input type="radio" name="attach_loc" value="upyun" ${((options.attach_loc?if_exists)=='upyun')?string('checked','')}> 又拍云-->
|
||||
<#--</label>-->
|
||||
<#--<label class="radio-inline">-->
|
||||
<#--<input type="radio" name="attach_loc" value="qiniu" ${((options.attach_loc?if_exists)=='qiniu')?string('checked','')}> 七牛云-->
|
||||
<#--</label>-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
|
||||
<#--<!-- 原生设置 –>-->
|
||||
<#--<div class="server-options" style="display: none">-->
|
||||
|
||||
<#--</div>-->
|
||||
|
||||
<#--<!-- 又拍云选项 –>-->
|
||||
<#--<div class="upyun-options" style="display: none">-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssDomain" class="col-sm-2 control-label">域名绑定:</label>-->
|
||||
<#--<div class="col-sm-4">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssDomain" name="upyun_oss_domain" value="${options.upyun_oss_domain?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssBucket" class="col-sm-2 control-label">空间名称:</label>-->
|
||||
<#--<div class="col-sm-4">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssBucket" name="upyun_oss_bucket" value="${options.upyun_oss_bucket?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssOperator" class="col-sm-2 control-label">操作员名称:</label>-->
|
||||
<#--<div class="col-sm-4">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssOperator" name="upyun_oss_operator" value="${options.upyun_oss_operator?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssPwd" class="col-sm-2 control-label">操作员密码:</label>-->
|
||||
<#--<div class="col-sm-4">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssPwd" name="upyun_oss_pwd" value="${options.upyun_oss_pwd?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--<div class="form-group">-->
|
||||
<#--<label for="upyunOssSrc" class="col-sm-2 control-label">文件目录:</label>-->
|
||||
<#--<div class="col-sm-4">-->
|
||||
<#--<input type="text" class="form-control" id="upyunOssSrc" name="upyun_oss_src" value="${options.upyun_oss_src?if_exists}">-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
|
||||
<#--<!-- 七牛云 –>-->
|
||||
<#--<div class="qiniu-options" style="display: none">-->
|
||||
|
||||
<#--</div>-->
|
||||
<#--</div>-->
|
||||
<div class="box-footer">
|
||||
<button type="button" class="btn btn-primary btn-sm " onclick="saveOptions('attachOptions')">保存</button>
|
||||
</div>
|
||||
|
@ -529,6 +583,17 @@
|
|||
<div class="tab-pane" id="other">
|
||||
<form method="post" class="form-horizontal" id="otherOptions">
|
||||
<div class="box-body">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">API服务:</label>
|
||||
<div class="col-sm-4">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="api_status" value="true" ${((options.api_status?if_exists)=='true')?string('checked','')}> 启用
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="api_status" value="false" ${((options.api_status?default('false'))=='false')?string('checked','')}> 禁用
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="statisticsCode" class="col-sm-2 control-label">统计代码:
|
||||
<span data-toggle="tooltip" data-placement="top" title="可以使用cnzz,百度,google等" style="cursor: pointer">
|
||||
|
@ -651,6 +716,27 @@
|
|||
}
|
||||
}
|
||||
|
||||
function checkAttachOption() {
|
||||
var server = $('input:radio[value=server]:checked').val();
|
||||
var upyun = $('input:radio[value=upyun]:checked').val();
|
||||
var qiniu = $('input:radio[value=qiniu]:checked').val();
|
||||
if(server!=null){
|
||||
$('.server-options').show();
|
||||
}else{
|
||||
$('.server-options').hide();
|
||||
}
|
||||
if(upyun!=null){
|
||||
$('.upyun-options').show();
|
||||
}else{
|
||||
$('.upyun-options').hide();
|
||||
}
|
||||
if(qiniu!=null){
|
||||
$('.qiniu-options').show();
|
||||
}else{
|
||||
$('.qiniu-options').hide();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台布局切换
|
||||
*/
|
||||
|
@ -677,6 +763,9 @@
|
|||
$('input[name=comment_system]').click(function () {
|
||||
checkCommentOption();
|
||||
});
|
||||
$('input[name=attach_loc]').click(function () {
|
||||
checkAttachOption();
|
||||
});
|
||||
$('input[name=admin_layout]').click(function () {
|
||||
viewLayout();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue