同步更新:重构路由、服务模块,更新前端构建

This commit is contained in:
2025-12-14 21:47:08 +08:00
parent e01a7b5235
commit a346509a5f
87 changed files with 9186 additions and 7826 deletions

View File

@@ -13,9 +13,18 @@ import atexit
import weakref
from typing import Optional, Callable
from dataclasses import dataclass
from urllib.parse import urlsplit
from app_config import get_config
BASE_URL = "https://postoa.aidunsoft.com"
config = get_config()
BASE_URL = getattr(config, "ZSGL_BASE_URL", "https://postoa.aidunsoft.com")
LOGIN_URL = getattr(config, "ZSGL_LOGIN_URL", f"{BASE_URL}/admin/login.aspx")
INDEX_URL_PATTERN = getattr(config, "ZSGL_INDEX_URL_PATTERN", "index.aspx")
COOKIES_DIR = getattr(config, "COOKIES_DIR", "data/cookies")
_cookie_domain_fallback = urlsplit(BASE_URL).hostname or "postoa.aidunsoft.com"
_api_browser_instances: "weakref.WeakSet[APIBrowser]" = weakref.WeakSet()
@@ -79,12 +88,11 @@ class APIBrowser:
import json
import hashlib
cookies_dir = '/app/data/cookies'
os.makedirs(cookies_dir, exist_ok=True)
os.makedirs(COOKIES_DIR, exist_ok=True)
# 安全修复使用SHA256代替MD5作为文件名哈希
filename = hashlib.sha256(username.encode()).hexdigest()[:32] + '.json'
cookies_path = os.path.join(cookies_dir, filename)
cookies_path = os.path.join(COOKIES_DIR, filename)
try:
# 获取requests session的cookies
@@ -93,7 +101,7 @@ class APIBrowser:
cookies_list.append({
'name': cookie.name,
'value': cookie.value,
'domain': cookie.domain or 'postoa.aidunsoft.com',
'domain': cookie.domain or _cookie_domain_fallback,
'path': cookie.path or '/',
})
@@ -182,8 +190,7 @@ class APIBrowser:
self.log(f"[API] 登录: {username}")
try:
login_url = f"{BASE_URL}/admin/login.aspx"
resp = self._request_with_retry('get', login_url)
resp = self._request_with_retry('get', LOGIN_URL)
soup = BeautifulSoup(resp.text, 'html.parser')
fields = self._get_aspnet_fields(soup)
@@ -195,17 +202,17 @@ class APIBrowser:
resp = self._request_with_retry(
'post',
login_url,
LOGIN_URL,
data=data,
headers={
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': BASE_URL,
'Referer': login_url,
'Referer': LOGIN_URL,
},
allow_redirects=True
)
if 'index.aspx' in resp.url:
if INDEX_URL_PATTERN in resp.url:
self.logged_in = True
self.log(f"[API] 登录成功")
return True