diff --git a/src/rom/app.py b/src/rom/app.py index 8326184..d23db6e 100644 --- a/src/rom/app.py +++ b/src/rom/app.py @@ -139,6 +139,7 @@ async def lcd_set(request): elif k == "ui_type": display.ui_type = v config.set(k, v) + config.write() except Exception as e: ack["status"] = "error" ack["message"] = str(e) @@ -212,7 +213,7 @@ async def fetch_weather_data(city=None): # 从配置文件获取城市,如果没有提供则使用配置中的值 if not city: - city = config.get("city") or "北京" + city = config.get("cityid") or "北京" print(f"正在获取{city}天气数据...") # 从配置获取API基础URL,默认使用官方API diff --git a/src/rom/captive_http.py b/src/rom/captive_http.py index af0c801..84566c1 100644 --- a/src/rom/captive_http.py +++ b/src/rom/captive_http.py @@ -119,11 +119,13 @@ class HTTPServer(BaseServer): ssid = unquote(params.get(b"ssid", None)) password = unquote(params.get(b"password", "")) city = unquote(params.get(b"city", None)) + cityid = params.get(b"city", None) # 使用全局Config实例保存配置 config.set("ssid", ssid) config.set("password", password) config.set("city", city) + config.set("cityid", cityid) if config.write(): print("Configuration saved successfully") else: diff --git a/src/rom/www/index.html b/src/rom/www/index.html index 4475bdf..78266c5 100644 --- a/src/rom/www/index.html +++ b/src/rom/www/index.html @@ -79,6 +79,7 @@ placeholder="例如:北京" 可输入城市名称或城市ID(查看城市ID列表)