refactor(constant): 将应用名称和标题常量统一管理
This commit is contained in:
+2
@@ -46,4 +46,6 @@ public interface SystemConst {
|
||||
String SYMBOL_AT = "@";
|
||||
String PROPERTY_OS_NAME = "os.name";
|
||||
String OS_NAME_WINDOWS = "Windows";
|
||||
String CURRENT_APP_NAME = "cutejava";
|
||||
String CURRENT_APP_TITLE = "CuteJava";
|
||||
}
|
||||
|
||||
+5
-8
@@ -18,7 +18,6 @@ package cn.odboy.framework.server.core;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.odboy.constant.SystemConst;
|
||||
import cn.odboy.util.KitSystemUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -36,26 +35,24 @@ public class KitFileLocalUploadHelper {
|
||||
private static final String PATH_WINDOWS = "C:\\${appName}\\file\\";
|
||||
private static final String PATH_MAC = "/Users${username}/${appName}/file/";
|
||||
private static final String PATH_LINUX = "/home/${appName}/file/";
|
||||
@Value("${spring.application.name}")
|
||||
private String appName;
|
||||
|
||||
public String getPath() {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os == null) {
|
||||
// 默认使用 Linux 路径作为兜底方案
|
||||
return PATH_LINUX.replace("${appName}", appName);
|
||||
return PATH_LINUX.replace("${appName}", SystemConst.CURRENT_APP_NAME);
|
||||
}
|
||||
String lowerOs = os.toLowerCase();
|
||||
if (lowerOs.startsWith(SystemConst.WIN)) {
|
||||
return PATH_WINDOWS.replace("${appName}", appName);
|
||||
return PATH_WINDOWS.replace("${appName}", SystemConst.CURRENT_APP_NAME);
|
||||
} else if (lowerOs.startsWith(SystemConst.MAC)) {
|
||||
String currentUserName = KitSystemUtil.getCurrentUserName();
|
||||
if (StrUtil.isBlank(currentUserName)) {
|
||||
return PATH_MAC.replace("${appName}", appName).replace("${username}", "");
|
||||
return PATH_MAC.replace("${appName}", SystemConst.CURRENT_APP_NAME).replace("${username}", "");
|
||||
}
|
||||
return PATH_MAC.replace("${appName}", appName).replace("${username}", currentUserName);
|
||||
return PATH_MAC.replace("${appName}", SystemConst.CURRENT_APP_NAME).replace("${username}", currentUserName);
|
||||
}
|
||||
return PATH_LINUX.replace("${appName}", appName);
|
||||
return PATH_LINUX.replace("${appName}", SystemConst.CURRENT_APP_NAME);
|
||||
}
|
||||
|
||||
public int getAvatarMaxSize() {
|
||||
|
||||
Reference in New Issue
Block a user