#!/usr/bin/env python # -*- coding: utf-8 -*- """ 批量创建 Admin 占位页面 """ import os from pathlib import Path # 页面配置 (基于 adminRoutes.uts) pages_config = [ # 首页 - 已存在,跳过 # 用户模块 {'path': 'pages/mall/admin/user/list.uvue', 'title': '用户管理', 'componentKey': 'UserList'}, {'path': 'pages/mall/admin/user/level.uvue', 'title': '用户等级', 'componentKey': 'UserLevel'}, {'path': 'pages/mall/admin/user/group.uvue', 'title': '用户分组', 'componentKey': 'UserGroup'}, {'path': 'pages/mall/admin/user/label.uvue', 'title': '用户标签', 'componentKey': 'UserLabel'}, {'path': 'pages/mall/admin/user/grade/type.uvue', 'title': '会员类型', 'componentKey': 'UserGradeType'}, {'path': 'pages/mall/admin/user/grade/card.uvue', 'title': '卡密会员', 'componentKey': 'UserGradeCard'}, {'path': 'pages/mall/admin/user/grade/record.uvue', 'title': '会员记录', 'componentKey': 'UserGradeRecord'}, {'path': 'pages/mall/admin/user/grade/right.uvue', 'title': '会员权益', 'componentKey': 'UserGradeRight'}, # 商品模块 {'path': 'pages/mall/admin/product/list.uvue', 'title': '商品管理', 'componentKey': 'ProductList'}, {'path': 'pages/mall/admin/product/classify.uvue', 'title': '商品分类', 'componentKey': 'ProductClassify'}, {'path': 'pages/mall/admin/product/reply.uvue', 'title': '商品评论', 'componentKey': 'ProductReply'}, {'path': 'pages/mall/admin/product/attr.uvue', 'title': '商品规格', 'componentKey': 'ProductAttr'}, {'path': 'pages/mall/admin/product/param.uvue', 'title': '商品参数', 'componentKey': 'ProductParam'}, {'path': 'pages/mall/admin/product/label.uvue', 'title': '商品标签', 'componentKey': 'ProductLabel'}, {'path': 'pages/mall/admin/product/protection.uvue', 'title': '商品保障', 'componentKey': 'ProductProtection'}, # 订单模块 {'path': 'pages/mall/admin/order/list.uvue', 'title': '订单管理', 'componentKey': 'OrderList'}, # 营销模块 {'path': 'pages/mall/admin/marketing/coupon/list.uvue', 'title': '优惠券', 'componentKey': 'MarketingCoupon'}, {'path': 'pages/mall/admin/marketing/integral/list.uvue', 'title': '积分管理', 'componentKey': 'MarketingIntegral'}, {'path': 'pages/mall/admin/marketing/bargain/list.uvue', 'title': '砍价活动', 'componentKey': 'MarketingBargain'}, {'path': 'pages/mall/admin/marketing/combination/list.uvue', 'title': '拼团活动', 'componentKey': 'MarketingCombination'}, {'path': 'pages/mall/admin/marketing/seckill/list.uvue', 'title': '秒杀活动', 'componentKey': 'MarketingSeckill'}, # 内容模块 {'path': 'pages/mall/admin/cms/article/list.uvue', 'title': '文章管理', 'componentKey': 'CmsArticle'}, {'path': 'pages/mall/admin/cms/category/list.uvue', 'title': '文章分类', 'componentKey': 'CmsCategory'}, # 财务模块 {'path': 'pages/mall/admin/finance/record.uvue', 'title': '财务记录', 'componentKey': 'FinanceRecord'}, # 数据统计模块 {'path': 'pages/mall/admin/statistic/index.uvue', 'title': '数据概览', 'componentKey': 'StatisticIndex'}, # 设置模块 {'path': 'pages/mall/admin/setting/system/config.uvue', 'title': '系统配置', 'componentKey': 'SettingSystemConfig'}, {'path': 'pages/mall/admin/setting/system/admin.uvue', 'title': '管理员管理', 'componentKey': 'SettingSystemAdmin'}, {'path': 'pages/mall/admin/setting/system/role.uvue', 'title': '角色管理', 'componentKey': 'SettingSystemRole'}, ] # 占位页面模板 template = ''' ''' def create_placeholder_pages(): """创建所有占位页面""" base_dir = Path(r'd:\骅锋\mall') created_count = 0 skipped_count = 0 for page in pages_config: file_path = base_dir / page['path'] # 如果文件已存在,跳过 if file_path.exists(): print(f'[跳过] {page["path"]} - 文件已存在') skipped_count += 1 continue # 创建目录 file_path.parent.mkdir(parents=True, exist_ok=True) # 生成文件内容 content = template.format( title=page['title'], componentKey=page['componentKey'] ) # 写入文件 with open(file_path, 'w', encoding='utf-8') as f: f.write(content) print(f'[创建] {page["path"]}') created_count += 1 print(f'\n完成! 创建 {created_count} 个文件, 跳过 {skipped_count} 个文件') if __name__ == '__main__': create_placeholder_pages()