import codecs file_path = r'd:\\骅锋\\mall\\layouts\\admin\\components\\AdminHeader.uvue' with codecs.open(file_path, 'r', 'utf-8') as f: text = f.read() # I will replace the user-profile-container entirely with a solid implementation, including the overlay. old_html = r''' crmeb demo 个人中心 退出登录 ''' new_html = r''' crmeb demo 个人中心 退出登录 ''' text = text.replace(old_html, new_html) # Add closeUserMenu to script if doesn't exist if 'function closeUserMenu' not in text: text = text.replace('function toggleUserMenu() {', 'function closeUserMenu() {\n showUserMenu.value = false\n}\n\nfunction toggleUserMenu() {') # Adjust goToUserCenter to remove toast, just keep logic text = text.replace('uni.showToast({ title: "尝试打开个人中心...", icon: "none", duration: 2000 });\n console.log([AdminHeader] goToUserCenter called);\n console.log([AdminHeader] goToUserCenter called);', '') with codecs.open(file_path, 'w', 'utf-8') as f: f.write(text)