修复
This commit is contained in:
@@ -47,12 +47,33 @@ class Service(db.Model):
|
||||
group_id = db.Column(
|
||||
db.Integer, db.ForeignKey("service_groups.id"), nullable=False, index=True
|
||||
)
|
||||
# hub=复盘中控(iframe 嵌入需 /embed-auth);留空=普通内嵌
|
||||
embed_kind = db.Column(db.String(16), nullable=False, default="", server_default="")
|
||||
|
||||
def build_origin(self) -> str:
|
||||
proto = (self.scheme or "http").strip().lower()
|
||||
if proto not in ("http", "https"):
|
||||
proto = "http"
|
||||
return f"{proto}://{self.host}:{self.port}"
|
||||
|
||||
def build_url(self) -> str:
|
||||
p = (self.path or "/").strip()
|
||||
if not p.startswith("/"):
|
||||
p = "/" + p
|
||||
proto = (self.scheme or "http").strip().lower()
|
||||
if proto not in ("http", "https"):
|
||||
proto = "http"
|
||||
return f"{proto}://{self.host}:{self.port}{p}"
|
||||
return f"{self.build_origin()}{p}"
|
||||
|
||||
def build_open_url(self) -> str:
|
||||
"""导航 iframe 首次打开的地址(中控走 login?embed=1 以便写入会话)。"""
|
||||
kind = (self.embed_kind or "").strip().lower()
|
||||
next_path = (self.path or "/monitor").strip() or "/monitor"
|
||||
if not next_path.startswith("/"):
|
||||
next_path = "/" + next_path
|
||||
if kind == "hub":
|
||||
from urllib.parse import urlencode
|
||||
|
||||
q = urlencode({"embed": "1", "next": next_path})
|
||||
return f"{self.build_origin()}/login?{q}"
|
||||
return self.build_url()
|
||||
|
||||
def is_hub_embed(self) -> bool:
|
||||
return (self.embed_kind or "").strip().lower() == "hub"
|
||||
|
||||
Reference in New Issue
Block a user