Files
universal-web-api/app/utils/platform.py
T
2026-11-02 22:54:14 +08:00

42 lines
682 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
app/utils/platform.py - 轻量平台工具
职责:
- 统一判断当前运行平台
- 提供跨平台快捷键抽象
"""
from __future__ import annotations
import sys
def is_windows() -> bool:
return sys.platform.startswith("win")
def is_macos() -> bool:
return sys.platform == "darwin"
def is_linux() -> bool:
return sys.platform.startswith("linux")
def get_primary_modifier_key() -> str:
"""
返回系统主修饰键。
- Windows / Linux: Control
- macOS: Meta(对应 Command)
"""
return "Meta" if is_macos() else "Control"
__all__ = [
"get_primary_modifier_key",
"is_linux",
"is_macos",
"is_windows",
]