vf107/src/view/mainView.js
@@ -35,10 +35,10 @@
        // 直接从net模块获取IP地址,确保获取到最新的IP
        let ip = ""
        try {
            let netType = config["net.type"] || 1
            let netMode = net.getModeByCard(netType)
            if (netMode && netMode.param && netMode.param.ip) {
                ip = netMode.param.ip
            // 使用getNetParam()方法获取最新的网络参数
            let param = net.getNetParam()
            if (param && param.ip) {
                ip = param.ip
            }
        } catch (error) {
            // 出错时使用config中的IP
@@ -86,10 +86,10 @@
        // 直接从net模块获取IP地址,确保获取到最新的IP
        let ip = ""
        try {
            let netType = config["net.type"] || 1
            let netMode = net.getModeByCard(netType)
            if (netMode && netMode.param && netMode.param.ip) {
                ip = netMode.param.ip
            // 使用getNetParam()方法获取最新的网络参数
            let param = net.getNetParam()
            if (param && param.ip) {
                ip = param.ip
            }
        } catch (error) {
            // 出错时使用config中的IP
@@ -128,6 +128,33 @@
        }
    }
    // 更新网络图标
    function updateNetworkIcon() {
        try {
            let config = screen.getConfig()
            let netType = config["net.type"] || 1
            let isConnected = net.isConnected()
            // 隐藏所有网络图标
            if (topView.ethShow) topView.ethShow.hide()
            if (topView.wifiShow) topView.wifiShow.hide()
            if (topView._4gShow) topView._4gShow.hide()
            // 根据网络类型和连接状态显示对应的图标
            if (isConnected) {
                if (netType === 1) { // 以太网
                    if (topView.ethShow) topView.ethShow.show()
                } else if (netType === 2) { // WiFi
                    if (topView.wifiShow) topView.wifiShow.show()
                } else if (netType === 4) { // 4G
                    if (topView._4gShow) topView._4gShow.show()
                }
            }
        } catch (error) {
            logger.error('[mainView]: 更新网络图标失败:', error)
        }
    }
    screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_LOADED, () => {
        topView.changeTheme(false)
@@ -148,6 +175,8 @@
        // 程序启动时更新库区名称和仓号
        updateWarehouseInfo()
        // 初始化网络图标
        updateNetworkIcon()
        // 只注册一次事件监听器
        if (!mainView.eventListenersRegistered) {
@@ -158,9 +187,11 @@
                onStatusChange: function(netType, status) {
                    // 网络状态变化时更新IP信息
                    updateDeviceInfo()
                    // 更新网络图标
                    updateNetworkIcon()
                }
            })
            // 启动网络事件循环
            std.setInterval(() => {
                try {
@@ -803,9 +834,10 @@
        oxygenValueContainer.flexAlign(dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER)
        oxygenValueContainer.obj.lvObjSetStylePadGap(5, dxui.Utils.ENUM._LV_STYLE_STATE_CMP_SAME)
        
        // 氧气数值部分
        const oxygenValue = dxui.Label.build('oxygenValue', oxygenValueContainer)
        oxygenValue.text('20')
        oxygenValue.text('-')
        oxygenValue.textFont(viewUtils.font(20, dxui.Utils.FONT_STYLE.BOLD))
        oxygenValue.textColor(0xffffff)
        mainView.oxygenValue = oxygenValue // 设置为mainView属性
@@ -865,7 +897,7 @@
        
        // 磷化氢数值部分
        const ph3Value = dxui.Label.build('ph3Value', ph3ValueContainer)
        ph3Value.text('0')
        ph3Value.text('-')
        ph3Value.textFont(viewUtils.font(20, dxui.Utils.FONT_STYLE.BOLD))
        ph3Value.textColor(0xffffff)
        mainView.ph3Value = ph3Value // 设置为mainView属性
@@ -909,7 +941,7 @@
        
        // 二氧化碳数值部分
        const co2Value = dxui.Label.build('co2Value', co2ValueContainer)
        co2Value.text('400')
        co2Value.text('-')
        co2Value.textFont(viewUtils.font(20, dxui.Utils.FONT_STYLE.BOLD))
        co2Value.textColor(0xffffff)
        mainView.co2Value = co2Value // 设置为mainView属性