From 2461e2850bb5d2155ff5365cc3fd67ab05a2b71b Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Mon, 29 Apr 2024 15:17:29 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E6=81=A2=E5=A4=8D=E5=87=BA?= =?utf8?q?=E5=8E=82=E8=AE=BE=E7=BD=AE=E5=90=8E=20ConfigModel.json=E4=B8=8D?= =?utf8?q?=E4=BC=9A=E5=86=8D=E6=AC=A1=E7=94=9F=E6=88=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../fd230app/nativeui/config/src/ConfigModel.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index 19035b2db..30ea2e204 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -123,13 +123,22 @@ namespace OHOS reset_item_to_default(item); } } - return true; } else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Open JSON filePath fail!:%s", filePath.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Open JSON filePath fail!:%s , create a new Json Configfile!", filePath.c_str()); + cjson_json = cJSON_CreateObject(); + for (int i = 0; i< ConfigItem::CONFIGMODEL_ITEM_MAX;i++) + { + ConfigItem item = (ConfigItem)i; + cJSON *obj=get_item(item); + if (obj == NULL) //没有变量则用默认值初始化 + { + reset_item_to_default(item); + } + } } - return false; + return true; } /*1.读取字符串*/ -- 2.17.1