diff --git a/.gitignore b/.gitignore
index e5b99a40485c13f5f234e1a31894db7c553730eb..568c8be9727e920eeca5b013644019971f85f198 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,9 +38,13 @@ build/
/JNotepad/
/src/main/JNotepad.java
/.idea/
+!.idea/codeStyles/
+!.idea/fileTemplates/
+!.idea/encodings.xml
/project.txt
logs/
/ch_language_pack.txt
/en_language_pack.txt
/jnotepadConfig.json
/qodana.yaml
+.mvn/
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000000000000000000000000000000000000..79ee123c2b23e069e35ed634d687e17f731cc702
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/fileTemplates/code/JavaDoc Class.java b/.idea/fileTemplates/code/JavaDoc Class.java
new file mode 100644
index 0000000000000000000000000000000000000000..8c770c86169568f8aaec3fd46acd79eea65db516
--- /dev/null
+++ b/.idea/fileTemplates/code/JavaDoc Class.java
@@ -0,0 +1,7 @@
+#foreach($param in $RECORD_COMPONENTS)
+ * @param $param
+#end
+#foreach($param in $TYPE_PARAMS)
+ * @param <$param>
+#end
+ * @author $USER
diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar
deleted file mode 100644
index c1dd12f17644411d6e840bd5a10c6ecda0175f18..0000000000000000000000000000000000000000
Binary files a/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100644
index 40ca0155f714d58a8b51693db47b5d80821bad4c..0000000000000000000000000000000000000000
--- a/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
-wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
\ No newline at end of file
diff --git a/docs/images/codeTemplate.png b/docs/images/codeTemplate.png
new file mode 100644
index 0000000000000000000000000000000000000000..4ba79dc3ee23133f53ff2709ebb719288d9d806c
Binary files /dev/null and b/docs/images/codeTemplate.png differ
diff --git "a/docs/\344\273\243\347\240\201\350\247\204\350\214\203.md" "b/docs/\344\273\243\347\240\201\350\247\204\350\214\203.md"
new file mode 100644
index 0000000000000000000000000000000000000000..ec665614abfcd96acda3a0ae2c79c3489937b41d
--- /dev/null
+++ "b/docs/\344\273\243\347\240\201\350\247\204\350\214\203.md"
@@ -0,0 +1,247 @@
+# 代码规范
+
+## 1. 排版规则
+
+### 1.1 编码
+
+**规 则:IDE的text file encoding设置为UTF-8。**
+**规 则:IDE中文件的换行符使用Unix格式,不要使用windows格式。**
+
+**补 充:**
+本项目中`.idea/encodings.xml`已定义src、resource目录为UTF-8编码,禁止修改。
+
+### 1.2 页宽
+
+**规 则:编辑器列宽应设置为120**
+**说 明:**
+当一行代码的长度过长时,为了阅读方便,应该换行展示。但因为每个人的字体设置,屏幕大小有所不同,因此需要统一列宽为120。
+**补 充:**
+IDEA默认列宽为120。本项目的.idea/codeStyles目录中应用的即为IDEA默认配置。
+
+### 1.3 换行
+
+**规 则:第二行相对第一行缩进4个空格,从第三行开始,不再缩进,而是与第二行保持同级。**
+**规 则:运算符、方法调用的点符号与下文一起换行。**
+**规 则:在多个参数超长时,逗号后换行。**
+**示 例:**
+
+```java
+//符合规范
+StringBuffer sb=new StringBuffer();
+//超过100个字符的时候,换行缩进4个空格,并且方法钱的点符号一起换行
+ sb.append("wan").append("fang")...
+ .append("shu")...
+ .append("ju")...
+ .append("gu");
+//在逗号后换行
+ method(arg1,arg2,arg3,...argx,
+ argx1)
+```
+
+### 1.4 缩进
+
+**规 则:程序块需要采用缩进风格编写,缩进为4个空格。**
+**说 明:** 不同的编辑工具会导致Tab字符的宽度不统一,在编码时应注意其可能造成的问题。
+**补 充:**
+本项目的.idea/codeStyles目录中应用的即为IDEA默认配置。
+
+### 1.5 空行
+
+**规则:独立的程序块与变量声明之间加空行分割**
+**示 例:**
+
+```java
+//不符合规范
+if(log.getLevel()Editor->File and Code Templates,可进行修改。
+⚠️注意:确保schema选择的是project。
+
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/jnotepad/tool/JsonUtil.java b/src/main/java/org/jcnc/jnotepad/tool/JsonUtil.java
index 1119123af1b4f388dcfc1110662f36c8ce475151..59f920e3ab497c13cc45f1e5412b0cc055287102 100644
--- a/src/main/java/org/jcnc/jnotepad/tool/JsonUtil.java
+++ b/src/main/java/org/jcnc/jnotepad/tool/JsonUtil.java
@@ -1,10 +1,15 @@
package org.jcnc.jnotepad.tool;
import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.PrettyPrinter;
+import com.fasterxml.jackson.core.util.DefaultIndenter;
+import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.jcnc.jnotepad.exception.AppException;
+import static com.fasterxml.jackson.core.util.DefaultIndenter.SYS_LF;
+
/**
* jackson解析器的facade类,主要提供objectMapper对象
*
@@ -14,7 +19,16 @@ public class JsonUtil {
private JsonUtil() {
}
- public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
+ public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ static {
+ OBJECT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
+ DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
+ DefaultIndenter di = new DefaultIndenter(" ", SYS_LF);
+ prettyPrinter.indentArraysWith(di);
+ prettyPrinter.indentObjectsWith(di);
+ OBJECT_MAPPER.setDefaultPrettyPrinter(prettyPrinter);
+ }
public static String toJsonString(Object o) {
try {