优化表盘删除的函数
authorCaisking <Casiking@zhihuishixun.com>
Thu, 24 Jul 2025 06:54:36 +0000 (14:54 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Thu, 24 Jul 2025 06:54:36 +0000 (14:54 +0800)
code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp

index 4a88065..287c7e8 100644 (file)
@@ -214,7 +214,8 @@ std::string SetDialModel::GetdialPath(int Id) {
   //判断Id是否在map中
   if (registeredDials.find(Id) != registeredDials.end()) {
     // 先将第一个字符串字面量转换为std::string,后续拼接会自动兼容
-    std::string path = std::string(APP_DEFAULT_DIAL_PATH) + "/" + registeredDials[Id] + ".bin";
+    std::string path =
+        std::string(APP_DEFAULT_DIAL_PATH) + "/" + registeredDials[Id] + ".bin";
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetdialPath is %s", path.c_str());
     return path;
   }
@@ -265,8 +266,9 @@ bool SetDialModel::IsDialInstalled(uint16_t ID) {
     return false;
   }
 }
-/*删除自定义表盘*/
+/*删除自定义表盘文件*/
 bool SetDialModel::DeleteCustomDial(uint16_t Id) {
+#if 0
   // 删除配置文件
   std::string filename = GetSaveDir(Id) + "/" + std::to_string(Id) + ".bin";
   if (!uapi_delete_files(filename.c_str())) {
@@ -369,11 +371,19 @@ bool SetDialModel::DeleteCustomDial(uint16_t Id) {
                   "DeleteCustomDial: Invalid dial ID: %d", Id);
     return false; // ID 不合法
   }
+#endif
+  std::string dirpath = GetSaveDir(Id) + "/";
+  if (uapi_delete_folder(dirpath.c_str()) == -1) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "DeleteCustomDial: Failed to delete dial directory: %s",
+                  dirpath.c_str());
+    return false;
+  }
 
   // 所有操作成功  重新加载list
   registeredDials.erase(Id);
   LoadAllDial();
-  WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP,
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
                 "DeleteCustomDial: Successfully deleted custom dial with ID %d",
                 Id);
   //删除表盘,更新id文件