diff --git a/init_permissions.py b/init_permissions.py index 291d1e4..5ae9d7b 100644 --- a/init_permissions.py +++ b/init_permissions.py @@ -291,13 +291,25 @@ async def main(): print(f" 注册权限: {perm_count}, 授权次数: {grant_count}, 错误: {error_count}") - # ---- 4c: 注册数据表页面权限 ---- + # ---- 4c: 注册数据表页面权限(按 CRUD json 的 alias 或 tblname) ---- print(f"\n [4c] 注册数据表页面权限...") crud_count = 0 for module, tables in pc.CRUD_TABLES.items(): - for table in tables: - page_path = f"/{module}/{table}" + json_dir = os.path.join(APP_ROOT, '..', module, 'json') + if not os.path.isdir(json_dir): + continue + for f in sorted(os.listdir(json_dir)): + if not f.endswith('.json'): + continue try: + with open(os.path.join(json_dir, f), 'r') as fh: + data = json.loads(fh.read()) + tblname = data.get('tblname', '') + alias = data.get('alias', '') + if not tblname: + continue + url_name = alias if alias else tblname + page_path = f"/{module}/{url_name}" permid = await ensure_permission(sor, page_path, permtype='page') await grant_perm(sor, role_ids['admin_superuser'], permid) crud_count += 1 diff --git a/wwwroot/index.ui b/wwwroot/index.ui index 6a0b6a1..6980815 100644 --- a/wwwroot/index.ui +++ b/wwwroot/index.ui @@ -46,6 +46,7 @@ "id": "btn_logout", "options": { "label": "退出登录", +"bgcolor": "#3a73e8", "color": "white" } }