Files
medical-mall/fix_pages.py

32 lines
1.3 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import re
file_path = r'd:\\骅锋\\mall\\pages.json'
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# Find homePage definition
target_pattern = r'(\{\s*\
path\:\s*\pages/mall/admin/homePage/index\[\s\S]*?\})'
# The block to append
new_block = r''',{
\path\: \pages/mall/admin/userCenter/index\,
\style\: {
\navigationBarTitleText\: \个人中心\,
\navigationStyle\: \custom\
}
}'''
def replace_func(match):
return match.group(1) + new_block
new_content = re.sub(target_pattern, replace_func, content)
with open(file_path, 'w', encoding='utf-8') as f:
f.write(new_content)
print('Updated pages.json')