32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
|
||
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')
|
||
|