Merge branch 'master' of https://gitee.com/jcnc-org/JNotepad
# Conflicts: # src/main/java/org/jcnc/jnotepad/app/config/LoadJnotepadConfig.java # src/main/java/org/jcnc/jnotepad/init/Config.java # src/main/java/org/jcnc/jnotepad/tool/EncodingDetector.java
This commit is contained in:
commit
631c7b82f2
@ -1,12 +1,8 @@
|
|||||||
package org.jcnc.jnotepad.app.config;
|
package org.jcnc.jnotepad.app.config;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
import javafx.scene.input.KeyCombination;
|
import javafx.scene.input.KeyCombination;
|
||||||
import org.jcnc.jnotepad.app.entity.ShortcutKey;
|
import org.jcnc.jnotepad.app.entity.ShortcutKey;
|
||||||
import org.jcnc.jnotepad.exception.AppException;
|
|
||||||
import org.jcnc.jnotepad.tool.LogUtil;
|
import org.jcnc.jnotepad.tool.LogUtil;
|
||||||
import org.jcnc.jnotepad.tool.PopUpUtil;
|
import org.jcnc.jnotepad.tool.PopUpUtil;
|
||||||
import org.jcnc.jnotepad.ui.menu.JNotepadMenuBar;
|
import org.jcnc.jnotepad.ui.menu.JNotepadMenuBar;
|
||||||
@ -67,7 +63,6 @@ public abstract class LoadJnotepadConfig<T> {
|
|||||||
logger.info("未检测到配置文件!");
|
logger.info("未检测到配置文件!");
|
||||||
// 不存在则创建
|
// 不存在则创建
|
||||||
createConfig();
|
createConfig();
|
||||||
logger.info("已创建默认配置文件!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,13 +3,16 @@ package org.jcnc.jnotepad.tool;
|
|||||||
|
|
||||||
import com.ibm.icu.text.CharsetDetector;
|
import com.ibm.icu.text.CharsetDetector;
|
||||||
import com.ibm.icu.text.CharsetMatch;
|
import com.ibm.icu.text.CharsetMatch;
|
||||||
import org.jcnc.jnotepad.app.config.LocalizationConfig;
|
import org.jcnc.jnotepad.constants.TextConstants;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import static org.jcnc.jnotepad.constants.TextConstants.UNKNOWN;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,6 +74,10 @@ public class EncodingDetector {
|
|||||||
public static Charset detectEncodingCharset(File file) {
|
public static Charset detectEncodingCharset(File file) {
|
||||||
String charset = detectEncoding(file);
|
String charset = detectEncoding(file);
|
||||||
if (charset.equals(localizationConfig.getUnknown())) {
|
if (charset.equals(localizationConfig.getUnknown())) {
|
||||||
|
try {
|
||||||
|
assert charset != null;
|
||||||
|
return Charset.forName(charset);
|
||||||
|
} catch (Exception e) {
|
||||||
return Charset.defaultCharset();
|
return Charset.defaultCharset();
|
||||||
}
|
}
|
||||||
return Charset.forName(charset);
|
return Charset.forName(charset);
|
||||||
|
|||||||
@ -3,13 +3,13 @@
|
|||||||
<!-- scanPeriod属性设置监测配置文件修改的时间间隔,默认单位为毫秒,在scan为true时才生效 -->
|
<!-- scanPeriod属性设置监测配置文件修改的时间间隔,默认单位为毫秒,在scan为true时才生效 -->
|
||||||
<!-- debug属性如果为true时,会打印出logback内部的日志信息 -->
|
<!-- debug属性如果为true时,会打印出logback内部的日志信息 -->
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
<!-- 定义参数常量 -->JJ
|
<!-- 定义参数常量 -->
|
||||||
<!-- 日志级别:TRACE<DEBUG<INFO<WARN<ERROR,其中常用的是DEBUG、INFO和ERROR -->
|
<!-- 日志级别:TRACE<DEBUG<INFO<WARN<ERROR,其中常用的是DEBUG、INFO和ERROR -->
|
||||||
<property name="log.level" value="debug"/>
|
<property name="log.level" value="debug"/>
|
||||||
<!-- 文件保留时间 -->
|
<!-- 文件保留时间 -->
|
||||||
<property name="log.maxHistory" value="30"/>
|
<property name="log.maxHistory" value="30"/>
|
||||||
<!-- 日志存储路径 -->
|
<!-- 日志存储路径 -->
|
||||||
<property name="log.filePath" value="logs"/>
|
<property name="log.filePath" value="${user.home}/.jnotepad/logs"/>
|
||||||
<!--打包时,请使用下方的路径-->
|
<!--打包时,请使用下方的路径-->
|
||||||
<!--<property name="log.filePath" value="../logs"/>-->
|
<!--<property name="log.filePath" value="../logs"/>-->
|
||||||
<!-- 日志的显式格式 -->
|
<!-- 日志的显式格式 -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user