From db323a26ced12e501c670caed143d3a78acb9325 Mon Sep 17 00:00:00 2001 From: songchunyi <2402265378@qq.com> Date: Tue, 25 Aug 2026 03:43:51 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20=5Ffix=5Fpause=5Fstop.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _fix_pause_stop.py | 74 ---------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 _fix_pause_stop.py diff --git a/_fix_pause_stop.py b/_fix_pause_stop.py deleted file mode 100644 index f074ae20..00000000 --- a/_fix_pause_stop.py +++ /dev/null @@ -1,74 +0,0 @@ -import sys - -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: - lines = f.readlines() - -print(f'Total lines: {len(lines)}') - -# Find lines with "无可用任务" -target_lines = [] -for i, line in enumerate(lines): - if '无可用任务' in line: - target_lines.append(i) - # Print surrounding context - start = max(0, i-5) - end = min(len(lines), i+3) - for j in range(start, end): - print(f' L{j+1}: {lines[j].rstrip()}') - -print(f'Found at lines: {[l+1 for l in target_lines]}') - -# For each occurrence, replace the block: -# lines[i-3]: " final taskId = taskCubit.state.currentTaskId;" -# lines[i-2]: " if (taskId == null) {" -# lines[i-1]: " _showPageToast(message: "无可用任务", type: ToastType.warn);" -# lines[i]: " return;" -# lines[i+1]: " }" - -for line_idx in target_lines: - # Find the start of the block - block_start = line_idx - 1 - block_end = line_idx + 2 - - indent = '' - for ch in lines[block_start]: - if ch in (' ', '\t'): - indent += ch - else: - break - - new_lines = [ - f'{indent}if (taskId == null) {{\n', - f'{indent} await taskCubit.fetchAndFilterTask(deviceId);\n', - f'{indent} final tasks = taskCubit.state.activeTasks;\n', - f'{indent} if (tasks.isNotEmpty) {{\n', - f'{indent} taskCubit.selectTask(tasks.first);\n', - f'{indent} taskId = tasks.first.id;\n', - f'{indent} }} else {{\n', - f'{indent} _showPageToast(message: "无可用任务", type: ToastType.warn);\n', - f'{indent} return;\n', - f'{indent} }}\n', - f'{indent}}}\n', - ] - - # Also change "final taskId" to "var taskId" - var_line_idx = line_idx - 2 - old_var_line = lines[var_line_idx] - lines[var_line_idx] = old_var_line.replace('final taskId', 'var taskId') - - # Replace the block - old_block = lines[block_start:block_end+1] - print(f'Replacing lines {block_start+1}-{block_end+1}:') - for l in old_block: - print(f' OLD: {l.rstrip()}') - for l in new_lines: - print(f' NEW: {l.rstrip()}') - - lines[block_start:block_end+1] = new_lines - -with open(path, 'w', encoding='utf-8', newline='') as f: - f.writelines(lines) - -print('DONE')