From b6e2a40aa773123c0bae38aacee87d6f9bf74dca Mon Sep 17 00:00:00 2001 From: songchunyi <2402265378@qq.com> Date: Tue, 25 Aug 2026 03:41:25 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20=5Ffix=5Fflow.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _fix_flow.py | 92 ---------------------------------------------------- 1 file changed, 92 deletions(-) delete mode 100644 _fix_flow.py diff --git a/_fix_flow.py b/_fix_flow.py deleted file mode 100644 index 584c6de6..00000000 --- a/_fix_flow.py +++ /dev/null @@ -1,92 +0,0 @@ -import re - -path = r'C:\Users\jsmbz\Documents\flutter-app-02\lib\features\home\presentation\widgets\map\testmap_pages.dart' - -with open(path, 'r', encoding='utf-8') as f: - content = f.read() - -# Fix 1: Add var failed = false and if(failed) return, plus else branch for needRequery -old_block = """ var needRequery = false; - result.fold( - (failure) { - final failMsg = failure.toString(); - if (failMsg.contains('存在任务') || failMsg.contains('already exists')) { - needRequery = true; - return; - } - _showPageToast(message: '作业启动失败', type: ToastType.error); - taskCubit.clearCurrentTask(); - return; - }, - (taskId) { - taskCubit.updateCurrentTaskId(taskId); - }, - ); - - if (needRequery) { - await taskCubit.fetchAndFilterTask(deviceId); - await Future.delayed(const Duration(milliseconds: 300)); - final existingTasks = taskCubit.state.activeTasks; - if (existingTasks.isNotEmpty) { - taskCubit.selectTask(existingTasks.first); - } - return; - }""" - -new_block = """ var needRequery = false; - var failed = false; - result.fold( - (failure) { - final failMsg = failure.toString(); - if (failMsg.contains('存在任务') || failMsg.contains('already exists')) { - needRequery = true; - return; - } - failed = true; - debugPrint('[开始作业] 创建失败: $failMsg'); - _showPageToast(message: '作业启动失败', type: ToastType.error); - taskCubit.clearCurrentTask(); - return; - }, - (taskId) { - taskCubit.updateCurrentTaskId(taskId); - }, - ); - - if (failed) return; - if (needRequery) { - await taskCubit.fetchAndFilterTask(deviceId); - await Future.delayed(const Duration(milliseconds: 300)); - final existingTasks = taskCubit.state.activeTasks; - if (existingTasks.isNotEmpty) { - taskCubit.selectTask(existingTasks.first); - } else { - debugPrint('[开始作业] needRequery 后仍无活跃任务'); - _showPageToast(message: '未找到活跃任务', type: ToastType.warn); - } - return; - }""" - -if old_block in content: - content = content.replace(old_block, new_block) - print("Block replaced successfully") -else: - print("Block NOT FOUND in file!") - # Try tab indentation - old_block_tabs = old_block.replace(' ', '\t\t\t\t') - if old_block_tabs in content: - content = content.replace(old_block_tabs, new_block.replace(' ', '\t\t\t\t')) - print("Block replaced with TABS") - else: - # Find the unique line - for i, line in enumerate(content.split('\n')): - if 'var needRequery = false;' in line and 'result.fold(' in content.split('\n')[i+1]: - print(f"Found at line {i+1}: {repr(line)}") - break - else: - print("Could not find needRequery line") - -with open(path, 'w', encoding='utf-8', newline='') as f: - f.write(content) - -print("Done")