“单设备登录(同端互斥)”功能和后台全局用户配置
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
"""设备类型检测工具。"""
|
||||
|
||||
|
||||
def detect_device_type(user_agent: str | None) -> str:
|
||||
"""根据 User-Agent 判断设备类型:'pc' 或 'mobile'。
|
||||
|
||||
返回 'mobile' 表示手机/平板等移动设备,返回 'pc' 表示桌面设备或无法识别。
|
||||
"""
|
||||
if not user_agent:
|
||||
return "pc"
|
||||
ua = user_agent.lower()
|
||||
mobile_keywords = [
|
||||
"mobile", "android", "iphone", "ipad", "ipod",
|
||||
"windows phone", "blackberry", "opera mini", "opera mobi",
|
||||
]
|
||||
return "mobile" if any(kw in ua for kw in mobile_keywords) else "pc"
|
||||
Reference in New Issue
Block a user