更新
This commit is contained in:
@@ -5,6 +5,7 @@ import functools
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
from dataclasses import replace
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
@@ -28,6 +29,25 @@ def validate_effective_config(config, requested_api: str) -> None:
|
||||
raise ValueError("本地独立配置已改动,请在 .local-workstation/config 中核对本地服务器设置")
|
||||
|
||||
|
||||
def local_config_type(api: str):
|
||||
"""Pin this explicit local entry, including later login/config updates."""
|
||||
from doctor_workstation.config import AppConfig, normalize_api_base_url
|
||||
|
||||
validate_local_url(api)
|
||||
local_api = normalize_api_base_url(api)
|
||||
|
||||
class LocalAppConfig(AppConfig):
|
||||
def _merge_preferences(self):
|
||||
config = super()._merge_preferences()
|
||||
# Use the locked login behavior with the selected local endpoint.
|
||||
# Shared Qt settings and stale local preferences must not send a
|
||||
# local verification session back to the production backend.
|
||||
return replace(config, api_base_url=local_api, debug_mode=False,
|
||||
demo_mode=False, verify_ssl=True)
|
||||
|
||||
return LocalAppConfig
|
||||
|
||||
|
||||
def main() -> int:
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
api = os.environ.get("DOCTOR_LOCAL_API_URL", "https://css.zhenyangtang.com.cn")
|
||||
@@ -49,16 +69,23 @@ def main() -> int:
|
||||
"SSL_CERT_FILE": str(ca_bundle),
|
||||
})
|
||||
sys.path.insert(0, str(root / "src"))
|
||||
import doctor_workstation
|
||||
# This explicit source-only entry does not edit the formal build configuration.
|
||||
doctor_workstation.DEBUG_MODE = True
|
||||
from doctor_workstation.config import AppConfig
|
||||
config = AppConfig.load()
|
||||
LocalAppConfig = local_config_type(api)
|
||||
config = LocalAppConfig.load()
|
||||
validate_effective_config(config, api)
|
||||
config.save_preferences()
|
||||
if "--check" in sys.argv:
|
||||
print("Local backend: loopback HTTPS; TLS verification enabled; isolated configuration and credential namespace")
|
||||
return 0
|
||||
from PySide6.QtCore import QSettings
|
||||
|
||||
from doctor_workstation import app as workstation_app
|
||||
|
||||
workstation_app.AppConfig = LocalAppConfig
|
||||
workstation_app.LoginWindow = functools.partial(
|
||||
workstation_app.LoginWindow,
|
||||
settings=QSettings("ZhenYangTang", "DoctorWorkstationLocalSource"),
|
||||
)
|
||||
# The normal credential service remains untouched even after a local login.
|
||||
workstation_app.TokenStore = functools.partial(
|
||||
workstation_app.TokenStore, service_name="zyt-doctor-workstation-local-source"
|
||||
|
||||
Reference in New Issue
Block a user