张世豪
4 小时以前 d22349714c8d199c02f336f90fba841ef8f5cd39
src/xitongshezhi/ConfigSet.java
@@ -54,13 +54,13 @@
    private final MenuItemListener menuItemListener;
    
    public ConfigSet(JFrame parent) {
        super(parent, "设置", true);
        super(parent, "", true);
        configManager = Chushihua.getInstance();
        menuItemListener = new MenuItemListener();
     // 记录进入设置页面前的轮询状态
        // 记录进入设置页面前的轮询状态
        recordPollingStateBeforeEntering();
        initializeUI();
     // 进入设置页面时暂停轮询
        // 进入设置页面时暂停轮询
        pausePollingWhenEntering();
    }
    
@@ -135,7 +135,26 @@
        mainPanel.add(createHeaderPanel(), BorderLayout.NORTH);
        mainPanel.add(createMenuGridPanel(), BorderLayout.CENTER);
        
        // 添加版权信息在底部
        mainPanel.add(createCopyrightPanel(), BorderLayout.SOUTH);
        getContentPane().add(mainPanel);
    }
 // 创建版权信息面板
    private JPanel createCopyrightPanel() {
        JPanel copyrightPanel = new JPanel();
        copyrightPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
        copyrightPanel.setOpaque(true);
        copyrightPanel.setBackground(DARK_COLOR);
        copyrightPanel.setBorder(new EmptyBorder(10, 0, 5, 0));
        JLabel copyrightLabel = new JLabel("北京华星北斗智控技术有限公司 版权所有 2025");
        copyrightLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
        copyrightLabel.setForeground(new Color(160, 160, 160));
        copyrightPanel.add(copyrightLabel);
        return copyrightPanel;
    }
    
    private JPanel createHeaderPanel() {
@@ -158,8 +177,11 @@
        closeButton.setOpaque(true); // 确保不透明
        closeButton.setFocusPainted(false);
        closeButton.setBorder(BorderFactory.createEmptyBorder(10, 18, 10, 18));
        closeButton.setIcon(getCachedIcon("✕", 16));
        closeButton.addActionListener(e -> dispose());
        closeButton.addActionListener(e -> {
            // 强制开启轮询查询功能
            forceStartPolling();
            dispose();
        });
        
        // 添加悬停效果
        closeButton.addMouseListener(new java.awt.event.MouseAdapter() {
@@ -588,12 +610,13 @@
        return icon;
    }
    
    private void showSystemDebugDialog() {
        SystemDebugDialog.showSystemDebugDialog((JFrame) getParent());
    }
    
    @Override
    public void dispose() {
        // 退出设置页面时恢复轮询控制
        SystemDebugDialog.setPollingControlEnabled(true);
        // 退出设置页面时恢复轮询
        resumePollingWhenExiting();
        
@@ -673,5 +696,43 @@
            configDialog.setVisible(true);
        });
    }    
    /**
     * 强制开启轮询查询功能(无论当前状态如何)
     */
    private void forceStartPolling() {
        try {
            // 如果轮询未运行,则启动轮询
            if (!lunxun.isPolling()) {
                boolean started = lunxun.startPolling();
                if (started) {
                    //System.out.println("强制开启:轮询查询已启动");
                } else {
                    System.err.println("强制开启:启动轮询查询失败");
                }
            }
            // 如果轮询已运行但处于暂停状态,则恢复轮询
            else if (lunxun.isPaused()) {
                boolean resumed = lunxun.resumePolling();
                if (resumed) {
                    //System.out.println("强制开启:轮询查询已恢复");
                } else {
                    System.err.println("强制开启:恢复轮询查询失败");
                }
            }
            // 如果轮询已运行且未暂停,则无需操作
            else {
                //System.out.println("强制开启:轮询查询已在运行中");
            }
        } catch (Exception e) {
            System.err.println("强制开启轮询查询时发生异常: " + e.getMessage());
        }
    }
    
 // 在 showSystemDebugDialog 方法中添加
    private void showSystemDebugDialog() {
        // 在打开调试对话框时禁用轮询控制
        SystemDebugDialog.setPollingControlEnabled(false);
        SystemDebugDialog.showSystemDebugDialog((JFrame) getParent());
    }
}