60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
# AUTO_MAA:A MAA Multi Account Management and Automation Tool
|
|
# Copyright © 2024-2025 DLmaster361
|
|
|
|
# This file is part of AUTO_MAA.
|
|
|
|
# AUTO_MAA is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published
|
|
# by the Free Software Foundation, either version 3 of the License,
|
|
# or (at your option) any later version.
|
|
|
|
# AUTO_MAA is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
|
# the GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
# Contact: DLmaster_361@163.com
|
|
|
|
|
|
import os
|
|
import sys
|
|
import ctypes
|
|
|
|
from app.utils import get_logger
|
|
|
|
logger = get_logger("主程序")
|
|
|
|
|
|
def is_admin() -> bool:
|
|
"""检查当前程序是否以管理员身份运行"""
|
|
try:
|
|
return ctypes.windll.shell32.IsUserAnAdmin()
|
|
except:
|
|
return False
|
|
|
|
|
|
@logger.catch
|
|
def main():
|
|
|
|
if is_admin():
|
|
|
|
import uvicorn
|
|
from app.api import app
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|
else:
|
|
|
|
ctypes.windll.shell32.ShellExecuteW(
|
|
None, "runas", sys.executable, os.path.realpath(sys.argv[0]), None, 1
|
|
)
|
|
sys.exit(0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|