# -*- coding: utf-8 -*- """临时脚本:更新 urls.py""" # 读取文件 with open('server/urls.py', 'r', encoding='utf-8') as f: content = f.read() # 1. 更新导入 old_import = "from server.api import auth, accounts, tasks, workers, filters, scripts, contacts, stats, settings as api_settings" new_import = """from server.api import ( auth, accounts, tasks, workers, filters, scripts, contacts, stats, settings as api_settings, followup )""" if old_import in content: content = content.replace(old_import, new_import) # 2. 在联系记录后添加复聊配置路由 insert_point = ' path("api/contacts/", contacts.contact_detail),' followup_routes = ''' path("api/contacts/", contacts.contact_detail), # ─── 复聊配置 ─── path("api/followup-configs", followup.followup_config_list), path("api/followup-configs/", followup.followup_config_detail), path("api/followup-scripts", followup.followup_script_list), path("api/followup-scripts/", followup.followup_script_detail), path("api/followup-records", followup.followup_record_list), path("api/followup-records/send", followup.followup_send_manual),''' if insert_point in content and 'followup-configs' not in content: content = content.replace(insert_point, followup_routes) # 写入文件 with open('server/urls.py', 'w', encoding='utf-8') as f: f.write(content) print("URLs 更新完成!")