fix:wifi页面wifi列表新增刷新功能
This commit is contained in:
@@ -26,6 +26,8 @@ const connectError = ref("");
|
|||||||
const keyboardHeight = ref(0);
|
const keyboardHeight = ref(0);
|
||||||
// 控制密码输入框是否显示明文
|
// 控制密码输入框是否显示明文
|
||||||
const showPassword = ref(false);
|
const showPassword = ref(false);
|
||||||
|
// 刷新防抖标志:扫描进行中为 true,禁止重复点击;扫描结束(成功/失败)后重置为 false。
|
||||||
|
const isRefreshing = ref(false);
|
||||||
|
|
||||||
const progress = ref(0);
|
const progress = ref(0);
|
||||||
let progressTimer = null;
|
let progressTimer = null;
|
||||||
@@ -56,12 +58,13 @@ const showWifiPermissionDeniedModal = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 将 iOS 当前手机连接的 WiFi 写入候选列表,供用户继续填写设备连接密码。
|
// 将 iOS 当前手机连接的 WiFi 写入候选列表,供用户继续填写设备连接密码;扫描结束后重置刷新防抖标志。
|
||||||
const applyIOSConnectedWifi = (wifi) => {
|
const applyIOSConnectedWifi = (wifi) => {
|
||||||
const ssid = wifi?.SSID;
|
const ssid = wifi?.SSID;
|
||||||
if (!ssid) {
|
if (!ssid) {
|
||||||
wifiList.value = [];
|
wifiList.value = [];
|
||||||
currentState.value = STATES.LIST;
|
currentState.value = STATES.LIST;
|
||||||
|
isRefreshing.value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +77,7 @@ const applyIOSConnectedWifi = (wifi) => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
currentState.value = STATES.LIST;
|
currentState.value = STATES.LIST;
|
||||||
|
isRefreshing.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取 iOS 当前手机连接的 WiFi,并把它作为可选网络展示。
|
// 获取 iOS 当前手机连接的 WiFi,并把它作为可选网络展示。
|
||||||
@@ -91,6 +95,7 @@ const syncIOSConnectedWifi = () => {
|
|||||||
});
|
});
|
||||||
wifiList.value = [];
|
wifiList.value = [];
|
||||||
currentState.value = STATES.LIST;
|
currentState.value = STATES.LIST;
|
||||||
|
isRefreshing.value = false;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -110,12 +115,16 @@ const startIOSScanning = () => {
|
|||||||
});
|
});
|
||||||
if (err.errCode === 12005) showWifiBanner.value = true;
|
if (err.errCode === 12005) showWifiBanner.value = true;
|
||||||
currentState.value = STATES.LIST;
|
currentState.value = STATES.LIST;
|
||||||
|
isRefreshing.value = false;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 启动小程序 WiFi 能力并按平台获取可用网络。
|
// 启动小程序 WiFi 能力并按平台获取可用网络;也作为刷新按钮的点击处理器,重新获取最新 WiFi 列表。
|
||||||
|
// 扫描进行中时防抖:若上次扫描尚未完成则直接 return,避免重复触发导致弹窗异常。
|
||||||
const startScanning = () => {
|
const startScanning = () => {
|
||||||
|
if (isRefreshing.value) return;
|
||||||
|
isRefreshing.value = true;
|
||||||
currentState.value = STATES.SCANNING;
|
currentState.value = STATES.SCANNING;
|
||||||
wifiList.value = [];
|
wifiList.value = [];
|
||||||
showWifiBanner.value = false;
|
showWifiBanner.value = false;
|
||||||
@@ -141,6 +150,7 @@ const startScanning = () => {
|
|||||||
});
|
});
|
||||||
if (isWifiPermissionDenied(err)) showWifiPermissionDeniedModal();
|
if (isWifiPermissionDenied(err)) showWifiPermissionDeniedModal();
|
||||||
if (err.errCode === 12005) showWifiBanner.value = true;
|
if (err.errCode === 12005) showWifiBanner.value = true;
|
||||||
|
isRefreshing.value = false;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -152,6 +162,7 @@ const startScanning = () => {
|
|||||||
});
|
});
|
||||||
if (isWifiPermissionDenied(err)) showWifiPermissionDeniedModal();
|
if (isWifiPermissionDenied(err)) showWifiPermissionDeniedModal();
|
||||||
if (err.errCode === 12005) showWifiBanner.value = true;
|
if (err.errCode === 12005) showWifiBanner.value = true;
|
||||||
|
isRefreshing.value = false;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -164,6 +175,7 @@ const startScanning = () => {
|
|||||||
}
|
}
|
||||||
wifiList.value = realWifiList;
|
wifiList.value = realWifiList;
|
||||||
currentState.value = STATES.LIST;
|
currentState.value = STATES.LIST;
|
||||||
|
isRefreshing.value = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -372,10 +384,10 @@ onUnmounted(() => {
|
|||||||
<view class="section-label-row">
|
<view class="section-label-row">
|
||||||
<text class="section-label">网络</text>
|
<text class="section-label">网络</text>
|
||||||
<image
|
<image
|
||||||
v-if="currentState === 'SCANNING'"
|
|
||||||
src="../static/sicon/refresh.png"
|
src="../static/sicon/refresh.png"
|
||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
style="width: 34rpx; height: 34rpx; margin-left: 8rpx; opacity: 0.7;"
|
:style="{ width: '34rpx', height: '34rpx', marginLeft: '8rpx', opacity: isRefreshing ? 0.3 : 0.7 }"
|
||||||
|
@click="startScanning"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user