Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
🐛 fixed #464
Browse files Browse the repository at this point in the history
  • Loading branch information
hellokaton committed Oct 12, 2018
1 parent ce00746 commit 27b9206
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,13 @@ public RestResponse<?> activeTheme(@BodyParam ThemeParam themeParam) {

@SysLog("保存模板")
@PostRoute("template/save")
public RestResponse<?> saveTpl(@Param String fileName, @Param String content) throws IOException {
if (StringKit.isBlank(fileName)) {
public RestResponse<?> saveTpl(@BodyParam TemplateParam templateParam) throws IOException {
if (StringKit.isBlank(templateParam.getFileName())) {
return RestResponse.fail("缺少参数,请重试");
}
String content = templateParam.getContent();
String themePath = Const.CLASSPATH + File.separatorChar + "templates" + File.separatorChar + "themes" + File.separatorChar + Commons.site_theme();
String filePath = themePath + File.separatorChar + fileName;
String filePath = themePath + File.separatorChar + templateParam.getFileName();
if (Files.exists(Paths.get(filePath))) {
byte[] rf_wiki_byte = content.getBytes("UTF-8");
Files.write(Paths.get(filePath), rf_wiki_byte);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/tale/model/params/PageParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import lombok.Data;

/**
* 分页基础参数
*
* @author biezhi
* @date 2018/6/5
*/
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/tale/model/params/TemplateParam.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.tale.model.params;

import lombok.Data;

/**
* 保存模板参数
*
* @author biezhi
* @date 2018/10/12
*/
@Data
public class TemplateParam {

private String fileName;
private String content;

}
2 changes: 1 addition & 1 deletion src/main/resources/templates/admin/tpl_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h3 class="panel-title">编辑模板</h3>
var fileName = $('#tplSelect').val();
if (fileName && fileName != '') {
tale.post({
url: '/admin/template/save',
url: '/admin/api/template/save',
data: {
fileName: fileName,
content: $('#tpl-preview').val()
Expand Down

0 comments on commit 27b9206

Please sign in to comment.