feat(wifi_adb): WiFi-ADB 设置对话框三个连接路径都记 last_wifi_target
补齐之前 main commit a71f6fa 漏的几处:
- "连接"按钮:成功后保存 ip:port + 设备型号到 last_wifi_target
- "自动连接"按钮:从 USB → WiFi 切换成功后保存
- "断开连接"按钮:如果断开的就是上次记住的 IP,清掉记录避免下次启动徒劳重试
行为现在统一:所有"连上一台 WiFi 设备"的入口都会更新记忆,所有"主动断开"
的入口都会清除记忆。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a71f6faed0
commit
b3a41db029
1 file changed
+46
-1
+46
-1
@@ -859,13 +859,29 @@ def main():
|
||||
|
||||
def connect_wifi():
|
||||
ip = ip_var.get().strip()
|
||||
port = port_var.get().strip()
|
||||
port = port_var.get().strip() or "5555"
|
||||
if not ip:
|
||||
on_line("[WiFi ADB] 请输入IP地址")
|
||||
return
|
||||
success, msg = connect_wifi_adb(adb_exe, ip, port)
|
||||
on_line(f"[WiFi ADB] {msg}")
|
||||
if success:
|
||||
# 记住,下次启动自动重连
|
||||
target = ip if ":" in ip else f"{ip}:{port}"
|
||||
model = ""
|
||||
try:
|
||||
model = query_device_model(adb_exe, target)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
set_last_wifi_target(target, model)
|
||||
on_line(
|
||||
f"[WiFi ADB] 已记住 {target}"
|
||||
+ (f" ({model})" if model else "")
|
||||
+ ",下次 GUI 启动会自动重连"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
# 刷新设备列表
|
||||
refresh_devices()
|
||||
# 重新打开对话框以显示新的WiFi设备
|
||||
@@ -886,6 +902,17 @@ def main():
|
||||
success, msg = disconnect_wifi_adb(adb_exe, ip, "5555")
|
||||
on_line(f"[WiFi ADB] {msg}")
|
||||
if success:
|
||||
# 如果断开的就是上次记住的设备,清掉记录避免下次启动徒劳重试
|
||||
try:
|
||||
last = get_last_wifi_target()
|
||||
last_target = str(last.get("target") or "")
|
||||
if last_target.startswith(ip):
|
||||
clear_last_wifi_target()
|
||||
on_line(
|
||||
f"[WiFi ADB] 已清除上次设备记录 {last_target}"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
# 刷新设备列表
|
||||
refresh_devices()
|
||||
# 重新打开对话框以更新设备列表
|
||||
@@ -929,6 +956,24 @@ def main():
|
||||
ip_success, ip_msg = get_device_ip(adb_exe, device_id)
|
||||
if ip_success:
|
||||
ip_var.set(ip_msg)
|
||||
# 记住目标设备
|
||||
target = (
|
||||
ip_msg if ":" in ip_msg else f"{ip_msg}:5555"
|
||||
)
|
||||
model = ""
|
||||
try:
|
||||
model = query_device_model(adb_exe, target)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
set_last_wifi_target(target, model)
|
||||
on_line(
|
||||
f"[WiFi ADB] 已记住 {target}"
|
||||
+ (f" ({model})" if model else "")
|
||||
+ ",下次 GUI 启动会自动重连"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
# 重新打开对话框以显示新的WiFi设备
|
||||
dialog.destroy()
|
||||
open_wifi_adb_dialog()
|
||||
|
||||
Reference in new issue
Block a user