feat(gui): 添加系统托盘功能并优化 UI

- 实现系统托盘支持,包含打开主界面、反编译工具和退出程序的菜单项
- 添加窗口关闭时隐藏而不是退出的功能
-优化托盘图标,使用圆角图像
- 增加中文字体支持和全局字体设置- 移除 AIChatDialog 中的 MathJax 配置- 更新 BoxClassLoader,添加 com.dustinredmond 包的访问权限
- 在 build.gradle 中添加 SystemTray4J 和 JavaFX相关依赖
This commit is contained in:
tzdwindows 7
2025-03-16 12:17:44 +08:00
parent 9da8953253
commit 4ce244579f
4 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
package com.axis.innovators.box.gui;
import javax.swing.*;
import java.awt.*;
public class ComponentFactory {
/**
* 创建带样式的文本组件
* @param text 显示文本
* @param color 文本颜色
* @param fontSize 字体大小单位pt
* @param size 组件尺寸null时使用自动布局
* @return 配置完成的文本组件
*/
public static Component createTextComponent(String text, Color color,
int fontSize, Dimension size) {
return createTextComponent(text, color, fontSize, null, size);
}
/**
* 重载方法支持背景色配置
* @param bgColor 背景颜色null时为透明
*/
public static Component createTextComponent(String text, Color color,
int fontSize, Color bgColor,
Dimension size) {
JLabel label = new JLabel(text) {
// 抗锯齿渲染
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
super.paintComponent(g2);
}
};
// 基础样式配置
label.setForeground(color);
label.setFont(new Font("微软雅黑", Font.PLAIN, fontSize));
// 背景色处理
if (bgColor != null) {
label.setOpaque(true);
label.setBackground(bgColor);
}
// 尺寸设置
if (size != null) {
label.setPreferredSize(size);
label.setMinimumSize(size);
label.setMaximumSize(size);
}
return label;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB