mirror of
https://github.com/octopusYan/alist-gui.git
synced 2025-12-08 17:21:56 +08:00
Compare commits
3 Commits
alpha/v1.0
...
96274f6952
| Author | SHA1 | Date | |
|---|---|---|---|
| 96274f6952 | |||
| b468b9774d | |||
| 17d21fdc03 |
@ -20,7 +20,7 @@
|
||||
|
||||
### 截图
|
||||
|
||||
<details>
|
||||
<details open>
|
||||
<summary> 主界面 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/909ac6ad-0021-47d7-a75c-7fb6505e8c15">
|
||||
@ -28,7 +28,7 @@
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<details open>
|
||||
<summary> 管理员信息 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/840dca69-e67d-4083-88f8-8e67c3e47141">
|
||||
@ -36,7 +36,7 @@
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<details open>
|
||||
<summary> 设置 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/8fc8c489-b9cd-4e34-ad32-4899ccc275e9">
|
||||
@ -44,7 +44,7 @@
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<details open>
|
||||
<summary> 关于 </summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/dbef2d66-4ca4-4e89-8292-dbdce3566f93">
|
||||
|
||||
@ -19,9 +19,10 @@ import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -33,7 +34,7 @@ public class ConsoleLog {
|
||||
public static final String format = "yyyy/MM/dd hh:mm:ss";
|
||||
private volatile static ConsoleLog log;
|
||||
private final VBox textArea;
|
||||
private final static String CONSOLE_COLOR_PREFIX = "^\033[";
|
||||
private final static String CONSOLE_COLOR_PREFIX = "\033[";
|
||||
private final static String CONSOLE_MSG_REX = "^\033\\[(\\d+)m(.*)\033\\[0m(.*)$";
|
||||
private final static String URL_IP_REX = "^((ht|f)tps?:\\/\\/)?[\\w-+&@#/%?=~_|!:,.;]*[\\w-+&@#/%=~_|]+(:\\d{1,5})?\\/?$";
|
||||
|
||||
@ -88,16 +89,6 @@ public class ConsoleLog {
|
||||
if (StringUtils.isEmpty(message) || !isInit()) return;
|
||||
message = message.strip();
|
||||
message = StrUtil.format(message, param);
|
||||
|
||||
// 多颜色消息处理
|
||||
if (StringUtils.countMatches(message, CONSOLE_COLOR_PREFIX) > 1) {
|
||||
String[] split = message.replace(CONSOLE_MSG_REX, "\n%s".formatted(CONSOLE_COLOR_PREFIX)).split("\n");
|
||||
List<String> msgs = Arrays.stream(split).toList();
|
||||
for (String msg : msgs) {
|
||||
msg(msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
message = setPwdText(message);
|
||||
message = resetConsoleColor(message);
|
||||
|
||||
@ -187,17 +178,35 @@ public class ConsoleLog {
|
||||
/**
|
||||
* 控制台输出颜色
|
||||
*
|
||||
* @param msg alist 输出消息
|
||||
* @param msg 输出消息
|
||||
* @return bbcode 颜色文本
|
||||
*/
|
||||
private static String resetConsoleColor(String msg) {
|
||||
if (!msg.contains("\033[")) return msg;
|
||||
if (!msg.contains(CONSOLE_COLOR_PREFIX) || !Pattern.matches(CONSOLE_MSG_REX, msg)) return msg;
|
||||
|
||||
String colorCode = ReUtil.get(CONSOLE_MSG_REX, msg, 1);
|
||||
String color = StringUtils.lowerCase(Color.valueOf(Integer.parseInt(colorCode)).getColor());
|
||||
String colorMsg = ReUtil.get(CONSOLE_MSG_REX, msg, 2);
|
||||
msg = ReUtil.get(CONSOLE_MSG_REX, msg, 3);
|
||||
return color(color, colorMsg) + msg;
|
||||
// 多颜色处理
|
||||
String[] split = Pattern.compile("\\033\\[(\\d;)?(\\d+)m")
|
||||
.matcher(msg)
|
||||
.replaceAll(matchResult -> "\n" + matchResult.group())
|
||||
.replaceFirst("\n", "")
|
||||
.split("\n");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Pattern pattern = Pattern.compile("\\033\\[(\\d;)?(\\d+)m(.*)");
|
||||
Matcher matcher;
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
matcher = pattern.matcher(split[i]);
|
||||
if(!matcher.matches()) continue;
|
||||
|
||||
if (i % 2 == 0) {
|
||||
String color = StringUtils.lowerCase(Color.valueOf(Integer.parseInt(matcher.group(2))).getColor());
|
||||
sb.append(color(color, matcher.group(3)));
|
||||
} else {
|
||||
sb.append(matcher.group(3));
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -65,8 +65,14 @@ public class SetupViewModel extends BaseViewModel {
|
||||
proxySetup.addListener((_, _, newValue) -> ConfigManager.proxySetup(newValue));
|
||||
proxyTestUrl.addListener((_, _, newValue) -> ConfigManager.proxyTestUrl(newValue));
|
||||
proxyHost.addListener((_, _, newValue) -> ConfigManager.proxyHost(newValue));
|
||||
proxyPort.addListener((_, _, newValue) -> ConfigManager.proxyPort(newValue));
|
||||
language.addListener((_, _, newValue) -> Context.setLanguage(newValue));
|
||||
proxyHost.addListener((_, _, newValue) -> {
|
||||
ConfigManager.proxyHost(newValue);
|
||||
setProxy();
|
||||
});
|
||||
proxyPort.addListener((_, _, newValue) -> {
|
||||
ConfigManager.proxyPort(newValue);
|
||||
setProxy();
|
||||
});
|
||||
}
|
||||
|
||||
public ObjectProperty<Theme> themeProperty() {
|
||||
@ -123,6 +129,14 @@ public class SetupViewModel extends BaseViewModel {
|
||||
});
|
||||
}
|
||||
|
||||
private void setProxy() {
|
||||
ConfigManager.checkProxy((success, _) -> {
|
||||
if (!success) return;
|
||||
|
||||
HttpUtil.getInstance().proxy(ConfigManager.proxySetup(), ConfigManager.getProxyInfo());
|
||||
});
|
||||
}
|
||||
|
||||
private static ProxyCheckTask getProxyCheckTask(String checkUrl) {
|
||||
var task = new ProxyCheckTask(checkUrl);
|
||||
task.onListen(new TaskListener(task) {
|
||||
|
||||
Reference in New Issue
Block a user