runhey 3 лет назад
Родитель
Сommit
10d2ceb73c

+ 14 - 1
deploy/launcher/oas-gui.bat

@@ -51,5 +51,18 @@ python -m deploy.installer
 if %errorlevel% neq 0 (
 if %errorlevel% neq 0 (
     pause > nul
     pause > nul
 ) else (
 ) else (
-    python gui.py
+    REM 璉��亦恣������
+    >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
+    
+    REM 憒��銝𠹺��∪𦶢隞斤�餈𥪜��潔蛹0嚗��銵函內�瑟�蝞∠��䀹��?
+    if "%errorlevel%"=="0" (
+        REM 隞亦恣���頨思遢餈鞱� Python �𡁏𧋦
+        start /B pythonw gui.py
+    ) else (
+        REM 憒��瘝⊥�蝞∠��䀹��琜��嗘蝙�?PowerShell �𣂼�銝箇恣���頨思遢撟嗉�銵諹��?
+        PowerShell -Command "Start-Process -Verb RunAs pythonw  -ArgumentList gui.py"
 )
 )
+)
+
+REM �喲𡡒�芾澈蝒堒藁
+taskkill /F /PID %PPID%

+ 1 - 1
deploy/process.py

@@ -62,7 +62,7 @@ class ProcessManager(DeployConfig):
 
 
     def process_kill(self):
     def process_kill(self):
         logger.hr(f'Kill existing Alas', 0)
         logger.hr(f'Kill existing Alas', 0)
-        self.kill_by_name('alas.exe')
+        self.kill_by_name('oas.exe')
         self.kill_by_name('python.exe')
         self.kill_by_name('python.exe')
 
 
 
 

+ 3 - 1
gui.py

@@ -2,6 +2,7 @@
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
 
 
+from module.gui.utils import check_admin
 from module.gui.context.add import Add
 from module.gui.context.add import Add
 from module.gui.context.settings import Setting
 from module.gui.context.settings import Setting
 from module.gui.context.process_manager import ProcessManager
 from module.gui.context.process_manager import ProcessManager
@@ -9,7 +10,8 @@ from module.gui.fluent_app import FluentApp
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     # 检查是不是以管理员身份运行,脚本启动的其他进程会继承权限
     # 检查是不是以管理员身份运行,脚本启动的其他进程会继承权限
-
+    # 但是貌似有问题的这个函数
+    # check_admin()
     # 启动一个UI交互的线程,因为信号槽不可跨进程
     # 启动一个UI交互的线程,因为信号槽不可跨进程
     # 后面选择注入上下文快
     # 后面选择注入上下文快
     app = FluentApp()
     app = FluentApp()

+ 1 - 1
module/config/argument/setting-template.json

@@ -1 +1 @@
-{"displayMode":1,"darkMode":2,"primaryColor":"Yellow","nativeText":true,"language":"zh-CN"}
+{"displayMode":1,"darkMode":2,"primaryColor":"Yellow","nativeText":true,"language":"简体中文"}

+ 17 - 0
module/config/i18n/README.md

@@ -0,0 +1,17 @@
+这个是qt的翻译系统
+
+[TS file format | Qt Linguist Manual](https://doc.qt.io/qt-6/linguist-ts-file-format.html)
+
+
+
+你需要手动的编写ts文件并用linguist编译生成对应的qm文件
+
+可以手动的用记事本打开ts文件.
+
+context就是对应的qml所使用的翻译的文件名
+
+
+
+
+
+![image-20230528155846492](https://runhey-img-stg1.oss-cn-chengdu.aliyuncs.com/img2/202305281558027.png)

BIN
module/config/i18n/en_US.qm


+ 77 - 0
module/config/i18n/en_US.ts

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="en_US">
+<context>
+    <name>ItemsOriginal</name>
+    <message>
+        <source>home</source>
+        <translation>home</translation>
+    </message>
+</context>
+<context>
+    <name>ItemsFooter</name>
+    <message>
+        <source>add</source>
+        <translation>add</translation>
+    </message>
+    <message>
+        <source>about</source>
+        <translation>关于</translation>
+    </message>
+    <message>
+        <source>settings</source>
+        <translation>about</translation>
+    </message>
+</context>
+<context>
+    <name>O_Settings</name>
+    <message>
+        <source>Dark Mode</source>
+        <translation>Dark Mode</translation>
+    </message>
+    <message>
+        <source>System</source>
+        <translation>System</translation>
+    </message>
+    <message>
+        <source>Light</source>
+        <translation>Light</translation>
+    </message>
+    <message>
+        <source>Dark</source>
+        <translation>Dark</translation>
+    </message>
+    <message>
+        <source>navigation_view_display_mode</source>
+        <translation>Navigation view display mode</translation>
+    </message>
+    <message>
+        <source>Open</source>
+        <translation>Open</translation>
+    </message>
+    <message>
+        <source>Compact</source>
+        <translation>Compact</translation>
+    </message>
+    <message>
+        <source>Minimal</source>
+        <translation>Minimal</translation>
+    </message>
+    <message>
+        <source>Auto</source>
+        <translation>Auto</translation>
+    </message>
+    <message>
+        <source>Theme color</source>
+        <translation>Theme color</translation>
+    </message>
+    <message>
+        <source>Native text rendering</source>
+        <translation>Native text rendering</translation>
+    </message>
+    <message>
+        <source>Locale</source>
+        <translation>Locale</translation>
+    </message>
+</context>
+</TS>

BIN
module/config/i18n/zh_CN.qm


+ 122 - 0
module/config/i18n/zh_CN.ts

@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="zh_CN">
+<context>
+    <name>ItemsOriginal</name>
+    <message>
+        <source>home</source>
+        <translation>主页</translation>
+    </message>
+</context>
+<context>
+    <name>ItemsFooter</name>
+    <message>
+        <source>add</source>
+        <translation>新增</translation>
+    </message>
+    <message>
+        <source>about</source>
+        <translation>关于</translation>
+    </message>
+    <message>
+        <source>settings</source>
+        <translation>设置</translation>
+    </message>
+</context>
+<context>
+    <name>O_Settings</name>
+    <message>
+        <source>Dark Mode</source>
+        <translation>夜间模式</translation>
+    </message>
+    <message>
+        <source>System</source>
+        <translation>系统</translation>
+    </message>
+    <message>
+        <source>Light</source>
+        <translation>明亮</translation>
+    </message>
+    <message>
+        <source>Dark</source>
+        <translation>暗夜</translation>
+    </message>
+    <message>
+        <source>navigation_view_display_mode</source>
+        <translation>导航视图显示模式</translation>
+    </message>
+    <message>
+        <source>Open</source>
+        <translation>展开</translation>
+    </message>
+    <message>
+        <source>Compact</source>
+        <translation>紧凑</translation>
+    </message>
+    <message>
+        <source>Minimal</source>
+        <translation>最小化</translation>
+    </message>
+    <message>
+        <source>Auto</source>
+        <translation>自动</translation>
+    </message>
+    <message>
+        <source>Theme color</source>
+        <translation>主题颜色</translation>
+    </message>
+    <message>
+        <source>Native text rendering</source>
+        <translation>原生文本渲染</translation>
+    </message>
+    <message>
+        <source>Locale</source>
+        <translation>语言环境</translation>
+    </message>
+</context>
+<context>
+    <name>O_Home</name>
+    <message>
+        <source>Home</source>
+        <translation>主页</translation>
+    </message>
+    <message>
+        <source>Update</source>
+        <translation>更新</translation>
+    </message>
+</context>
+<context>
+    <name>ScriptView</name>
+    <message>
+        <source>Overview</source>
+        <translation>总览</translation>
+    </message>
+</context>
+<context>
+    <name>SplitPanel</name>
+    <message>
+        <source>Home</source>
+        <translation>主页</translation>
+    </message>
+    <message>
+        <source>Update</source>
+        <translation>更新</translation>
+    </message>
+	<message>
+        <source>Overview</source>
+        <translation>总览</translation>
+    </message>
+	<message>
+        <source>Script</source>
+        <translation>脚本</translation>
+    </message>
+	<message>
+        <source>General</source>
+        <translation>通用</translation>
+    </message>
+	<message>
+        <source>Restart</source>
+        <translation>重启</translation>
+    </message>
+</context>
+</TS>

+ 59 - 1
module/gui/fluent_app.py

@@ -6,11 +6,12 @@ import os
 
 
 from PySide6.QtGui import QGuiApplication, QIcon
 from PySide6.QtGui import QGuiApplication, QIcon
 from PySide6.QtQml import QQmlApplicationEngine
 from PySide6.QtQml import QQmlApplicationEngine
-from PySide6.QtCore import Qt, QObject, QStandardPaths, QCoreApplication
+from PySide6.QtCore import Qt, QObject, QTranslator, QLocale, Slot
 from pathlib import Path
 from pathlib import Path
 
 
 from module.gui.utils import get_work_path
 from module.gui.utils import get_work_path
 from module.gui.Bridge import bridge
 from module.gui.Bridge import bridge
+from module.logger import logger
 
 
 # import module.gui.qml_rcc
 # import module.gui.qml_rcc
 import module.gui.res_rcc
 import module.gui.res_rcc
@@ -18,6 +19,7 @@ import module.gui.res_rcc
 class FluentApp():
 class FluentApp():
     app = None
     app = None
     engine = None
     engine = None
+    translator = None
 
 
     def __init__(self):
     def __init__(self):
         super().__init__()
         super().__init__()
@@ -36,6 +38,9 @@ class FluentApp():
         FluentApp.engine = QQmlApplicationEngine()
         FluentApp.engine = QQmlApplicationEngine()
         FluentApp.engine.addImportPath(os.fspath(Path(__file__).resolve().parent))
         FluentApp.engine.addImportPath(os.fspath(Path(__file__).resolve().parent))
 
 
+        FluentApp.translator = Translator(engine=FluentApp.engine, app=FluentApp.app)
+        self.set_context_property(context=FluentApp.translator, name='translator')
+
     @classmethod
     @classmethod
     def run(cls):
     def run(cls):
         FluentApp.engine.load(os.fspath(Path(get_work_path() / 'module' / 'gui' / 'qml' / 'app.qml')))
         FluentApp.engine.load(os.fspath(Path(get_work_path() / 'module' / 'gui' / 'qml' / 'app.qml')))
@@ -53,3 +58,56 @@ class FluentApp():
         """
         """
         FluentApp.engine.rootContext().setContextProperty(name, context)
         FluentApp.engine.rootContext().setContextProperty(name, context)
 
 
+#     @classmethod
+#     def init_translator(cls) -> None:
+#         """
+#         初始化翻译
+#         :return:
+#         """
+#         path_en_US = Path.cwd() / "module" / "config" / "i18n" / "en_US.qm"
+#         path_zh_CN = Path.cwd() / "module" / "config" / "i18n" / "zh_CN.qm"
+#         FluentApp.translator = QTranslator()
+#         # FluentApp.translator.load(str(path_en_US.resolve()))
+#         print(FluentApp.translator.load(str(path_zh_CN.resolve())))
+#         QGuiApplication.installTranslator(FluentApp.translator)
+#         FluentApp.engine.retranslate()
+#         print(FluentApp.translator.language())
+# #        # locale = QLocale("en_US")  # 设置英文
+# #        locale = QLocale("zh_CN")  # 设置中文
+# #        FluentApp.app.setApplicationLocale(locale)
+
+
+class Translator(QObject):
+
+    def __init__(self, engine, app) -> None:
+        super(Translator, self).__init__()
+        self._engine = engine
+        self._app = app
+        self.path_en_US = str((Path.cwd() / "module" / "config" / "i18n" / "en_US.qm").resolve())
+        self.path_zh_CN = str((Path.cwd() / "module" / "config" / "i18n" / "zh_CN.qm").resolve())
+
+        self.translator = QTranslator()
+
+    @Slot(str)
+    def set_language(self, language: str) -> None:
+        """
+        设置语言
+        :param language:
+        :return:
+        """
+        if language == "简体中文":
+            if not self.translator.load(self.path_zh_CN):
+                logger.error("load language 简体中文 failed!")
+            QGuiApplication.installTranslator(self.translator)
+            self._engine.retranslate()
+            return
+
+        if language == "English":
+            if not self.translator.load(self.path_en_US):
+                logger.error("load language English failed!")
+            QGuiApplication.installTranslator(self.translator)
+            self._engine.retranslate()
+            return
+
+
+

+ 4 - 11
module/gui/qml/Component/SplitPanel.qml

@@ -47,26 +47,19 @@ Item {
         anchors.bottomMargin: 12
         anchors.bottomMargin: 12
     }
     }
 
 
-    Component.onCompleted: {
-        var datas = []
-        datas.push(menu_tree.createItem("Home",false))
-        datas.push(menu_tree.createItem("Update",false))
-//        datas.push(menu_tree.createItem("Node2",true,[createItem("Node2-1",false),createItem("Node2-2",false)]))
-        menu_tree.updateData(datas)
-    }
     //创建左边的菜单,最多两级
     //创建左边的菜单,最多两级
-    //['home', 'xxx':['x1', 'x2']]
+    //['home', 'xxx':['x1', 'x2']]  是英文的
     function create(data){
     function create(data){
         var datas = []
         var datas = []
         for(var items in data){
         for(var items in data){
             if(items.length === 0){
             if(items.length === 0){
-                datas.push(menu_tree.createItem(items,false))
+                datas.push(menu_tree.createItem(qsTr(items),false))
             }else{
             }else{
                 var da = []
                 var da = []
                 for(var item in data[items]){
                 for(var item in data[items]){
-                    da.push(menu_tree.createItem(data[items][item], false))
+                    da.push(menu_tree.createItem(qsTr(data[items][item]), false))
                 }
                 }
-                datas.push(menu_tree.createItem(items, true, da))
+                datas.push(menu_tree.createItem(qsTr(items), true, da))
             }
             }
         }
         }
         menu_tree.updateData(datas)
         menu_tree.updateData(datas)

+ 3 - 4
module/gui/qml/Global/ItemsFooter.qml

@@ -13,23 +13,22 @@ FluObject{
     FluPaneItemSeparator{}
     FluPaneItemSeparator{}
 
 
     FluPaneItem{
     FluPaneItem{
-        title: "add"
+        title: qsTr("add")
         icon: FluentIcons.Add
         icon: FluentIcons.Add
         onTap:{
         onTap:{
             MainEvent.addOpen = !MainEvent.addOpen
             MainEvent.addOpen = !MainEvent.addOpen
         }
         }
     }
     }
     FluPaneItem{
     FluPaneItem{
-        title: "about"
+        title: qsTr("about")
         icon:FluentIcons.Contact
         icon:FluentIcons.Contact
         tapFunc:function(){
         tapFunc:function(){
-            console.debug("this click about")
             MainEvent.runStatus = MainEvent.RunStatus.Error
             MainEvent.runStatus = MainEvent.RunStatus.Error
         }
         }
     }
     }
 
 
     FluPaneItem{
     FluPaneItem{
-        title: "settings"
+        title: qsTr("settings")
         icon:FluentIcons.Settings
         icon:FluentIcons.Settings
         onTap:{
         onTap:{
             Qt.Pa
             Qt.Pa

+ 1 - 2
module/gui/qml/Global/ItemsOriginal.qml

@@ -9,7 +9,7 @@ FluObject{
 
 
     property var navigationView
     property var navigationView
     FluPaneItem{
     FluPaneItem{
-        title: "home"
+        title: qsTr("home")
         icon:FluentIcons.Home
         icon:FluentIcons.Home
         onTap:{
         onTap:{
             navigationView.push(Qt.resolvedUrl("../../qml/Page/O_Home.qml"))
             navigationView.push(Qt.resolvedUrl("../../qml/Page/O_Home.qml"))
@@ -102,7 +102,6 @@ FluObject{
         var exists = allPaneItems()
         var exists = allPaneItems()
         for(var i=0; i<configs.length; i++){
         for(var i=0; i<configs.length; i++){
             if(exists.includes(configs[i])){
             if(exists.includes(configs[i])){
-                console.debug('已经存在了:'+configs[i])
             }else{
             }else{
             createPaneItem(configs[i])
             createPaneItem(configs[i])
             }
             }

+ 10 - 4
module/gui/qml/Global/MainEvent.qml

@@ -20,13 +20,18 @@ QtObject {
     property int darkMode: FluDarkMode.System
     property int darkMode: FluDarkMode.System
     property QtObject primaryColor: FluColors.Orange
     property QtObject primaryColor: FluColors.Orange
     property bool nativeText: true
     property bool nativeText: true
-    property string language: "zh-CN"
+    property string language: ""
 
 
     property int runStatus: MainEvent.RunStatus.Empty
     property int runStatus: MainEvent.RunStatus.Empty
-    property string menuTitle: "主页"
+    property string menuTitle: ""
     property bool addOpen: false
     property bool addOpen: false
     property string scriptName: ""
     property string scriptName: ""
 
 
+    //切换语言中文是"zh_CN" 英文是"en_US"
+    function switchLocale(locale) {
+
+    }
+
     Component.onCompleted:{
     Component.onCompleted:{
         var set = JSON.parse(setting.read())
         var set = JSON.parse(setting.read())
         mainEvent.settings = set
         mainEvent.settings = set
@@ -36,13 +41,14 @@ QtObject {
                 "darkMode": 2,
                 "darkMode": 2,
                 "primaryColor": "Orange",
                 "primaryColor": "Orange",
                 "nativeText": true,
                 "nativeText": true,
-                "language": "zh-CN"}
+                "language": "简体中文"}
         }
         }
 
 
         mainEvent.displayMode = set["displayMode"]
         mainEvent.displayMode = set["displayMode"]
         mainEvent.darkMode = set["darkMode"]
         mainEvent.darkMode = set["darkMode"]
         mainEvent.nativeText = set["nativeText"]
         mainEvent.nativeText = set["nativeText"]
         mainEvent.language = set["language"]
         mainEvent.language = set["language"]
+        switchLocale("zh_CN")
 
 
         var primary_color = set["primaryColor"]
         var primary_color = set["primaryColor"]
         if(primary_color === "Yellow"){mainEvent.primaryColor = FluColors.Yellow}
         if(primary_color === "Yellow"){mainEvent.primaryColor = FluColors.Yellow}
@@ -112,6 +118,6 @@ QtObject {
 
 
         mainEvent.settings["language"] = mainEvent.language
         mainEvent.settings["language"] = mainEvent.language
         setting.update(JSON.stringify(mainEvent.settings))
         setting.update(JSON.stringify(mainEvent.settings))
-//        showSuccess('update language' + mainEvent.language)
+        translator.set_language(mainEvent.language)
     }
     }
 }
 }

+ 5 - 2
module/gui/qml/Page/O_Home.qml

@@ -10,12 +10,12 @@ import "../Component"
 SplitPanel{
 SplitPanel{
 
 
     onTitleChanged: {
     onTitleChanged: {
-        if(title === "Home"){
+        if(title === qsTr("Home")){
             var comp = Qt.createComponent("../../qml/Page/Home.qml")
             var comp = Qt.createComponent("../../qml/Page/Home.qml")
             if (comp.status === Component.Ready) {
             if (comp.status === Component.Ready) {
                 setLoader(comp)
                 setLoader(comp)
             }
             }
-        }else if(title === "Update"){
+        }else if(title === qsTr("Update")){
             var updater = Qt.createComponent("../../qml/Page/Update.qml")
             var updater = Qt.createComponent("../../qml/Page/Update.qml")
             if (updater.status === Component.Ready) {
             if (updater.status === Component.Ready) {
                 setLoader(updater)
                 setLoader(updater)
@@ -23,6 +23,9 @@ SplitPanel{
         }
         }
     }
     }
     Component.onCompleted:{
     Component.onCompleted:{
+        var data = { "Home":[], 'Update': []}
+        create(data)
+
         var comp = Qt.createComponent("../../qml/Page/Home.qml")
         var comp = Qt.createComponent("../../qml/Page/Home.qml")
         if (comp.status === Component.Ready) {
         if (comp.status === Component.Ready) {
             setDefalut(comp)
             setDefalut(comp)

+ 47 - 6
module/gui/qml/Page/O_Settings.qml

@@ -25,12 +25,12 @@ FluScrollablePage{
                 left: parent.left
                 left: parent.left
             }
             }
             FluText{
             FluText{
-                text: "Dark Mode"
+                text: qsTr("Dark Mode")
                 font: FluTextStyle.BodyStrong
                 font: FluTextStyle.BodyStrong
                 Layout.bottomMargin: 4
                 Layout.bottomMargin: 4
             }
             }
             Repeater{
             Repeater{
-                model: [{title:"System",mode:FluDarkMode.System},{title:"Light",mode:FluDarkMode.Light},{title:"Dark",mode:FluDarkMode.Dark}]
+                model: [{title:qsTr("System"),mode:FluDarkMode.System},{title:qsTr("Light"),mode:FluDarkMode.Light},{title:qsTr("Dark"),mode:FluDarkMode.Dark}]
                 delegate:  FluRadioButton{
                 delegate:  FluRadioButton{
                     selected : MainEvent.darkMode === modelData.mode
                     selected : MainEvent.darkMode === modelData.mode
                     text:modelData.title
                     text:modelData.title
@@ -59,12 +59,12 @@ FluScrollablePage{
             }
             }
 
 
             FluText{
             FluText{
-                text: "navigation_view_display_mode"
+                text: qsTr("navigation_view_display_mode")
                 font: FluTextStyle.BodyStrong
                 font: FluTextStyle.BodyStrong
                 Layout.bottomMargin: 4
                 Layout.bottomMargin: 4
             }
             }
             Repeater{
             Repeater{
-                model: [{title:"Open",mode:FluNavigationView.Open},{title:"Compact",mode:FluNavigationView.Compact},{title:"Minimal",mode:FluNavigationView.Minimal},{title:"Auto",mode:FluNavigationView.Auto}]
+                model: [{title:qsTr("Open"),mode:FluNavigationView.Open},{title:qsTr("Compact"),mode:FluNavigationView.Compact},{title:qsTr("Minimal"),mode:FluNavigationView.Minimal},{title:qsTr("Auto"),mode:FluNavigationView.Auto}]
                 delegate:  FluRadioButton{
                 delegate:  FluRadioButton{
                     selected : MainEvent.displayMode===modelData.mode
                     selected : MainEvent.displayMode===modelData.mode
                     text:modelData.title
                     text:modelData.title
@@ -79,13 +79,18 @@ FluScrollablePage{
     FluArea{
     FluArea{
         Layout.fillWidth: true
         Layout.fillWidth: true
         Layout.topMargin: 20
         Layout.topMargin: 20
-        height: 210
+        height: 160
         paddings: 10
         paddings: 10
         ColumnLayout{
         ColumnLayout{
             spacing:0
             spacing:0
             anchors{
             anchors{
                 left: parent.left
                 left: parent.left
             }
             }
+            FluText{
+                text: qsTr("Theme color")
+                font: FluTextStyle.BodyStrong
+                Layout.bottomMargin: 4
+            }
             RowLayout{
             RowLayout{
                 Layout.topMargin: 10
                 Layout.topMargin: 10
                 Repeater{
                 Repeater{
@@ -114,7 +119,8 @@ FluScrollablePage{
                 }
                 }
             }
             }
             FluText{
             FluText{
-                text:"native文本渲染"
+                text:qsTr("Native text rendering")
+                font: FluTextStyle.BodyStrong
                 Layout.topMargin: 20
                 Layout.topMargin: 20
             }
             }
             FluToggleSwitch{
             FluToggleSwitch{
@@ -127,5 +133,40 @@ FluScrollablePage{
         }
         }
     }
     }
 
 
+    FluArea{
+        Layout.fillWidth: true
+        Layout.topMargin: 20
+        height: 80
+        paddings: 10
+
+        ColumnLayout{
+            spacing: 10
+            anchors{
+                top: parent.top
+                left: parent.left
+            }
+
+            FluText{
+                text:qsTr("Locale")
+                font: FluTextStyle.BodyStrong
+                Layout.bottomMargin: 4
+            }
+
+            Flow{
+                spacing: 5
+                Repeater{
+                    model: ["简体中文","English"]
+                    delegate:  FluRadioButton{
+                        selected : MainEvent.language === modelData
+                        text:modelData
+                        onClicked:{
+                            MainEvent.language = modelData
+                        }
+                    }
+                }
+            }
+        }
+    }
+
 
 
 }
 }

+ 1 - 1
module/gui/qml/Page/ScriptView.qml

@@ -8,7 +8,7 @@ SplitPanel{
 
 
     property string configName: ""
     property string configName: ""
     onTitleChanged: {
     onTitleChanged: {
-        if(title === "Overview"){
+        if(title === qsTr("Overview")){
             showDefalut()
             showDefalut()
         }
         }
         else{
         else{

+ 35 - 1
module/gui/utils.py

@@ -1,10 +1,44 @@
 # This Python file uses the following encoding: utf-8
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
+import ctypes
+import win32gui
+import win32con
+import sys
+import time
+
 from pathlib import Path
 from pathlib import Path
+from module.logger import logger
 
 
 def get_work_path() -> Path:
 def get_work_path() -> Path:
     """
     """
     返回程序工作的目录如果没有问题的就是根目录
     返回程序工作的目录如果没有问题的就是根目录
     """
     """
-    return Path.cwd()
+    return Path.cwd()
+
+
+def is_admin():
+    """
+    Check if the program is running as an admin.
+    """
+    try:
+        return ctypes.windll.shell32.IsUserAnAdmin()
+    except:
+        return False
+
+def check_admin():
+    """
+    检查是不是管理员权限
+    如果不是管理员权限则使用管理员权限重启
+    """
+    if not is_admin():
+        logger.info('非管理员身份运行,已尝试以管理员身份运行')
+        time.sleep(5)
+        # Hide the command window
+        # win = win32gui.GetForegroundWindow()
+        # win32gui.ShowWindow(win, win32con.SW_HIDE)
+        # Re-run the program as an admin
+        args = ' '.join(sys.argv)
+        ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
+        sys.exit(0)
+    logger.log('管理员身份运行')

+ 2 - 1
requirements-in.txt

@@ -9,4 +9,5 @@ opencv-python==4.7.0.72
 websockets==11.0.3
 websockets==11.0.3
 anytree==2.8.0
 anytree==2.8.0
 pywin32==306
 pywin32==306
-zerorpc==0.6.3
+zerorpc==0.6.3
+wrapt==1.15.0