完成后端架构重构等

This commit is contained in:
super
2026-04-23 15:25:41 +08:00
parent 46f46039ea
commit 34bc980eea
76 changed files with 3242 additions and 1111 deletions

View File

@@ -42,9 +42,13 @@ def get_current_admin_role():
)
row = cur.fetchone()
conn.close()
if not row or not row.get('is_admin'):
return None, row
role = row.get('role') or ('super_admin' if row.get('created_by_id') is None else 'admin')
if not row:
return None, None
role = (row.get('role') or '').strip().lower()
if not role:
role = 'super_admin' if row.get('is_admin') and row.get('created_by_id') is None else (
'admin' if row.get('is_admin') else 'normal'
)
return role, row
except Exception:
return None, None
@@ -56,7 +60,14 @@ def is_current_user_admin():
def _is_ajax_request():
return request.headers.get('X-Requested-With') == 'XMLHttpRequest'
if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
return True
if request.path.startswith('/api/'):
return True
accept = (request.headers.get('Accept') or '').lower()
if 'application/json' in accept:
return True
return False
def login_required(f):