vf107/src/view/config/menu/networkSettingView.js
@@ -9,6 +9,9 @@
const net_map = map.get("NET")
const networkSettingView = {}
networkSettingView.isEditing = false // 是否正在编辑配置的标志位
networkSettingView.isVisible = false // 是否在网络配置页面的标志位
networkSettingView.init = function () {
    /**************************************************创建屏幕*****************************************************/
    const screenMain = dxui.View.build('networkSettingView', dxui.Utils.LAYER.MAIN)
@@ -20,6 +23,8 @@
    screenMain.bgColor(0xffffff)
    screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_LOADED, () => {
        topView.changeTheme(true)
        networkSettingView.isEditing = false // 屏幕加载时重置编辑状态
        networkSettingView.isVisible = true // 屏幕加载时设置为可见
        const configAll = screen.getConfig()
        // Store initial state for comparison on save
@@ -38,6 +43,7 @@
        let netList = []
        switch (screen.dxDriver.DRIVER.MODEL) {
            case "vf105":
            case "vf107":
                netList = [i18n.t('networkSettingView.ethernet'), i18n.t('networkSettingView.wifi')]
                break;
            case "vf114":
@@ -59,6 +65,8 @@
    screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_UNLOADED, () => {
        wifiListBoxClose.send(dxui.Utils.EVENT.CLICK)
        networkSettingView.isVisible = false // 屏幕卸载时设置为不可见
        networkSettingView.isEditing = false // 屏幕卸载时重置编辑状态
    })
    const titleBox = viewUtils.title(screenMain, configView.screenMain, 'networkSettingViewTitle', 'networkSettingView.title')
@@ -177,6 +185,21 @@
            input.setSize(screen.screenSize.width * (310 / 600), screen.screenSize.height * (45 / 1280))
            item.input = input
            // 添加输入框焦点事件监听和值变化监听,防止编辑时配置被重置
            input.on(dxui.Utils.EVENT.FOCUSED, () => {
                networkSettingView.isEditing = true
            })
            input.on(dxui.Utils.EVENT.DEFOCUSED, () => {
                // 只有当配置没有变化时才设置isEditing为false
                if (!networkSettingView._isConfigChanged()) {
                    networkSettingView.isEditing = false
                }
            })
            // 添加值变化监听,当用户修改了值时设置isEditing为true
            input.on(dxui.Utils.EVENT.VALUE_CHANGED, () => {
                networkSettingView.isEditing = true
            })
            if (item.title === 'networkSettingView.wifiName') {
                input.setSize(screen.screenSize.width * (200 / 600), screen.screenSize.height * (45 / 1280))
                input.align(dxui.Utils.ALIGN.RIGHT_MID, -screen.screenSize.width * (110 / 600), 0)
@@ -217,6 +240,11 @@
            __switch.setSize(screen.screenSize.width * (70 / 600), screen.screenSize.height * (35 / 1280))
            __switch.bgColor(0x000000, NativeObject.APP.NativeComponents.NativeEnum.LV_PART_INDICATOR | NativeObject.APP.NativeComponents.NativeEnum.LV_STATE_CHECKED)
            item.switch = __switch
            // 添加开关事件监听,防止操作时配置被重置
            __switch.on(dxui.Utils.EVENT.VALUE_CHANGED, () => {
                networkSettingView.isEditing = true
            })
        }
        if (item.type === 'dropdown') {
@@ -233,6 +261,7 @@
            if (item.title === 'networkSettingView.type') {
                dropdown.on(dxui.Utils.EVENT.VALUE_CHANGED, () => {
                    networkSettingView.isEditing = true
                    switch (dropdown.getSelected()) {
                        case 0:
                            networkSettingView.changeNetType(1)
@@ -406,6 +435,7 @@
    const saveBtn = viewUtils.bottomBtn(screenMain, screenMain.id + 'saveBtn', 'networkSettingView.save', () => {
        if (!networkSettingView._isConfigChanged()) {
            // No changes, just go back
            networkSettingView.isEditing = false
            dxui.loadMain(screenMain.backScreen)
            return
        }
@@ -527,6 +557,7 @@
            networkSettingView.statusPanel.success()
            std.setTimeout(() => {
                // 成功返回上一层界面
                networkSettingView.isEditing = false
                dxui.loadMain(screenMain.backScreen)
            }, 500)
            screen.updateNetStatus("disconnect")
@@ -546,10 +577,7 @@
}
networkSettingView._isConfigChanged = function () {
    //如果打开界面时的数据和点击保存按钮时的数据前后没有发生变化,就不触发重连和数据保存
    if (net_map.get("NET_STATUS") != "connected") {
        return true //但是假如网络没连上,就一定要触发重连和数据保存
    }
    //检查配置是否真的发生了变化,无论网络状态如何
    const selectedTypeIndex = networkSettingView.netInfo[0].dropdown.getSelected()
    let currentType
    switch (selectedTypeIndex) {
@@ -633,6 +661,11 @@
}
networkSettingView.refresh = function () {
    // 如果用户正在编辑配置,不执行自动刷新
    if (networkSettingView.isEditing) {
        return
    }
    const configAll = screen.getConfig()
    let selectNum = 0