66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
import json
|
|
import sys
|
|
|
|
# 读取 pages.json
|
|
with open('peidu/uniapp/pages.json', 'r', encoding='utf-8') as f:
|
|
data = json.load(f)
|
|
|
|
# 需要删除的页面路径
|
|
pages_to_remove = {
|
|
'src/user-package': [
|
|
'pages/user/friends',
|
|
'pages/user/work-order',
|
|
'pages/user/my-package',
|
|
'pages/user/address'
|
|
],
|
|
'teacher-package': [
|
|
'pages/level/index',
|
|
'pages/teacher/profile',
|
|
'pages/teacher/settings',
|
|
'pages/teacher/reviews',
|
|
'pages/growth-record/list',
|
|
'pages/growth-record/detail',
|
|
'pages/growth-record/edit'
|
|
],
|
|
'provider-package': [
|
|
'pages/provider/order-list',
|
|
'pages/provider/order-detail',
|
|
'pages/provider/profile',
|
|
'pages/provider/setting',
|
|
'pages/provider/course-publish',
|
|
'pages/provider/course-edit',
|
|
'pages/provider/category-courses',
|
|
'pages/provider/special-course-list',
|
|
'pages/provider/special-course-detail',
|
|
'pages/provider/special-course-publish'
|
|
],
|
|
'training-package': [
|
|
'pages/franchise/policy',
|
|
'pages/franchise/progress',
|
|
'pages/franchise/select-tenant',
|
|
'pages/franchise/my-tenant'
|
|
],
|
|
'src/activity-package': [
|
|
'pages/growth/growth-record'
|
|
]
|
|
}
|
|
|
|
# 处理每个 subPackage
|
|
for subpkg in data.get('subPackages', []):
|
|
root = subpkg.get('root', '')
|
|
if root in pages_to_remove:
|
|
# 过滤掉不存在的页面
|
|
original_count = len(subpkg['pages'])
|
|
subpkg['pages'] = [
|
|
page for page in subpkg['pages']
|
|
if page['path'] not in pages_to_remove[root]
|
|
]
|
|
removed_count = original_count - len(subpkg['pages'])
|
|
print(f"从 {root} 删除了 {removed_count} 个页面配置")
|
|
|
|
# 写回文件
|
|
with open('peidu/uniapp/pages.json', 'w', encoding='utf-8') as f:
|
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
|
|
print("✅ pages.json 修复完成")
|