mirror of
https://github.com/YaoFANGUK/video-subtitle-remover.git
synced 2026-05-22 06:13:24 +08:00
在代码中添加管理员权限请求功能
- 在gui.py中添加Windows管理员权限检测和请求代码 - 使用ctypes.windll.shell32.ShellExecuteW实现UAC权限提升 - 移除PyInstaller的uac_admin配置避免启动问题 - 优化spec文件确保interface文件正确复制 - 程序现在会在启动时自动请求管理员权限 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,12 @@ datas = [
|
|||||||
(os.path.join(current_dir, 'ui/icon'), 'ui/icon'),
|
(os.path.join(current_dir, 'ui/icon'), 'ui/icon'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# 手动添加interface文件,确保被包含
|
||||||
|
for filename in os.listdir(os.path.join(current_dir, 'backend/interface')):
|
||||||
|
if filename.endswith('.ini'):
|
||||||
|
src = os.path.join(current_dir, 'backend/interface', filename)
|
||||||
|
datas.append((src, 'backend/interface'))
|
||||||
|
|
||||||
binaries = []
|
binaries = []
|
||||||
|
|
||||||
# 收集重要包的数据文件
|
# 收集重要包的数据文件
|
||||||
@@ -297,8 +303,6 @@ exe = EXE(
|
|||||||
codesign_identity=None,
|
codesign_identity=None,
|
||||||
entitlements_file=None,
|
entitlements_file=None,
|
||||||
icon=['design\\vsr.ico'],
|
icon=['design\\vsr.ico'],
|
||||||
# 请求管理员权限
|
|
||||||
uac_admin=True, # 以管理员身份运行
|
|
||||||
)
|
)
|
||||||
|
|
||||||
coll = COLLECT(
|
coll = COLLECT(
|
||||||
|
|||||||
7
gui.py
7
gui.py
@@ -11,9 +11,16 @@ import os
|
|||||||
import configparser
|
import configparser
|
||||||
import cv2
|
import cv2
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import ctypes
|
||||||
from PySide6.QtCore import Qt, QTranslator
|
from PySide6.QtCore import Qt, QTranslator
|
||||||
from PySide6 import QtCore, QtWidgets, QtGui
|
from PySide6 import QtCore, QtWidgets, QtGui
|
||||||
from PySide6.QtWidgets import QApplication, QFrame, QStackedWidget, QHBoxLayout, QLabel
|
from PySide6.QtWidgets import QApplication, QFrame, QStackedWidget, QHBoxLayout, QLabel
|
||||||
|
|
||||||
|
# 请求管理员权限(Windows)
|
||||||
|
if sys.platform == 'win32' and not ctypes.windll.shell32.IsUserAnAdmin():
|
||||||
|
params = ' '.join([f'"{arg}"' for arg in sys.argv])
|
||||||
|
ctypes.windll.shell32.ShellExecuteW(None, 'runas', sys.executable, params, None, 1)
|
||||||
|
sys.exit(0)
|
||||||
from qfluentwidgets import (FluentWindow, PushButton, Slider, ProgressBar, PlainTextEdit,
|
from qfluentwidgets import (FluentWindow, PushButton, Slider, ProgressBar, PlainTextEdit,
|
||||||
setTheme, Theme, FluentIcon, CardWidget, SettingCardGroup,
|
setTheme, Theme, FluentIcon, CardWidget, SettingCardGroup,
|
||||||
ComboBoxSettingCard, SwitchSettingCard, setThemeColor, OptionsConfigItem,
|
ComboBoxSettingCard, SwitchSettingCard, setThemeColor, OptionsConfigItem,
|
||||||
|
|||||||
Reference in New Issue
Block a user