Просмотр исходного кода

Merge pull request #9 from runhey/dev

Dev
huangrunheng 3 лет назад
Родитель
Сommit
3909ad7e92
53 измененных файлов с 2720 добавлено и 773 удалено
  1. 1 0
      .gitignore
  2. 89 22
      README.md
  3. 29 43
      config/template.json
  4. 14 1
      deploy/launcher/oas-gui.bat
  5. 1 1
      deploy/process.py
  6. 1 1
      fluentui/README.md
  7. 14 14
      fluentui/src/imports/FluentUI/Controls/FluAppBar.qml
  8. 123 2
      fluentui/src/imports/FluentUI/Controls/FluComboBox.qml
  9. 39 0
      fluentui/src/imports/FluentUI/Controls/FluItemDelegate.qml
  10. 720 613
      fluentui/src/imports/FluentUI/Controls/FluNavigationView.qml
  11. 3 1
      gui.py
  12. 1 1
      module/config/argument/setting-template.json
  13. 42 15
      module/config/config.py
  14. 35 0
      module/config/config_menu.py
  15. 127 0
      module/config/config_model.py
  16. 13 0
      module/config/config_state.py
  17. 2 1
      module/config/config_updater.py
  18. 17 0
      module/config/i18n/README.md
  19. BIN
      module/config/i18n/en_US.qm
  20. 77 0
      module/config/i18n/en_US.ts
  21. BIN
      module/config/i18n/zh_CN.qm
  22. 122 0
      module/config/i18n/zh_CN.ts
  23. 30 1
      module/config/utils.py
  24. BIN
      module/gui/FluentUI/fluentuiplugin.dll
  25. 12 4
      module/gui/context/add.py
  26. 122 1
      module/gui/context/process_manager.py
  27. 40 1
      module/gui/fluent_app.py
  28. 1 0
      module/gui/qml.qrc
  29. 2 0
      module/gui/qml/Component/Add.qml
  30. 526 2
      module/gui/qml/Component/Args.qml
  31. 4 0
      module/gui/qml/Component/FComboBox.qml
  32. 133 0
      module/gui/qml/Component/ModelParse.js
  33. 1 1
      module/gui/qml/Component/OverStatus.qml
  34. 17 1
      module/gui/qml/Component/ScriptItem.qml
  35. 17 9
      module/gui/qml/Component/SplitPanel.qml
  36. 5 5
      module/gui/qml/Global/ItemsFooter.qml
  37. 3 3
      module/gui/qml/Global/ItemsOriginal.qml
  38. 10 4
      module/gui/qml/Global/MainEvent.qml
  39. 1 0
      module/gui/qml/Page/Home.qml
  40. 7 2
      module/gui/qml/Page/O_Home.qml
  41. 49 6
      module/gui/qml/Page/O_Settings.qml
  42. 19 3
      module/gui/qml/Page/ScriptView.qml
  43. 35 1
      module/gui/utils.py
  44. 7 0
      module/tasks/General/config.py
  45. 10 0
      module/tasks/Restart/config.py
  46. 22 0
      module/tasks/Restart/config_scheduler.py
  47. 14 0
      module/tasks/Script/config.py
  48. 52 0
      module/tasks/Script/config_device.py
  49. 15 0
      module/tasks/Script/config_error.py
  50. 21 0
      module/tasks/Script/config_optimization.py
  51. 3 1
      requirements-in.txt
  52. 3 1
      requirements.txt
  53. 69 12
      script.py

+ 1 - 0
.gitignore

@@ -25,6 +25,7 @@ test/
 !module/gui/FluentUI/fluentuiplugin.dll
 !module/gui/FluentUI/fluentuiplugin.dll
 build-fluentui-Desktop_*/
 build-fluentui-Desktop_*/
 module/config/argument/setting.json
 module/config/argument/setting.json
+!fluentui/*
 
 
 
 
 
 

+ 89 - 22
README.md

@@ -1,5 +1,3 @@
-欢迎大家捧场
-
 ![image-20230526205041711](https://runhey-img-stg1.oss-cn-chengdu.aliyuncs.com/img2/202305262050939.png)
 ![image-20230526205041711](https://runhey-img-stg1.oss-cn-chengdu.aliyuncs.com/img2/202305262050939.png)
 
 
 ## 设计思路(其实大部分就是alas的设计)
 ## 设计思路(其实大部分就是alas的设计)
@@ -7,40 +5,109 @@
 <details>
 <details>
 <summary></summary>
 <summary></summary>
 
 
-- 核心
+### 核心
 
 
-  - 看上图左侧的+号,每一个被称为script实例,可以简单的理解为不同的模拟器配置或者是不同的任务配置,每个实例由一个config.json文件来驱动。config来管理任务的调度,配置任务的不同的参数。
-  - 这个脚本的目的是实现全程的7x24的接管游戏,去享受生活而不是在阴阳师这里上班,所以我也是有空更新。
-  - 对于每个任务的执行过程就是比较常规的截图(识别)+控制(点击啥的),在这里会选择和我[早期的设计](https://github.com/runhey/Uowl)一致,设计一个原子化的模块化的配置信息。比如说要识别某个图片会添加一份json数据来设置识图的范围、方式、识别的图片。点击的话也会有一份json数据配置点击的随机概率、范围等等。每一个操作都一份可格式化的配置信息,而不是同alas一样将识别图片和点击一起抽象成一个button。
-  - 噢对了我在写代码的时候命名上并没有针对oas,因此说你可以fork该项目使用到你的游戏脚本上
+- 多实例化:简单理解为不同的模拟器配置或者是不同的任务配置,每个实例由一个config.json文件来驱动。Config来管理任务的调度,配置任务的不同的参数。
+- 全程接管:阴阳师已经走过了颠覆时期,三次元痒痒鼠玩家本应游戏中畅行无阻,而游戏世界7x24永续航。
+- 游戏通用:我们在参考Alas时发现其同碧蓝航线有很强的耦合性,于此设计该项目将减少同阴阳师的耦合,因此你可以fork该项目使用到你的游戏脚本上
+- 操作格式化:对于每个任务的执行过程就是比较常规的截图+控制,我们选择同[早期的设计](https://github.com/runhey/Uowl)一致,设计一个原子化的模块化的配置信息。比如说要识别某个图片会添加一份json数据来设置识图的范围、方式、识别的图片。点击的话也会有一份json数据配置点击的随机概率、范围等等。每一个操作都一份可格式化的配置信息,而不是同alas一样将识别图片和点击一起抽象成一个button。
 
 
-- 部署方式:用的是batchfile + python(env+pip) + git 
 
 
-  - 具体的说就是,需要先下载一个安装包里面包含一个最小python和git环境,运行后下拉仓库,完事后安装依赖,再完事后启动gui。
 
 
+### 设计架构
 
 
-#### 设计架构
+- 部署方式:batchfile + python(env+pip) + git 。具体的说就是,需要先下载一个安装包里面包含一个最小python和git环境,运行后下拉仓库,完事后安装依赖,再完事后启动gui。
 
 
+- GUI实现:  用的是这个库[FluentUI for QML ](https://github.com/zhuzichu520/FluentUI).是用的qml来写,我想懂这个语言的人不多吧,跟python通信一个是靠注入上下文,另一个是靠zerorpc。
 
 
-- gui部分
+- 程序入口:  有两个根目录下的gui.py和script.py。而gui.py会根据配置文件config.json来实例化不同的script,script就是某个具体的脚本过程。
 
 
-  - 用的是这个库[FluentUI for QML ](https://github.com/zhuzichu520/FluentUI).是用的qml来写,我想懂这个语言的人不多吧,跟python通信一个是靠注入上下文,另一个是靠zerorpc。
+- 脚本进程:  gui启动自带一个进程,每有一个script就会继续多一个进程,单独建一个进程来提供ocr服务。一般用zerorpc来进程通信。
 
 
-- 程序入口
+- 运行过程:  gui 按钮点击后就会开始从script上启动服务。script持有一个设备device,一个配置config,一个任务task。这个时候调度器(其实就是config)会更新出running、pending and waiting tasks。选择runing的去执行,任务的执行过程就是一个大的状态机。
 
 
-  - 有两个根目录下的gui.py和script.py。而gui.py会根据配置文件config.json来实例化不同的script,script就是某个具体的脚本过程。
 
 
-- 进程
+### 模块设计
 
 
-  - gui启动自带一个进程,每有一个script就会继续多一个进程,单独建一个进程来提供ocr服务。一般用zerorpc来进程通信。
 
 
-- 运行过程
+</details>    
 
 
-  - gui 按钮点击后就会开始从script上启动服务。script持有一个设备device,一个配置config,一个任务task。这个时候调度器(其实就是config)会更新出running、pending and waiting tasks。选择runing的去执行,任务的执行过程就是一个大的状态机。
 
 
-#### 模块设计
 
 
-- config模块,主要是有一个类Config,主要是对配置的文件的接口,以及一些代码中手工配置的参数。(我还没写好从yaml到template.json和从template更新配置)
-- device模块,四个方向的功能管理模拟器,管理游戏,截图和控制
+## SETUP
+
+oas目前还在开发中,我们期待你的加入,Q群: 465946275
+
+### 浅尝即可
+
+如果单纯了解本项目,你可以下载[最新发布](https://github.com/runhey/OnmyojiAutoScript/releases),会自动安装环境。
+
+具体是:下载->解压->打开'oas.exe', 稍等一两分钟待环境安装好后即可启动
+
+### 参与开发
+
+1. 打开本项目[主仓库](https://github.com/runhey/OnmyojiAutoScript/tree/master), 点击右上角的 `Fork`,然后点击下面绿色的 `Create fork`
+
+2. 进入自己账号下的 Alas 仓库,并 `clone` 其中的 `dev` 分支到本地
+	```
+	git clone url -b dev
+	```
+
+3. 下载[最新环境包](https://github.com/runhey/OnmyojiAutoScript/releases), 解压复制`toolkit`,`deploy`两个文件夹和`consloe.bat`到本地的仓库根目录,`toolkit`里面包含python最小环境、git环境和GUI启动环境。
+
+3. 安装pip库, 安装后你可以执行`gui.py`启动进行测试
+
+   ```
+   ./toolkit/python.exe -m pip install -r requirements.txt 
+   ```
+   
+5. 此时你可以进行开发了,建议完成所有功能/任务后,再提交 `commit`, 别忘了按照下面的 `统一格式` 写上 `message`
+
+   ```
+   git commit -m 'message'
+   ```
+   >`message`的统一格式
+   >```
+   >doc(your part): your changes
+   >feat(module name): your add
+   >fix(module name): your fix
+   >```
+
+6. 完成开发后,推送本地分支到自己的仓库
+
+   ```
+   git push -u origin
+   ```
+
+   > 第一次 `push` 代码需要按照提示设置上传流(`--set-upstream`)
+
+5. 打开 [主仓库](https://github.com/runhey/OnmyojiAutoScript/tree/master)。提交一个 `pull request` (会自动携带你 `commit` 的信息),等待管理员通过。注意:要提交到 `dev` 分支上,别提交到 `master` 分支去了
+
+### 开发IDE
+
+- Pycharm
+- QtCreator:  用于qml开发
+- Linguist: Qt家的翻译器
+
+## NEXT
+
+| 进度表                                                       |
+| :----------------------------------------------------------- |
+| ✔自动化部署                                                  |
+| ✔GUI引入工程                                                 |
+| ✔config读写参数字段                                          |
+| 🔨优化window截图+控制                                         |
+| 🔨投屏到OAS                                                   |
+| 🔨操作格式化json生成工具:可以从用户界面简单操作生成维护数据(包括图片匹配,点击操作,滑动操作,ocr识别等等) |
+| 📆Atom: 对于上一条数据的接口                                  |
+| 📆实现ocr单独进程                                             |
+| 📆到此我们可以(读参数)、(对游戏截屏控制)、(操控数据)。实现第一个脚本任务如挖土 |
+| 📆重写device(从alas复制过来需要解耦)                          |
+|                                                              |
+
+| **更多**        | 难题             |
+| --------------- | ---------------- |
+| 📆实现更多的任务 | 如何输出Log到GUI |
+| 📆建立任务调度   | 优化速度         |
+|                 |                  |
 
 
-</details>    

+ 29 - 43
config/template.json

@@ -1,47 +1,33 @@
 {
 {
-    "Script":{
-        "Device":{
-            "Serial": "127.0.0.1:7555",
-            "Handle":"auto",
-            "PackageName":"auto",
-            "ScreenshotMethod": "ADB",
-            "ControlMethod": "minitouch",
-            "AdbRestart": false
-        },
-        "Error": {
-            "HandleError": true,
-            "SaveError": true,
-            "ScreenshotLength": 1
-          },
-        "Optimization": {
-              "ScreenshotInterval": 0.3,
-              "CombatScreenshotInterval": 1.0,
-              "TaskHoardingDuration": 0,
-              "WhenTaskQueueEmpty": "goto_home"
-    	}
+  "script": {
+    "device": {
+      "serial": "127.0.0.1:7555",
+      "handle": "auto",
+      "package_name": "auto",
+      "screenshot_method": "window_background",
+      "control_method": "window_message",
+      "adb_restart": false
     },
     },
-    "General": {
-        "Retirement": {
-          "Enable": true,
-          "RetireMode": "one_click_retire",
-          "RetireAmount": "retire_all",
-          "EnhanceFavourite": false,
-          "EnhanceFilter": null,
-          "EnhanceCheckPerCategory": 2,
-          "OldRetireN": true,
-          "OldRetireR": true,
-          "OldRetireSR": false,
-          "OldRetireSSR": false
-        }
-      },
-    "Restart": {
-        "Scheduler": {
-            "Enable": false,
-            "NextRun": "2021-01-01 00:00:00",
-            "Command": "Restart",
-            "SuccessInterval": 0,
-            "FailureInterval": 0,
-            "ServerUpdate": "00:00"
-        }
+    "error": {
+      "handle_error": false,
+      "save_error": false,
+      "screenshot_length": 1
+    },
+    "optimization": {
+      "screenshot_interval": 0.3,
+      "combat_screenshot_interval": 1.0,
+      "task_hoarding_duration": 0,
+      "when_task_queue_empty": "goto_home"
+    }
+  },
+  "restart": {
+    "scheduler": {
+      "enable": false,
+      "next_run": "2023-01-01 00:00:00",
+      "command": "Restart",
+      "success_interval": 0,
+      "failure_interval": 0,
+      "server_update": "00:00"
     }
     }
+  }
 }
 }

+ 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')
 
 
 
 

+ 1 - 1
fluentui/README.md

@@ -63,7 +63,7 @@ FluText{
 FluText{
 FluText{
     id: nav_app_bar_pane_title
     id: nav_app_bar_pane_title
     Layout.alignment: Qt.AlignVCenter
     Layout.alignment: Qt.AlignVCenter
-    text:lang.home
+    text: ''
     Layout.leftMargin: 2
     Layout.leftMargin: 2
     font: FluTextStyle.Body
     font: FluTextStyle.Body
 }
 }

+ 14 - 14
fluentui/src/imports/FluentUI/Controls/FluAppBar.qml

@@ -83,20 +83,20 @@ Rectangle{
             }
             }
         }
         }
 
 
-        FluIconButton{
-            width: 40
-            height: 30
-            iconSource : FluentIcons.Down
-            Layout.alignment: Qt.AlignVCenter
-            iconSize: 11
-            text: "隐藏到系统托盘"
-            radius: 0
-            iconColor: root.textColor
-            color: hovered ? minimizeHoverColor : minimizeNormalColor
-            onClicked: {
-                d.win.hide()
-            }
-        }
+        // FluIconButton{
+        //     width: 40
+        //     height: 30
+        //     iconSource : FluentIcons.Down
+        //     Layout.alignment: Qt.AlignVCenter
+        //     iconSize: 11
+        //     text: "隐藏到系统托盘"
+        //     radius: 0
+        //     iconColor: root.textColor
+        //     color: hovered ? minimizeHoverColor : minimizeNormalColor
+        //     onClicked: {
+        //         d.win.hide()
+        //     }
+        // }
         FluIconButton{
         FluIconButton{
             width: 40
             width: 40
             height: 30
             height: 30

+ 123 - 2
fluentui/src/imports/FluentUI/Controls/FluComboBox.qml

@@ -1,7 +1,128 @@
-import QtQuick
+import QtQuick
 import QtQuick.Controls
 import QtQuick.Controls
+import QtQuick.Controls.Basic
 import FluentUI
 import FluentUI
+import QtQuick.Templates as T
 
 
-Item {
+ComboBox {
+    id: control
+    property bool disabled: false
+    property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
+    property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
+    property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
+    implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+                            implicitContentWidth + leftPadding + rightPadding)
+    implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+                             implicitContentHeight + topPadding + bottomPadding,
+                             implicitIndicatorHeight + topPadding + bottomPadding)
 
 
+    leftPadding: padding + (!control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing)
+    rightPadding: padding + (control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing)
+    enabled: !disabled
+    delegate: FluItemDelegate {
+        width: ListView.view.width
+        text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData
+        palette.text: control.palette.text
+        palette.highlightedText: control.palette.highlightedText
+        font.weight: control.currentIndex === index ? Font.DemiBold : Font.Normal
+        highlighted: control.highlightedIndex === index
+        hoverEnabled: control.hoverEnabled
+    }
+
+    indicator: FluIcon {
+        x: control.mirrored ? control.padding : control.width - width - control.padding
+        y: control.topPadding + (control.availableHeight - height) / 2
+        width: 28
+        iconSource:FluentIcons.ChevronDown
+        iconSize: 15
+        opacity: enabled ? 1 : 0.3
+    }
+
+    contentItem: T.TextField {
+        property bool disabled: !control.editable
+        leftPadding: !control.mirrored ? 12 : control.editable && activeFocus ? 3 : 1
+        rightPadding: control.mirrored ? 12 : control.editable && activeFocus ? 3 : 1
+        topPadding: 6 - control.padding
+        bottomPadding: 6 - control.padding
+        renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
+        selectionColor: FluTheme.primaryColor.lightest
+        text: control.editable ? control.editText : control.displayText
+        enabled: control.editable
+        autoScroll: control.editable
+        font:FluTextStyle.Body
+        readOnly: control.down
+        color: FluTheme.dark ?  Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
+        inputMethodHints: control.inputMethodHints
+        validator: control.validator
+        selectByMouse: true
+        verticalAlignment: Text.AlignVCenter
+        leftInset:1
+        topInset:1
+        bottomInset:1
+        rightInset:1
+        background: FluTextBoxBackground{
+            border.width: 0
+            inputItem: contentItem
+        }
+    }
+
+    background: Rectangle {
+        implicitWidth: 140
+        implicitHeight: 28
+        border.color: FluTheme.dark ? "#505050" : "#DFDFDF"
+        border.width: 1
+        visible: !control.flat || control.down
+        radius: 4
+        FluFocusRectangle{
+            visible: control.visualFocus
+            radius:8
+        }
+        color:{
+            if(disabled){
+                return disableColor
+            }
+            return hovered ? hoverColor :normalColor
+        }
+    }
+
+    popup: T.Popup {
+        y: control.height
+        width: control.width
+        height: Math.min(contentItem.implicitHeight, control.Window.height - topMargin - bottomMargin)
+        topMargin: 6
+        bottomMargin: 6
+        contentItem: ListView {
+            clip: true
+            implicitHeight: contentHeight
+            model: control.delegateModel
+            currentIndex: control.highlightedIndex
+            highlightMoveDuration: 0
+            T.ScrollIndicator.vertical: ScrollIndicator { }
+        }
+        enter: Transition {
+            NumberAnimation {
+                property: "opacity"
+                from:0
+                to:1
+                duration: 83
+            }
+        }
+        exit:Transition {
+            NumberAnimation {
+                property: "opacity"
+                from:1
+                to:0
+                duration: 83
+            }
+        }
+        background:Rectangle{
+            color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(249/255,249/255,249/255,1)
+            border.color: FluTheme.dark ? Window.active ? Qt.rgba(55/255,55/255,55/255,1):Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
+            border.width: 1
+            radius: 5
+            FluShadow{
+                radius: 5
+            }
+        }
+    }
 }
 }

+ 39 - 0
fluentui/src/imports/FluentUI/Controls/FluItemDelegate.qml

@@ -0,0 +1,39 @@
+import QtQuick
+import QtQuick.Controls.Basic
+import QtQuick.Templates as T
+import FluentUI
+
+T.ItemDelegate {
+    id: control
+
+    implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+                            implicitContentWidth + leftPadding + rightPadding)
+    implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+                             implicitContentHeight + topPadding + bottomPadding,
+                             implicitIndicatorHeight + topPadding + bottomPadding)
+
+    padding: 12
+    spacing: 8
+
+    icon.width: 24
+    icon.height: 24
+    icon.color: control.palette.text
+
+    contentItem: FluText {
+        text: control.text
+        font: control.font
+    }
+
+    background: Rectangle {
+        implicitWidth: 100
+        implicitHeight: 40
+        color:{
+            if(FluTheme.dark){
+                return Qt.rgba(1,1,1,0.05)
+            }else{
+                return Qt.rgba(0,0,0,0.05)
+            }
+        }
+        visible: control.down || control.highlighted || control.visualFocus
+    }
+}

+ 720 - 613
fluentui/src/imports/FluentUI/Controls/FluNavigationView.qml

@@ -6,7 +6,7 @@ import QtQuick.Layouts
 import FluentUI
 import FluentUI
 
 
 Item {
 Item {
-
+    id: control
     enum DisplayMode {
     enum DisplayMode {
         Open,
         Open,
         Compact,
         Compact,
@@ -14,918 +14,1025 @@ Item {
         Auto
         Auto
     }
     }
 
 
+    property Component autoSuggestBox
+    property int displayMode: FluNavigationView.Auto
+    property FluObject footerItems
+    property FluObject items
     property url logo
     property url logo
     property string title: ""
     property string title: ""
-    property FluObject items
-    property FluObject footerItems
-    property int displayMode: FluNavigationView.Auto
-    property Component  autoSuggestBox
-    property var window : {
-        if(Window.window == null)
-            return null
-        return Window.window
+    property var window: {
+        if (Window.window == null)
+            return null;
+        return Window.window;
+    }
+
+    function collapseAll() {
+        for (var i = 0; i < nav_list.model.length; i++) {
+            var item = nav_list.model[i];
+            if (item instanceof FluPaneItemExpander) {
+                item.isExpand = false;
+            }
+        }
+    }
+    //閫氳繃configName鎵惧埌index
+    function configName2index(configName) {
+        if (nav_swipe.count <= 0) {
+            return -1;
+        }
+        for (var i = 0; i < nav_swipe.count; i++) {
+            var item = nav_swipe.itemAt(i);
+            if (item.configName === configName) {
+                return i;
+            }
+        }
+        return -1;
+    }
+    function getCurrentIndex() {
+        return nav_list.currentIndex;
+    }
+    function getItems() {
+        return nav_list.model;
+    }
+    function push(url) {
+        var component = Qt.createComponent(url);
+        if (component.status === Component.Ready) {
+            var object = component.createObject(nav_swipe);
+            if (object !== null) {
+                nav_swipe.addItem(object);
+                nav_swipe.setCurrentIndex(nav_swipe.count - 1);
+            } else // 鍒涘缓澶辫触
+            {
+            }
+        } else // 缁勪欢鍔犺浇澶辫触
+        {
+        }
     }
     }
 
 
-    id:control
+    // z閽堝鑴氭湰鐨勬坊鍔犵殑
+    function pushScript(url, configName) {
+        var index = configName2index(configName);
+        if (index === -1) {
+            //濡傛灉鎵句笉鍒版垨鑰呭帇鏍硅繕娌℃湁Page,灏卞垱寤哄苟鍘嬪叆
+            var component = Qt.createComponent(url);
+            if (component.status === Component.Ready) {
+                var object = component.createObject(nav_swipe);
+                if (object !== null) {
+                    object.configName = configName;
+                    if(configName === "home"){
+                        nav_swipe.insertItem(0, object)
+                        nav_swipe.setCurrentIndex(0)
+                    }else if(configName === "settings"){
+                        nav_swipe.addItem(object);
+                        nav_swipe.setCurrentIndex(nav_swipe.count - 1);
+                    }else{
+                        var settings_index = configName2index("settings")
+                        if(settings_index !== -1){
+                            nav_swipe.insertItem(settings_index, object)
+                            nav_swipe.setCurrentIndex(settings_index);
+                        }else{
+                           nav_swipe.addItem(object);
+                            nav_swipe.setCurrentIndex(nav_swipe.count - 1);
+                        }
+                    }
+
+
+                } else {
+                    // 鍒涘缓澶辫触
+                    console.debug('瀵硅薄鍒涘缓澶辫触');
+                }
+            } else {
+                // 缁勪欢鍔犺浇澶辫触
+                console.debug('缁勪欢鍔犺浇澶辫触');
+            }
+        } else {
+            // 鎵惧緱鍒扮洿鎺ヨ缃埌褰撳墠鐨�
+            nav_swipe.setCurrentIndex(index);
+        }
+    }
+    function setCurrentIndex(index) {
+        nav_list.currentIndex = index;
+    }
+    function startPageByItem(data) {
+        var items = getItems();
+        for (var i = 0; i < items.length; i++) {
+            var item = items[i];
+            if (item.key === data.key) {
+                if (getCurrentIndex() === i) {
+                    return;
+                }
+                setCurrentIndex(i);
+                if (item.parent && !d.isCompactAndNotPanel) {
+                    item.parent.isExpand = true;
+                }
+                return;
+            }
+        }
+    }
+
+    QtObject {
+        id: d
 
 
-    QtObject{
-        id:d
-        property bool enableStack: true
         property int displayMode: {
         property int displayMode: {
-            if(control.displayMode !==FluNavigationView.Auto){
-                return control.displayMode
+            if (control.displayMode !== FluNavigationView.Auto) {
+                return control.displayMode;
             }
             }
-            if(control.width<=700){
-                return FluNavigationView.Minimal
-            }else if(control.width<=900){
-                return FluNavigationView.Compact
-            }else{
-                return FluNavigationView.Open
+            if (control.width <= 700) {
+                return FluNavigationView.Minimal;
+            } else if (control.width <= 900) {
+                return FluNavigationView.Compact;
+            } else {
+                return FluNavigationView.Open;
             }
             }
         }
         }
-        property var stackItems: []
         property bool enableNavigationPanel: false
         property bool enableNavigationPanel: false
+        property bool enableStack: true
         property bool isCompact: d.displayMode === FluNavigationView.Compact
         property bool isCompact: d.displayMode === FluNavigationView.Compact
-        property bool isMinimal: d.displayMode === FluNavigationView.Minimal
+        property bool isCompactAndNotPanel: d.displayMode === FluNavigationView.Compact && !d.enableNavigationPanel
         property bool isCompactAndPanel: d.displayMode === FluNavigationView.Compact && d.enableNavigationPanel
         property bool isCompactAndPanel: d.displayMode === FluNavigationView.Compact && d.enableNavigationPanel
-        property bool isCompactAndNotPanel:d.displayMode === FluNavigationView.Compact && !d.enableNavigationPanel
+        property bool isMinimal: d.displayMode === FluNavigationView.Minimal
         property bool isMinimalAndPanel: d.displayMode === FluNavigationView.Minimal && d.enableNavigationPanel
         property bool isMinimalAndPanel: d.displayMode === FluNavigationView.Minimal && d.enableNavigationPanel
+        property var stackItems: []
 
 
-        onIsCompactAndNotPanelChanged: {
-            collapseAll()
-        }
-
-        onDisplayModeChanged: {
-            if(d.displayMode === FluNavigationView.Compact){
-                collapseAll()
-            }
-            if(d.displayMode === FluNavigationView.Minimal){
-                anim_layout_list_x.enabled = false
-                d.enableNavigationPanel = false
-                timer_anim_x_enable.restart()
-            }
-        }
-
-        function handleItems(){
-            var idx = 0
-            var data = []
-            if(items){
-                for(var i=0;i<items.children.length;i++){
-                    var item = items.children[i]
-                    item.idx = idx
-                    data.push(item)
-                    idx++
-                    if(item instanceof FluPaneItemExpander){
-                        for(var j=0;j<item.children.length;j++){
-                            var itemChild = item.children[j]
-                            itemChild.parent = item
-                            itemChild.idx = idx
-                            data.push(itemChild)
-                            idx++
+        function handleItems() {
+            var idx = 0;
+            var data = [];
+            if (items) {
+                for (var i = 0; i < items.children.length; i++) {
+                    var item = items.children[i];
+                    item.idx = idx;
+                    data.push(item);
+                    idx++;
+                    if (item instanceof FluPaneItemExpander) {
+                        for (var j = 0; j < item.children.length; j++) {
+                            var itemChild = item.children[j];
+                            itemChild.parent = item;
+                            itemChild.idx = idx;
+                            data.push(itemChild);
+                            idx++;
                         }
                         }
                     }
                     }
                 }
                 }
-                if(footerItems){
+                if (footerItems) {
                     var comEmpty = Qt.createComponent("FluPaneItemEmpty.qml");
                     var comEmpty = Qt.createComponent("FluPaneItemEmpty.qml");
-                    for(var k=0;k<footerItems.children.length;k++){
-                        var itemFooter = footerItems.children[k]
+                    for (var k = 0; k < footerItems.children.length; k++) {
+                        var itemFooter = footerItems.children[k];
                         if (comEmpty.status === Component.Ready) {
                         if (comEmpty.status === Component.Ready) {
-                            var objEmpty = comEmpty.createObject(items,{idx:idx});
+                            var objEmpty = comEmpty.createObject(items, {
+                                    "idx": idx
+                                });
                             itemFooter.idx = idx;
                             itemFooter.idx = idx;
-                            data.push(objEmpty)
-                            idx++
+                            data.push(objEmpty);
+                            idx++;
                         }
                         }
                     }
                     }
                 }
                 }
             }
             }
-            return data
+            return data;
         }
         }
-    }
 
 
-    Component{
-        id:com_panel_item_empty
-        Item{
+        onDisplayModeChanged: {
+            if (d.displayMode === FluNavigationView.Compact) {
+                collapseAll();
+            }
+            if (d.displayMode === FluNavigationView.Minimal) {
+                anim_layout_list_x.enabled = false;
+                d.enableNavigationPanel = false;
+                timer_anim_x_enable.restart();
+            }
+        }
+        onIsCompactAndNotPanelChanged: {
+            collapseAll();
+        }
+    }
+    Component {
+        id: com_panel_item_empty
+        Item {
             visible: false
             visible: false
         }
         }
     }
     }
-
-    Component{
-        id:com_panel_item_separatorr
-        FluDivider{
-            width: layout_list.width
+    Component {
+        id: com_panel_item_separatorr
+        FluDivider {
             height: {
             height: {
-                if(model.parent){
-                    return model.parent.isExpand ? 1 : 0
+                if (model.parent) {
+                    return model.parent.isExpand ? 1 : 0;
                 }
                 }
-                return 1
+                return 1;
             }
             }
-            Behavior on height {
-                NumberAnimation{
+            width: layout_list.width
+
+            Behavior on height  {
+                NumberAnimation {
                     duration: 167
                     duration: 167
+                    easing.bezierCurve: [0, 0, 0, 1]
                     easing.type: Easing.BezierSpline
                     easing.type: Easing.BezierSpline
-                    easing.bezierCurve: [ 0, 0, 0, 1 ]
                 }
                 }
             }
             }
         }
         }
     }
     }
-
-    Component{
-        id:com_panel_item_header
-        Item{
+    Component {
+        id: com_panel_item_header
+        Item {
             height: {
             height: {
-                if(model.parent){
-                    return model.parent.isExpand ? 30 : 0
+                if (model.parent) {
+                    return model.parent.isExpand ? 30 : 0;
                 }
                 }
-                return 30
+                return 30;
             }
             }
-            Behavior on height {
-                NumberAnimation{
+            width: layout_list.width
+
+            Behavior on height  {
+                NumberAnimation {
                     duration: 167
                     duration: 167
+                    easing.bezierCurve: [0, 0, 0, 1]
                     easing.type: Easing.BezierSpline
                     easing.type: Easing.BezierSpline
-                    easing.bezierCurve: [ 0, 0, 0, 1 ]
                 }
                 }
             }
             }
-            width: layout_list.width
-            FluText{
-                text:model.title
+
+            FluText {
                 font: FluTextStyle.BodyStrong
                 font: FluTextStyle.BodyStrong
-                anchors{
+                text: model.title
+
+                anchors {
                     bottom: parent.bottom
                     bottom: parent.bottom
-                    left:parent.left
+                    left: parent.left
                     leftMargin: 10
                     leftMargin: 10
                 }
                 }
             }
             }
         }
         }
     }
     }
-
-    Component{
-        id:com_panel_item_expander
-        Item{
+    Component {
+        id: com_panel_item_expander
+        Item {
             height: 38
             height: 38
             width: layout_list.width
             width: layout_list.width
-            Rectangle{
+
+            Rectangle {
+                color: {
+                    if (FluTheme.dark) {
+                        if ((nav_list.currentIndex === idx) && type === 0) {
+                            return Qt.rgba(1, 1, 1, 0.06);
+                        }
+                        if (item_mouse.containsMouse) {
+                            return Qt.rgba(1, 1, 1, 0.03);
+                        }
+                        return Qt.rgba(0, 0, 0, 0);
+                    } else {
+                        if (nav_list.currentIndex === idx && type === 0) {
+                            return Qt.rgba(0, 0, 0, 0.06);
+                        }
+                        if (item_mouse.containsMouse) {
+                            return Qt.rgba(0, 0, 0, 0.03);
+                        }
+                        return Qt.rgba(0, 0, 0, 0);
+                    }
+                }
                 radius: 4
                 radius: 4
-                anchors{
-                    top: parent.top
+
+                anchors {
                     bottom: parent.bottom
                     bottom: parent.bottom
-                    left: parent.left
-                    right: parent.right
-                    topMargin: 2
                     bottomMargin: 2
                     bottomMargin: 2
+                    left: parent.left
                     leftMargin: 6
                     leftMargin: 6
+                    right: parent.right
                     rightMargin: 6
                     rightMargin: 6
+                    top: parent.top
+                    topMargin: 2
                 }
                 }
-                Rectangle{
-                    width: 3
+                Rectangle {
+                    color: FluTheme.primaryColor.dark
                     height: 18
                     height: 18
                     radius: 1.5
                     radius: 1.5
-                    color: FluTheme.primaryColor.dark
                     visible: {
                     visible: {
-                        for(var i=0;i<model.children.length;i++){
-                            var item = model.children[i]
-                            if(item.idx === nav_list.currentIndex && !model.isExpand){
-                                return true
+                        for (var i = 0; i < model.children.length; i++) {
+                            var item = model.children[i];
+                            if (item.idx === nav_list.currentIndex && !model.isExpand) {
+                                return true;
                             }
                             }
                         }
                         }
-                        return false
+                        return false;
                     }
                     }
-                    anchors{
+                    width: 3
+
+                    anchors {
                         verticalCenter: parent.verticalCenter
                         verticalCenter: parent.verticalCenter
                     }
                     }
                 }
                 }
-                FluIcon{
-                    rotation: model.isExpand?0:180
-                    iconSource:FluentIcons.ChevronUp
+                FluIcon {
                     iconSize: 15
                     iconSize: 15
-                    anchors{
-                        verticalCenter: parent.verticalCenter
-                        right: parent.right
-                        rightMargin: 12
-                    }
+                    iconSource: FluentIcons.ChevronUp
                     opacity: {
                     opacity: {
-                        if(d.isCompactAndNotPanel){
-                            return false
+                        if (d.isCompactAndNotPanel) {
+                            return false;
                         }
                         }
-                        return true
+                        return true;
                     }
                     }
-                    visible:opacity
-                    Behavior on opacity {
-                        NumberAnimation{
+                    rotation: model.isExpand ? 0 : 180
+                    visible: opacity
+
+                    Behavior on opacity  {
+                        NumberAnimation {
                             duration: 83
                             duration: 83
                         }
                         }
                     }
                     }
-                    Behavior on rotation {
-                        NumberAnimation{
+                    Behavior on rotation  {
+                        NumberAnimation {
                             duration: 83
                             duration: 83
                         }
                         }
                     }
                     }
+
+                    anchors {
+                        right: parent.right
+                        rightMargin: 12
+                        verticalCenter: parent.verticalCenter
+                    }
                 }
                 }
-                MouseArea{
-                    id:item_mouse
-                    hoverEnabled: true
+                MouseArea {
+                    id: item_mouse
                     anchors.fill: parent
                     anchors.fill: parent
+                    hoverEnabled: true
+
                     onClicked: {
                     onClicked: {
-                        if(d.isCompactAndNotPanel){
-                            control_popup.showPopup(Qt.point(50,mapToItem(control,0,0).y),model.children)
-                            return
+                        if (d.isCompactAndNotPanel) {
+                            control_popup.showPopup(Qt.point(50, mapToItem(control, 0, 0).y), model.children);
+                            return;
                         }
                         }
-                        model.isExpand = !model.isExpand
+                        model.isExpand = !model.isExpand;
                     }
                     }
                 }
                 }
-                color: {
-                    if(FluTheme.dark){
-                        if((nav_list.currentIndex === idx)&&type===0){
-                            return Qt.rgba(1,1,1,0.06)
-                        }
-                        if(item_mouse.containsMouse){
-                            return Qt.rgba(1,1,1,0.03)
-                        }
-                        return Qt.rgba(0,0,0,0)
-                    }else{
-                        if(nav_list.currentIndex === idx&&type===0){
-                            return Qt.rgba(0,0,0,0.06)
-                        }
-                        if(item_mouse.containsMouse){
-                            return Qt.rgba(0,0,0,0.03)
-                        }
-                        return Qt.rgba(0,0,0,0)
-                    }
-                }
-                Component{
-                    id:com_icon
-                    FluIcon{
+                Component {
+                    id: com_icon
+                    FluIcon {
+                        iconSize: 15
                         iconSource: {
                         iconSource: {
-                            if(model.icon){
-                                return model.icon
+                            if (model.icon) {
+                                return model.icon;
                             }
                             }
-                            return 0
+                            return 0;
                         }
                         }
-                        iconSize: 15
                     }
                     }
                 }
                 }
-
-                Item{
-                    id:item_icon
-                    width: 30
+                Item {
+                    id: item_icon
                     height: 30
                     height: 30
-                    anchors{
-                        verticalCenter: parent.verticalCenter
-                        left:parent.left
+                    width: 30
+
+                    anchors {
+                        left: parent.left
                         leftMargin: 3
                         leftMargin: 3
+                        verticalCenter: parent.verticalCenter
                     }
                     }
-                    Loader{
+                    Loader {
                         anchors.centerIn: parent
                         anchors.centerIn: parent
                         sourceComponent: {
                         sourceComponent: {
-                            if(model.cusIcon){
-                                return model.cusIcon
+                            if (model.cusIcon) {
+                                return model.cusIcon;
                             }
                             }
-                            return com_icon
+                            return com_icon;
                         }
                         }
                     }
                     }
                 }
                 }
-                FluText{
-                    id:item_title
-                    text:model.title
+                FluText {
+                    id: item_title
+                    color: {
+                        if (item_mouse.pressed) {
+                            return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120;
+                        }
+                        return FluTheme.dark ? FluColors.White : FluColors.Grey220;
+                    }
                     opacity: {
                     opacity: {
-                        if(d.isCompactAndNotPanel){
-                            return false
+                        if (d.isCompactAndNotPanel) {
+                            return false;
                         }
                         }
-                        return true
+                        return true;
                     }
                     }
-                    visible:opacity
-                    Behavior on opacity {
-                        NumberAnimation{
+                    text: model.title
+                    visible: opacity
+
+                    Behavior on opacity  {
+                        NumberAnimation {
                             duration: 83
                             duration: 83
                         }
                         }
                     }
                     }
-                    anchors{
+
+                    anchors {
+                        left: item_icon.right
                         verticalCenter: parent.verticalCenter
                         verticalCenter: parent.verticalCenter
-                        left:item_icon.right
-                    }
-                    color:{
-                        if(item_mouse.pressed){
-                            return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120
-                        }
-                        return FluTheme.dark ? FluColors.White : FluColors.Grey220
                     }
                     }
                 }
                 }
             }
             }
         }
         }
     }
     }
+    Component {
+        id: com_panel_item
+        Item {
+            clip: true
+            height: {
+                if (model.parent) {
+                    return model.parent.isExpand ? 38 : 0;
+                }
+                return 38;
+            }
+            width: layout_list.width
 
 
-    Component{
-        id:com_panel_item
-        Item{
-            Behavior on height {
-                NumberAnimation{
+            Behavior on height  {
+                NumberAnimation {
                     duration: 167
                     duration: 167
+                    easing.bezierCurve: [0, 0, 0, 1]
                     easing.type: Easing.BezierSpline
                     easing.type: Easing.BezierSpline
-                    easing.bezierCurve: [ 0, 0, 0, 1 ]
                 }
                 }
             }
             }
-            clip: true
-            height: {
-                if(model.parent){
-                    return model.parent.isExpand ? 38 : 0
+
+            Rectangle {
+                color: {
+                    if (FluTheme.dark) {
+                        if (type === 0) {
+                            if (nav_list.currentIndex === idx) {
+                                return Qt.rgba(1, 1, 1, 0.06);
+                            }
+                        } else {
+                            if (nav_list.currentIndex === (nav_list.count - layout_footer.count + idx)) {
+                                return Qt.rgba(1, 1, 1, 0.06);
+                            }
+                        }
+                        if (item_mouse.containsMouse) {
+                            return Qt.rgba(1, 1, 1, 0.03);
+                        }
+                        return Qt.rgba(0, 0, 0, 0);
+                    } else {
+                        if (type === 0) {
+                            if (nav_list.currentIndex === idx) {
+                                return Qt.rgba(0, 0, 0, 0.06);
+                            }
+                        } else {
+                            if (nav_list.currentIndex === (nav_list.count - layout_footer.count + idx)) {
+                                return Qt.rgba(0, 0, 0, 0.06);
+                            }
+                        }
+                        if (item_mouse.containsMouse) {
+                            return Qt.rgba(0, 0, 0, 0.03);
+                        }
+                        return Qt.rgba(0, 0, 0, 0);
+                    }
                 }
                 }
-                return 38
-            }
-            width: layout_list.width
-            Rectangle{
                 radius: 4
                 radius: 4
-                anchors{
-                    top: parent.top
+
+                anchors {
                     bottom: parent.bottom
                     bottom: parent.bottom
-                    left: parent.left
-                    right: parent.right
-                    topMargin: 2
                     bottomMargin: 2
                     bottomMargin: 2
+                    left: parent.left
                     leftMargin: 6
                     leftMargin: 6
+                    right: parent.right
                     rightMargin: 6
                     rightMargin: 6
+                    top: parent.top
+                    topMargin: 2
                 }
                 }
-                MouseArea{
-                    id:item_mouse
-                    hoverEnabled: true
+                MouseArea {
+                    id: item_mouse
                     anchors.fill: parent
                     anchors.fill: parent
+                    hoverEnabled: true
+
                     onClicked: {
                     onClicked: {
-                        if(type === 0){
-                            if(model.tapFunc){
-                                model.tapFunc()
-                            }else{
-                                nav_list.currentIndex = idx
-                                layout_footer.currentIndex = -1
-                                if(d.isMinimal || d.isCompact){
-                                    d.enableNavigationPanel = false
+                        if (type === 0) {
+                            if (model.tapFunc) {
+                                model.tapFunc();
+                            } else {
+                                nav_list.currentIndex = idx;
+                                layout_footer.currentIndex = -1;
+                                if (d.isMinimal || d.isCompact) {
+                                    d.enableNavigationPanel = false;
                                 }
                                 }
                             }
                             }
-                        }else{
-                            if(model.tapFunc){
-                                model.tapFunc()
-                            }else{
-                                model.tap()
-                                d.stackItems.push(model)
-                                nav_list.currentIndex = nav_list.count-layout_footer.count+idx
-                                layout_footer.currentIndex = idx
-                                if(d.isMinimal || d.isCompact){
-                                    d.enableNavigationPanel = false
+                        } else {
+                            if (model.tapFunc) {
+                                model.tapFunc();
+                            } else {
+                                model.tap();
+                                d.stackItems.push(model);
+                                nav_list.currentIndex = nav_list.count - layout_footer.count + idx;
+                                layout_footer.currentIndex = idx;
+                                if (d.isMinimal || d.isCompact) {
+                                    d.enableNavigationPanel = false;
                                 }
                                 }
                             }
                             }
                         }
                         }
-                    nav_app_bar_pane_title.text = model.title
+                        nav_app_bar_pane_title.text = model.title;
                     }
                     }
                 }
                 }
-                color: {
-                    if(FluTheme.dark){
-                        if(type===0){
-                            if(nav_list.currentIndex === idx){
-                                return Qt.rgba(1,1,1,0.06)
-                            }
-                        }else{
-                            if(nav_list.currentIndex === (nav_list.count-layout_footer.count+idx)){
-                                return Qt.rgba(1,1,1,0.06)
-                            }
-                        }
-                        if(item_mouse.containsMouse){
-                            return Qt.rgba(1,1,1,0.03)
-                        }
-                        return Qt.rgba(0,0,0,0)
-                    }else{
-                        if(type===0){
-                            if(nav_list.currentIndex === idx){
-                                return Qt.rgba(0,0,0,0.06)
-                            }
-                        }else{
-                            if(nav_list.currentIndex === (nav_list.count-layout_footer.count+idx)){
-                                return Qt.rgba(0,0,0,0.06)
-                            }
-                        }
-                        if(item_mouse.containsMouse){
-                            return Qt.rgba(0,0,0,0.03)
-                        }
-                        return Qt.rgba(0,0,0,0)
-                    }
-                }
-                Component{
-                    id:com_icon
-                    FluIcon{
+                Component {
+                    id: com_icon
+                    FluIcon {
+                        iconSize: 15
                         iconSource: {
                         iconSource: {
-                            if(model.icon){
-                                return model.icon
+                            if (model.icon) {
+                                return model.icon;
                             }
                             }
-                            return 0
+                            return 0;
                         }
                         }
-                        iconSize: 15
                     }
                     }
                 }
                 }
-
-                Item{
-                    id:item_icon
-                    width: 30
+                Item {
+                    id: item_icon
                     height: 30
                     height: 30
-                    anchors{
-                        verticalCenter: parent.verticalCenter
-                        left:parent.left
+                    width: 30
+
+                    anchors {
+                        left: parent.left
                         leftMargin: 3
                         leftMargin: 3
+                        verticalCenter: parent.verticalCenter
                     }
                     }
-                    Loader{
+                    Loader {
                         anchors.centerIn: parent
                         anchors.centerIn: parent
                         sourceComponent: {
                         sourceComponent: {
-                            if(model.cusIcon){
-                                return model.cusIcon
+                            if (model.cusIcon) {
+                                return model.cusIcon;
                             }
                             }
-                            return com_icon
+                            return com_icon;
                         }
                         }
                     }
                     }
                 }
                 }
-
-                FluText{
-                    id:item_title
-                    text:model.title
-                    opacity: {
-                        if(d.isCompactAndNotPanel){
-                            return false
+                FluText {
+                    id: item_title
+                    color: {
+                        if (item_mouse.pressed) {
+                            return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120;
                         }
                         }
-                        return true
+                        return FluTheme.dark ? FluColors.White : FluColors.Grey220;
                     }
                     }
-                    visible:opacity
-                    Behavior on opacity {
-                        NumberAnimation{
-                            duration: 83
+                    opacity: {
+                        if (d.isCompactAndNotPanel) {
+                            return false;
                         }
                         }
+                        return true;
                     }
                     }
-                    color:{
-                        if(item_mouse.pressed){
-                            return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120
+                    text: model.title
+                    visible: opacity
+
+                    Behavior on opacity  {
+                        NumberAnimation {
+                            duration: 83
                         }
                         }
-                        return FluTheme.dark ? FluColors.White : FluColors.Grey220
                     }
                     }
-                    anchors{
+
+                    anchors {
+                        left: item_icon.right
                         verticalCenter: parent.verticalCenter
                         verticalCenter: parent.verticalCenter
-                        left:item_icon.right
                     }
                     }
                 }
                 }
             }
             }
         }
         }
     }
     }
-
-
     Item {
     Item {
-        id:nav_app_bar
-        width: parent.width
+        id: nav_app_bar
         height: 40
         height: 40
-        z:999
-        RowLayout{
-            height:parent.height
+        width: parent.width
+        z: 999
+
+        RowLayout {
+            height: parent.height
             spacing: 0
             spacing: 0
-//            FluIconButton{
-//                iconSource: FluentIcons.ChromeBack
-//                Layout.leftMargin: 5
-//                Layout.preferredWidth: 40
-//                Layout.preferredHeight: 40
-//                Layout.alignment: Qt.AlignVCenter
-//                disabled:  nav_swipe.depth === 1
-//                iconSize: 13
-//                onClicked: {
-//                    nav_swipe.pop()
-//                    d.stackItems.pop()
-//                    var item = d.stackItems[d.stackItems.length-1]
-//                    d.enableStack = false
-//                    if(item.idx<(nav_list.count - layout_footer.count)){
-//                        layout_footer.currentIndex = -1
-//                    }else{
-//                        console.debug(item.idx-(nav_list.count-layout_footer.count))
-//                        layout_footer.currentIndex = item.idx-(nav_list.count-layout_footer.count)
-//                    }
-//                    nav_list.currentIndex = item.idx
-//                    d.enableStack = true
-//                }
-//            }
-            FluIconButton{
-                id:btn_nav
-                iconSource: FluentIcons.GlobalNavButton
-                iconSize: 15
-                Layout.preferredWidth: d.isMinimal ? 40 : 0
-                Layout.preferredHeight: 40
+
+            //            FluIconButton{
+            //                iconSource: FluentIcons.ChromeBack
+            //                Layout.leftMargin: 5
+            //                Layout.preferredWidth: 40
+            //                Layout.preferredHeight: 40
+            //                Layout.alignment: Qt.AlignVCenter
+            //                disabled:  nav_swipe.depth === 1
+            //                iconSize: 13
+            //                onClicked: {
+            //                    nav_swipe.pop()
+            //                    d.stackItems.pop()
+            //                    var item = d.stackItems[d.stackItems.length-1]
+            //                    d.enableStack = false
+            //                    if(item.idx<(nav_list.count - layout_footer.count)){
+            //                        layout_footer.currentIndex = -1
+            //                    }else{
+            //                        console.debug(item.idx-(nav_list.count-layout_footer.count))
+            //                        layout_footer.currentIndex = item.idx-(nav_list.count-layout_footer.count)
+            //                    }
+            //                    nav_list.currentIndex = item.idx
+            //                    d.enableStack = true
+            //                }
+            //            }
+            FluIconButton {
+                id: btn_nav
                 Layout.alignment: Qt.AlignVCenter
                 Layout.alignment: Qt.AlignVCenter
-                onClicked: {
-                    d.enableNavigationPanel = !d.enableNavigationPanel
-                }
+                Layout.preferredHeight: 40
+                Layout.preferredWidth: d.isMinimal ? 40 : 0
+                iconSize: 15
+                iconSource: FluentIcons.GlobalNavButton
                 visible: d.isMinimal
                 visible: d.isMinimal
-                Behavior on Layout.preferredWidth{
-                    NumberAnimation{
+
+                Behavior on Layout.preferredWidth  {
+                    NumberAnimation {
                         duration: 167
                         duration: 167
+                        easing.bezierCurve: [0, 0, 0, 1]
                         easing.type: Easing.BezierSpline
                         easing.type: Easing.BezierSpline
-                        easing.bezierCurve: [ 0, 0, 0, 1 ]
                     }
                     }
                 }
                 }
+
+                onClicked: {
+                    d.enableNavigationPanel = !d.enableNavigationPanel;
+                }
             }
             }
-            Item{
-                Layout.preferredHeight: 40
-                Layout.preferredWidth: 40
+            Item {
                 Layout.alignment: Qt.AlignVCenter
                 Layout.alignment: Qt.AlignVCenter
                 Layout.leftMargin: 5
                 Layout.leftMargin: 5
-                Image{
-                    width: 20
-                    height: 20
+                Layout.preferredHeight: 40
+                Layout.preferredWidth: 40
+
+                Image {
+                    id: image_logo
                     anchors.centerIn: parent
                     anchors.centerIn: parent
-                    id:image_logo
+                    height: 20
                     source: control.logo
                     source: control.logo
+                    width: 20
                 }
                 }
-                MouseArea{
+                MouseArea {
                     anchors.fill: parent
                     anchors.fill: parent
+
                     onClicked: Qt.openUrlExternally("https://github.com/runhey/OnmyojiAutoScript")
                     onClicked: Qt.openUrlExternally("https://github.com/runhey/OnmyojiAutoScript")
                 }
                 }
             }
             }
-            FluText{
+            FluText {
                 Layout.alignment: Qt.AlignVCenter
                 Layout.alignment: Qt.AlignVCenter
-                text:control.title
                 Layout.leftMargin: 12
                 Layout.leftMargin: 12
                 font: FluTextStyle.BodyStrong
                 font: FluTextStyle.BodyStrong
+                text: control.title
             }
             }
-            FluText{
+            FluText {
                 Layout.alignment: Qt.AlignVCenter
                 Layout.alignment: Qt.AlignVCenter
-                text: ">"
                 Layout.leftMargin: 2
                 Layout.leftMargin: 2
                 font: FluTextStyle.Body
                 font: FluTextStyle.Body
+                text: ">"
             }
             }
-            FluText{
+            FluText {
                 id: nav_app_bar_pane_title
                 id: nav_app_bar_pane_title
                 Layout.alignment: Qt.AlignVCenter
                 Layout.alignment: Qt.AlignVCenter
-                text:"主页"
                 Layout.leftMargin: 2
                 Layout.leftMargin: 2
                 font: FluTextStyle.Body
                 font: FluTextStyle.Body
+                text: "home"
             }
             }
         }
         }
     }
     }
-
-    Item{
-        anchors{
-            left: d.isMinimal || d.isCompactAndPanel  ? parent.left : layout_list.right
-            top: nav_app_bar.bottom
-            right: parent.right
+    Item {
+        anchors {
             bottom: parent.bottom
             bottom: parent.bottom
+            left: d.isMinimal || d.isCompactAndPanel ? parent.left : layout_list.right
             leftMargin: d.isCompactAndPanel ? 50 : 0
             leftMargin: d.isCompactAndPanel ? 50 : 0
+            right: parent.right
+            top: nav_app_bar.bottom
         }
         }
-        StackView{
-            id:nav_swipe
+        //        StackView{
+        //            id:nav_swipe
+        //            anchors.fill: parent
+        //            clip: true
+        //            popEnter : Transition{}
+        //            popExit : Transition {
+        //                NumberAnimation {
+        //                    properties: "y"
+        //                    from: 0
+        //                    to: nav_swipe.height
+        //                    duration: 167
+        //                    easing.type: Easing.BezierSpline
+        //                    easing.bezierCurve: [ 1, 0, 0, 0 ]
+        //                }
+        //            }
+        //            pushEnter: Transition {
+        //                NumberAnimation {
+        //                    properties: "y";
+        //                    from: nav_swipe.height;
+        //                    to: 0
+        //                    duration: 167
+        //                    easing.type: Easing.BezierSpline
+        //                    easing.bezierCurve: [ 0, 0, 0, 1 ]
+        //                }
+        //            }
+        //            pushExit : Transition{}
+        //            replaceEnter : Transition{}
+        //            replaceExit : Transition{}
+        //        }
+        SwipeView {
+            id: nav_swipe
             anchors.fill: parent
             anchors.fill: parent
             clip: true
             clip: true
-            popEnter : Transition{}
-            popExit : Transition {
-                NumberAnimation {
-                    properties: "y"
-                    from: 0
-                    to: nav_swipe.height
-                    duration: 167
-                    easing.type: Easing.BezierSpline
-                    easing.bezierCurve: [ 1, 0, 0, 0 ]
-                }
-            }
-            pushEnter: Transition {
-                NumberAnimation {
-                    properties: "y";
-                    from: nav_swipe.height;
-                    to: 0
-                    duration: 167
-                    easing.type: Easing.BezierSpline
-                    easing.bezierCurve: [ 0, 0, 0, 1 ]
-                }
-            }
-            pushExit : Transition{}
-            replaceEnter : Transition{}
-            replaceExit : Transition{}
+            interactive: false
+            orientation: Qt.Vertical
         }
         }
     }
     }
-
-    MouseArea{
+    MouseArea {
         anchors.fill: parent
         anchors.fill: parent
-        visible: d.isMinimalAndPanel||d.isCompactAndPanel
+        visible: d.isMinimalAndPanel || d.isCompactAndPanel
+
         onClicked: {
         onClicked: {
-            d.enableNavigationPanel = false
+            d.enableNavigationPanel = false;
         }
         }
     }
     }
 
 
-    Rectangle{
-        id:layout_list
+    //鏈�宸﹁竟鐨刵av
+    Rectangle {
+        id: layout_list
+        border.color: FluTheme.dark ? Qt.rgba(45 / 255, 45 / 255, 45 / 255, 1) : Qt.rgba(226 / 255, 230 / 255, 234 / 255, 1)
+        border.width: d.isMinimal || d.isCompactAndPanel ? 1 : 0
+        color: {
+            if (d.isMinimal || d.isCompactAndPanel) {
+                return FluTheme.dark ? Qt.rgba(61 / 255, 61 / 255, 61 / 255, 1) : Qt.rgba(243 / 255, 243 / 255, 243 / 255, 1);
+            }
+            if (window && window.active) {
+                return FluTheme.dark ? Qt.rgba(26 / 255, 34 / 255, 41 / 255, 1) : Qt.rgba(238 / 255, 244 / 255, 249 / 255, 1);
+            }
+            return FluTheme.dark ? Qt.rgba(32 / 255, 32 / 255, 32 / 255, 1) : Qt.rgba(243 / 255, 243 / 255, 243 / 255, 1);
+        }
         width: {
         width: {
-            if(d.isCompactAndNotPanel){
-                return 50
+            if (d.isCompactAndNotPanel) {
+                return 50;
             }
             }
-            return 200
+            return 200;
         }
         }
-        Behavior on width{
-            NumberAnimation{
+        x: {
+            if (d.displayMode !== FluNavigationView.Minimal)
+                return 0;
+            return d.isMinimalAndPanel ? 0 : -width;
+        }
+
+        Behavior on color  {
+            ColorAnimation {
+                duration: 300
+            }
+        }
+        Behavior on width  {
+            NumberAnimation {
                 duration: 167
                 duration: 167
+                easing.bezierCurve: [0, 0, 0, 1]
                 easing.type: Easing.BezierSpline
                 easing.type: Easing.BezierSpline
-                easing.bezierCurve: [ 0, 0, 0, 1 ]
             }
             }
         }
         }
-        Behavior on x{
-            id:anim_layout_list_x
-            NumberAnimation{
+        Behavior on x  {
+            id: anim_layout_list_x
+            NumberAnimation {
                 duration: 167
                 duration: 167
+                easing.bezierCurve: [0, 0, 0, 1]
                 easing.type: Easing.BezierSpline
                 easing.type: Easing.BezierSpline
-                easing.bezierCurve: [ 0, 0, 0, 1 ]
             }
             }
         }
         }
-        anchors{
-            top: parent.top
+
+        anchors {
             bottom: parent.bottom
             bottom: parent.bottom
+            top: parent.top
         }
         }
-        border.color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,230/255,234/255,1)
-        border.width:  d.isMinimal || d.isCompactAndPanel ? 1 : 0
-        color: {
-            if(d.isMinimal || d.isCompactAndPanel){
-                return FluTheme.dark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(243/255,243/255,243/255,1)
-            }
-            if(window && window.active){
-                return FluTheme.dark ? Qt.rgba(26/255,34/255,41/255,1) : Qt.rgba(238/255,244/255,249/255,1)
-            }
-            return FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
-        }
-        Behavior on color{
-            ColorAnimation {
-                duration: 300
-            }
-        }
-        x: {
-            if(d.displayMode !== FluNavigationView.Minimal)
-                return 0
-            return d.isMinimalAndPanel  ? 0 : -width
-        }
-        Item{
-            id:layout_header
-            width: layout_list.width
+        // 鏄剧ず鐨勬悳绱㈡锛燂紵
+        Item {
+            id: layout_header
             clip: true
             clip: true
-            y:nav_app_bar.height
             height: autoSuggestBox ? 38 : 0
             height: autoSuggestBox ? 38 : 0
-            Loader{
-                id:loader_auto_suggest_box
+            width: layout_list.width
+            y: nav_app_bar.height
+
+            Loader {
+                id: loader_auto_suggest_box
                 anchors.centerIn: parent
                 anchors.centerIn: parent
-                sourceComponent: autoSuggestBox
                 opacity: {
                 opacity: {
-                    if(d.isCompactAndNotPanel){
-                        return false
+                    if (d.isCompactAndNotPanel) {
+                        return false;
                     }
                     }
-                    return true
+                    return true;
                 }
                 }
+                sourceComponent: autoSuggestBox
                 visible: opacity
                 visible: opacity
-                Behavior on opacity{
-                    NumberAnimation{
-                        duration: 83
-                    }
-                }
-            }
 
 
-            FluIconButton{
-                visible:opacity
-                opacity:d.isCompactAndNotPanel
-                Behavior on opacity{
-                    NumberAnimation{
+                Behavior on opacity  {
+                    NumberAnimation {
                         duration: 83
                         duration: 83
                     }
                     }
                 }
                 }
-                hoverColor: FluTheme.dark ? Qt.rgba(1,1,1,0.03) : Qt.rgba(0,0,0,0.03)
-                pressedColor: FluTheme.dark ? Qt.rgba(1,1,1,0.03) : Qt.rgba(0,0,0,0.03)
-                normalColor: FluTheme.dark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0)
-                width:38
-                height:34
-                x:6
-                y:2
+            }
+            FluIconButton {
+                height: 34
+                hoverColor: FluTheme.dark ? Qt.rgba(1, 1, 1, 0.03) : Qt.rgba(0, 0, 0, 0.03)
                 iconSize: 15
                 iconSize: 15
                 iconSource: {
                 iconSource: {
-                    if(loader_auto_suggest_box.item){
-                        return loader_auto_suggest_box.item.autoSuggestBoxReplacement
+                    if (loader_auto_suggest_box.item) {
+                        return loader_auto_suggest_box.item.autoSuggestBoxReplacement;
                     }
                     }
-                    return 0
+                    return 0;
                 }
                 }
+                normalColor: FluTheme.dark ? Qt.rgba(0, 0, 0, 0) : Qt.rgba(0, 0, 0, 0)
+                opacity: d.isCompactAndNotPanel
+                pressedColor: FluTheme.dark ? Qt.rgba(1, 1, 1, 0.03) : Qt.rgba(0, 0, 0, 0.03)
+                visible: opacity
+                width: 38
+                x: 6
+                y: 2
+
+                Behavior on opacity  {
+                    NumberAnimation {
+                        duration: 83
+                    }
+                }
+
                 onClicked: {
                 onClicked: {
-                    d.enableNavigationPanel = !d.enableNavigationPanel
+                    d.enableNavigationPanel = !d.enableNavigationPanel;
                 }
                 }
             }
             }
         }
         }
-
-        ListView{
-            id:nav_list
+        ListView {
+            id: nav_list
             clip: true
             clip: true
-            ScrollBar.vertical: FluScrollBar {}
-            model:d.handleItems()
+            currentIndex: -1
             highlightMoveDuration: 150
             highlightMoveDuration: 150
-            highlight: Item{
+            model: d.handleItems()
+
+            ScrollBar.vertical: FluScrollBar {
+            }
+            delegate: Loader {
+                property var idx: index
+                property var model: modelData
+                property int type: 0
+
+                sourceComponent: {
+                    if (modelData instanceof FluPaneItem) {
+                        return com_panel_item;
+                    }
+                    if (modelData instanceof FluPaneItemHeader) {
+                        return com_panel_item_header;
+                    }
+                    if (modelData instanceof FluPaneItemSeparator) {
+                        return com_panel_item_separatorr;
+                    }
+                    if (modelData instanceof FluPaneItemExpander) {
+                        return com_panel_item_expander;
+                    }
+                    if (modelData instanceof FluPaneItemEmpty) {
+                        return com_panel_item_empty;
+                    }
+                }
+            }
+            highlight: Item {
                 clip: true
                 clip: true
-                Rectangle{
+
+                Rectangle {
+                    color: FluTheme.primaryColor.dark
                     height: 18
                     height: 18
                     radius: 1.5
                     radius: 1.5
-                    color: FluTheme.primaryColor.dark
                     width: 3
                     width: 3
-                    anchors{
-                        verticalCenter: parent.verticalCenter
+
+                    anchors {
                         left: parent.left
                         left: parent.left
                         leftMargin: 6
                         leftMargin: 6
+                        verticalCenter: parent.verticalCenter
                     }
                     }
                 }
                 }
             }
             }
+
             onCurrentIndexChanged: {
             onCurrentIndexChanged: {
-                if(d.enableStack){
-                    var item = model[currentIndex]
-                    if(item instanceof FluPaneItem){
-                        item.tap()
-                        d.stackItems.push(item)
+                if (d.enableStack) {
+                    var item = model[currentIndex];
+                    if (item instanceof FluPaneItem) {
+                        item.tap();
+                        d.stackItems.push(item);
                     }
                     }
                 }
                 }
             }
             }
-            currentIndex: -1
-            anchors{
-                top: layout_header.bottom
-                topMargin: 0
+
+            anchors {
+                bottom: layout_footer.top
                 left: parent.left
                 left: parent.left
                 right: parent.right
                 right: parent.right
-                bottom: layout_footer.top
-            }
-            delegate: Loader{
-                property var model: modelData
-                property var idx: index
-                property int type: 0
-                sourceComponent: {
-                    if(modelData instanceof FluPaneItem){
-                        return com_panel_item
-                    }
-                    if(modelData instanceof FluPaneItemHeader){
-                        return com_panel_item_header
-                    }
-                    if(modelData instanceof FluPaneItemSeparator){
-                        return com_panel_item_separatorr
-                    }
-                    if(modelData instanceof FluPaneItemExpander){
-                        return com_panel_item_expander
-                    }
-                    if(modelData instanceof FluPaneItemEmpty){
-                        return com_panel_item_empty
-                    }
-                }
+                top: layout_header.bottom
+                topMargin: 0
             }
             }
         }
         }
-        ListView{
-            id:layout_footer
+        ListView {
+            id: layout_footer
+            anchors.bottom: parent.bottom
             clip: true
             clip: true
-            width: layout_list.width
+            currentIndex: -1
             height: childrenRect.height
             height: childrenRect.height
-            anchors.bottom: parent.bottom
+            highlightMoveDuration: 150
             interactive: false
             interactive: false
-            currentIndex: -1
             model: {
             model: {
-                if(footerItems){
-                    return footerItems.children
+                if (footerItems) {
+                    return footerItems.children;
                 }
                 }
             }
             }
-            highlightMoveDuration: 150
-            highlight: Item{
+            width: layout_list.width
+
+            delegate: Loader {
+                property var idx: index
+                property var model: modelData
+                property int type: 1
+
+                sourceComponent: {
+                    if (modelData instanceof FluPaneItem) {
+                        return com_panel_item;
+                    }
+                    if (modelData instanceof FluPaneItemHeader) {
+                        return com_panel_item_header;
+                    }
+                    if (modelData instanceof FluPaneItemSeparator) {
+                        return com_panel_item_separatorr;
+                    }
+                }
+            }
+            highlight: Item {
                 clip: true
                 clip: true
-                Rectangle{
+
+                Rectangle {
+                    color: FluTheme.primaryColor.dark
                     height: 18
                     height: 18
                     radius: 1.5
                     radius: 1.5
-                    color: FluTheme.primaryColor.dark
                     width: 3
                     width: 3
-                    anchors{
-                        verticalCenter: parent.verticalCenter
+
+                    anchors {
                         left: parent.left
                         left: parent.left
                         leftMargin: 6
                         leftMargin: 6
-                    }
-                }
-            }
-            delegate: Loader{
-                property var model: modelData
-                property var idx: index
-                property int type: 1
-                sourceComponent: {
-                    if(modelData instanceof FluPaneItem){
-                        return com_panel_item
-                    }
-                    if(modelData instanceof FluPaneItemHeader){
-                        return com_panel_item_header
-                    }
-                    if(modelData instanceof FluPaneItemSeparator){
-                        return com_panel_item_separatorr
+                        verticalCenter: parent.verticalCenter
                     }
                     }
                 }
                 }
             }
             }
         }
         }
     }
     }
+    Popup {
+        id: control_popup
 
 
-    Popup{
         property var childModel
         property var childModel
-        id:control_popup
-        enter: Transition {
-            NumberAnimation {
-                property: "opacity"
-                from:0
-                to:1
-                duration: 83
-            }
+
+        function showPopup(pos, model) {
+            control_popup.x = pos.x;
+            control_popup.y = pos.y;
+            control_popup.childModel = model;
+            control_popup.open();
         }
         }
-        background: Rectangle{
-            width: 160
+
+        background: Rectangle {
+            color: FluTheme.dark ? Qt.rgba(51 / 255, 48 / 255, 48 / 255, 1) : Qt.rgba(248 / 255, 250 / 255, 253 / 255, 1)
+            height: 38 * Math.min(Math.max(list_view.count, 1), 8)
             radius: 4
             radius: 4
-            FluShadow{
+            width: 160
+
+            FluShadow {
                 radius: 4
                 radius: 4
             }
             }
-            color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
-            height: 38*Math.min(Math.max(list_view.count,1),8)
-            ListView{
-                id:list_view
+            ListView {
+                id: list_view
                 anchors.fill: parent
                 anchors.fill: parent
                 clip: true
                 clip: true
                 currentIndex: -1
                 currentIndex: -1
                 model: control_popup.childModel
                 model: control_popup.childModel
-                ScrollBar.vertical: FluScrollBar {}
-                delegate:Button{
+
+                ScrollBar.vertical: FluScrollBar {
+                }
+                delegate: Button {
+                    padding: 10
                     width: 160
                     width: 160
-                    padding:10
-                    background: Rectangle{
-                        color:  {
-                            if(hovered){
-                                return FluTheme.dark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1)
+
+                    background: Rectangle {
+                        color: {
+                            if (hovered) {
+                                return FluTheme.dark ? Qt.rgba(63 / 255, 60 / 255, 61 / 255, 1) : Qt.rgba(237 / 255, 237 / 255, 242 / 255, 1);
                             }
                             }
-                            return FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(0,0,0,0)
+                            return FluTheme.dark ? Qt.rgba(51 / 255, 48 / 255, 48 / 255, 1) : Qt.rgba(0, 0, 0, 0);
                         }
                         }
                     }
                     }
-                    contentItem: FluText{
-                        text:modelData.title
-                        anchors{
+                    contentItem: FluText {
+                        text: modelData.title
+
+                        anchors {
                             verticalCenter: parent.verticalCenter
                             verticalCenter: parent.verticalCenter
                         }
                         }
                     }
                     }
+
                     onClicked: {
                     onClicked: {
-                        if(modelData.tapFunc){
-                            modelData.tapFunc()
-                        }else{
-                            nav_list.currentIndex = idx
-                            layout_footer.currentIndex = -1
-                            if(d.isMinimal || d.isCompact){
-                                d.enableNavigationPanel = false
+                        if (modelData.tapFunc) {
+                            modelData.tapFunc();
+                        } else {
+                            nav_list.currentIndex = idx;
+                            layout_footer.currentIndex = -1;
+                            if (d.isMinimal || d.isCompact) {
+                                d.enableNavigationPanel = false;
                             }
                             }
                         }
                         }
-                        control_popup.close()
+                        control_popup.close();
                     }
                     }
                 }
                 }
             }
             }
         }
         }
-        function showPopup(pos,model){
-            control_popup.x = pos.x
-            control_popup.y = pos.y
-            control_popup.childModel = model
-            control_popup.open()
-        }
-    }
-
-    Timer{
-        id:timer_anim_x_enable
-        interval: 150
-        onTriggered: {
-            anim_layout_list_x.enabled = true
-        }
-    }
-
-    function collapseAll(){
-        for(var i=0;i<nav_list.model.length;i++){
-            var item = nav_list.model[i]
-            if(item instanceof FluPaneItemExpander){
-                item.isExpand = false
+        enter: Transition {
+            NumberAnimation {
+                duration: 83
+                from: 0
+                property: "opacity"
+                to: 1
             }
             }
         }
         }
     }
     }
+    Timer {
+        id: timer_anim_x_enable
+        interval: 150
 
 
-    function setCurrentIndex(index){
-        nav_list.currentIndex = index
-
-    }
-
-    function getItems(){
-        return nav_list.model
-    }
-
-    function push(url){
-        nav_swipe.push(url)
-    }
-
-    function getCurrentIndex(){
-        return nav_list.currentIndex
-    }
-
-    function startPageByItem(data){
-        var items = getItems();
-        for(var i=0;i<items.length;i++){
-            var item =  items[i]
-            if(item.key === data.key){
-                if(getCurrentIndex() === i){
-                    return
-                }
-                setCurrentIndex(i)
-                if(item.parent && !d.isCompactAndNotPanel){
-                    item.parent.isExpand = true
-                }
-                return
-            }
+        onTriggered: {
+            anim_layout_list_x.enabled = true;
         }
         }
     }
     }
 }
 }

+ 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":"简体中文"}

+ 42 - 15
module/config/config.py

@@ -9,30 +9,46 @@ import threading
 from module.config.config_updater import ConfigUpdater
 from module.config.config_updater import ConfigUpdater
 from module.config.config_manual import ConfigManual
 from module.config.config_manual import ConfigManual
 from module.config.config_watcher import ConfigWatcher
 from module.config.config_watcher import ConfigWatcher
+from module.config.config_menu import ConfigMenu
+from module.config.config_model import ConfigModel
+from module.config.config_state import ConfigState
 from module.config.utils import *
 from module.config.utils import *
 
 
 from module.logger import logger
 from module.logger import logger
 
 
-class Config(ConfigManual, ConfigWatcher, ConfigUpdater):
-    """
-    一个配置文件的集成类
-    """
+class Config(ConfigState, ConfigManual, ConfigWatcher, ConfigMenu):
+
     def __init__(self, config_name: str, task=None) -> None:
     def __init__(self, config_name: str, task=None) -> None:
         """
         """
 
 
         :param config_name:
         :param config_name:
         :param task:
         :param task:
         """
         """
-        self.config_name = config_name
-        self.data: dict = {}
-        self.is_template_config = config_name.startswith("template")
-
-        self.load()
+        super().__init__(config_name)  # 调用 ConfigState 的初始化方法
+        super(ConfigManual, self).__init__()
+        super(ConfigWatcher, self).__init__()
+        super(ConfigMenu, self).__init__()
+        self.model = ConfigModel(config_name=config_name)
 
 
+    def __getattr__(self, name):
+        """
+        一开始是打算直接继承ConfigModel的,但是pydantic会接管所有的变量
+        故而选择持有ConfigModel
+        :param name:
+        :return:
+        """
+        try:
+            return getattr(self.model, name)
+        except AttributeError:
+            logger.error(f'can not ask this variable {name}')
+            return None  # 或者抛出异常,或者返回其他默认值
 
 
-    def load(self) -> None:
-        self.data = self.read_file(self.config_name)
-
+    def gui_args(self, task: str) -> str:
+        """
+        获取给gui显示的参数
+        :return:
+        """
+        return self.model.gui_args(task=task)
 
 
     def get_arg(self, task: str, group: str, argument: str):
     def get_arg(self, task: str, group: str, argument: str):
         """
         """
@@ -61,7 +77,18 @@ class Config(ConfigManual, ConfigWatcher, ConfigUpdater):
         except:
         except:
             logger.exception(f'have no arg {task}.{group}.{argument}')
             logger.exception(f'have no arg {task}.{group}.{argument}')
 
 
+    def save(self) -> None:
+        """
+        保存配置文件
+        :return:
+        """
+        self.model.write_json(self.config_name, self.model.dict())
+
 if __name__ == '__main__':
 if __name__ == '__main__':
-    config = Config(config_name='oas1')
-    logger.info(config.data)
-    logger.info(config.get_arg("Script", "Device", "Serial"))
+    config = Config(config_name='pydantic')
+    print(config.menu)
+    print(config.config_name)
+
+    config.script.device.serial = 123
+    print(config.script.device.serial)
+

+ 35 - 0
module/config/config_menu.py

@@ -0,0 +1,35 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import json
+
+from cached_property import cached_property
+from pydantic import BaseModel, ValidationError, validator, Field
+
+from module.config.utils import *
+
+class ConfigMenu:
+    # 手动的代码配置菜单
+    def __init__(self) -> None:
+        self.menu = {}
+        # 总览
+        self.menu["Overview"] = []
+        # 脚本设置
+        self.menu['Script'] = ['Script', 'General', 'Restart']
+        # 日常的任务
+        self.menu["Daily Task"] = ['Territorial Demon', 'Coin Challenge']
+
+    @cached_property
+    def gui_menu(self) -> str:
+        """
+        生成的是json字符串
+        :return:
+        """
+        return json.dumps(self.menu, ensure_ascii=False, sort_keys=False, default=str)
+
+if __name__ == "__main__":
+    try:
+        m = ConfigMenu()
+        print(m.gui_menu)
+    except:
+        print('weih')

+ 127 - 0
module/config/config_model.py

@@ -0,0 +1,127 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import json
+
+from pathlib import Path
+from pydantic import BaseModel, ValidationError, validator, Field, root_validator
+
+from module.config.utils import *
+from module.logger import logger
+
+# 导入配置的Python文件
+from module.tasks.Script.config import Script
+from module.tasks.Restart.config import Restart
+
+
+
+
+
+
+class ConfigModel(BaseModel):
+    config_name: str = "oas"
+    script: Script = Field(default_factory=Script)
+    restart: Restart = Field(default_factory=Restart)
+
+    # @validator('script')
+    # def script_validator(cls, v):
+    #     if v is None:
+    #         return Script()
+
+    def __init__(self, config_name: str) -> None:
+        """
+
+        :param config_name:
+        """
+        data = self.read_json(config_name)
+        data["config_name"] = config_name
+        super().__init__(**data)
+
+    def __setattr__(self, key, value):
+        """
+        只要修改属性就会触发这个函数 自动保存
+        :param key:
+        :param value:
+        :return:
+        """
+        super().__setattr__(key, value)
+        logger.info("auto save config")
+        self.save()
+
+
+
+    @staticmethod
+    def read_json(config_name: str) -> dict:
+        """
+        读文件 没有额外操作
+        :param config_name:  不带后缀
+        :return:
+        """
+        filepath = Path.cwd() / "config" / f"{config_name}.json"
+        return read_file(filepath)
+
+    @staticmethod
+    def write_json(config_name: str, data) -> None:
+        """
+
+        :param config_name: 不带后缀
+        :param data:  字典而不是字符串
+        :return:
+        """
+        filepath = Path.cwd() / "config" / f"{config_name}.json"
+        write_file(filepath, data)
+
+    def gui_args(self, task: str) -> str:
+        """
+        返回提供给gui显示的参数
+        :param task: 输入的是任务的名称英文 如'Script' 或者是'script'都是可以的
+        :return: 返回的是pydantic给我们结构化的输出的信息, 如果不能获取就返回空的str
+        """
+        task = convert_to_underscore(task)
+        task_gui = getattr(self, task, None)
+        if task_gui is None:
+            logger.error(f'{task} is no inexistence')
+            return ''
+        return task_gui.schema_json()
+
+    def gui_task(self, task: str) -> str:
+        """
+        返回提供给gui显示的参数
+        :param task:
+        :return:
+        """
+        task_name = convert_to_underscore(task)
+        task = getattr(self, task_name, None)
+        if task is None:
+            logger.error(f'{task_name} is no inexistence')
+            return ''
+        return task.json()
+
+    def save(self) -> None:
+        """
+
+        :return:
+        """
+        self.write_json(self.config_name, self.dict())
+
+
+    # @root_validator
+    # def on_on_property_change(cls, values):
+    #     """
+    #     当属性改变时保存
+    #     :param values:
+    #     :return:
+    #     """
+    #     logger.info(f'property change auto save')
+    #     cls.save()
+
+
+if __name__ == "__main__":
+    try:
+        c = ConfigModel("oas1")
+    except ValidationError as e:
+        print(e)
+        c = ConfigModel()
+    # c.write_json('oas1', c.dict())
+    # c.write_json('oas1', c.schema())
+    c.script.device.serial = "5555"

+ 13 - 0
module/config/config_state.py

@@ -0,0 +1,13 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+
+class ConfigState:
+    """
+    这个类用于 先定义运行过程中所需要的变量
+    """
+    def __init__(self, config_name: str) -> None:
+        self.config_name = config_name
+        self.pending_task = []
+        self.waiting_task = []

+ 2 - 1
module/config/config_updater.py

@@ -62,4 +62,5 @@ class ConfigUpdater:
             data (dict):
             data (dict):
             mod_name (str):
             mod_name (str):
         """
         """
-        write_file(filepath_config(config_name, mod_name), data)
+        write_file(filepath_config(config_name, mod_name), data)
+

+ 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>about</translation>
+    </message>
+    <message>
+        <source>settings</source>
+        <translation>settings</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>FluTreeView</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>

+ 30 - 1
module/config/utils.py

@@ -154,4 +154,33 @@ def get_server_next_update(daily_trigger):
         future = local_now + timedelta(seconds=s)
         future = local_now + timedelta(seconds=s)
         trigger.append(future)
         trigger.append(future)
     update = sorted(trigger)[0]
     update = sorted(trigger)[0]
-    return update
+    return update
+
+
+def convert_to_underscore(text: str) -> str:
+    """
+    大驼峰形式的字符串转换为下划线形式的字符串,并在数字前插入下划线。如果字符串中已经包含下划线,则会直接返回原始字符串。
+    :param text:
+    :return:
+    """
+    if '_' in text:
+        # If text already contains underscore, assume it's in the correct format
+        return text
+
+    result = ''
+    for i, char in enumerate(text):
+        if char.isupper():
+            if i > 0 and (text[i-1].islower() or (i < len(text) - 1 and text[i+1].islower())):
+                # Insert underscore before uppercase letter, except at the beginning
+                result += '_'
+            result += char.lower()
+        elif char.isdigit():
+            if i > 0 and (text[i-1].isalpha() or (i < len(text) - 1 and text[i+1].isalpha())):
+                # Insert underscore before digit, except at the beginning
+                result += '_'
+            result += char
+        else:
+            result += char
+
+    return result
+

BIN
module/gui/FluentUI/fluentuiplugin.dll


+ 12 - 4
module/gui/context/add.py

@@ -80,10 +80,18 @@ class Add(QObject):
         all_script_files = self.all_script_files()
         all_script_files = self.all_script_files()
         if not all_script_files:
         if not all_script_files:
             return 'oas1'
             return 'oas1'
-        all_script_files.sort()
-        last_script = all_script_files[-1]
-        last_script_number = re.findall(r'\d+', last_script)[0]
-        new_script_number = int(last_script_number) + 1
+
+        script_numbers = []
+        for script_file in all_script_files:
+            match = re.search(r'\d+', script_file)
+            if match:
+                script_number = int(match.group())
+                script_numbers.append(script_number)
+
+        if not script_numbers:
+            return 'oas1'
+        script_numbers.sort()
+        new_script_number = script_numbers[-1] + 1
         return f'oas{new_script_number}'
         return f'oas{new_script_number}'
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":

+ 122 - 1
module/gui/context/process_manager.py

@@ -5,6 +5,7 @@ import socket
 import random
 import random
 import zerorpc
 import zerorpc
 
 
+from typing import Union, Any
 from PySide6.QtCore import QObject, Slot, Signal
 from PySide6.QtCore import QObject, Slot, Signal
 
 
 from module.gui.process.script_process import ScriptProcess
 from module.gui.process.script_process import ScriptProcess
@@ -124,4 +125,124 @@ class ProcessManager(QObject):
         """
         """
         for config in self.processes:
         for config in self.processes:
             self.processes[config].restart()
             self.processes[config].restart()
-        logger.info(f'restart all script')
+        logger.info(f'restart all script')
+
+    def get_client(self, config: str) -> zerorpc.Client:
+        """
+        get_client
+        :param config:
+        :return:
+        """
+        if config in self.clients:
+            return self.clients[config]
+        else:
+            logger.info(f'script {config} is not running')
+            return None
+
+    @Slot(str, result="QString")
+    def gui_menu(self, config: str) -> str:
+        """
+        get_gui_menu
+        :param config:
+        :return:
+        """
+        if config in self.clients:
+            logger.info(f'gui get menu of {config}')
+            return self.clients[config].gui_menu()
+        else:
+            logger.info(self.clients)
+            logger.info(f'script {config} is not running')
+            return None
+
+    @Slot(str, str, result="QString")
+    def gui_args(self, config: str, task: str) -> str:
+        """
+        获取显示task的gui参数
+        :param config:
+        :param task:
+        :return:
+        """
+        if config in self.clients:
+            logger.info(f'gui get args of {config} {task}')
+            return self.clients[config].gui_args(task)
+        else:
+            logger.info(f'script {config} is not running')
+            return None
+
+    @Slot(str, str, result="QString")
+    def gui_task(self, config: str, task: str) -> str:
+        """
+        获取显示task的gui
+        :param config:
+        :param task:
+        :return:
+        """
+        if config in self.clients:
+            logger.info(f'gui get value of {config} {task}')
+            return self.clients[config].gui_task(task)
+        else:
+            logger.info(f'script {config} is not running')
+            return None
+
+    @Slot(str, str, str, str, str, result="bool")
+    def gui_set_task(self, config: str, task: str, group: str, arg: str, value) -> bool:
+        """
+        设置task的gui   是string类型的
+        :param config:
+        :param task:
+        :param group:
+        :param arg:
+        :param value:
+        :return:
+        """
+        if config in self.clients:
+            logger.info(f'gui set value of {config} {task}')
+            if self.clients[config].gui_set_task(task, group, arg, value):
+                return True
+            else:
+                return False
+        else:
+            logger.info(f'script {config} is not running')
+            return False
+
+    @Slot(str, str, str, str, bool, result="bool")
+    def gui_set_task_bool(self, config: str, task: str, group: str, arg: str, value: bool) -> bool:
+        """
+        设置task的gui   是bool类型的
+        :param config:
+        :param task:
+        :param group:
+        :param arg:
+        :param value:
+        :return:
+        """
+        if config in self.clients:
+            logger.info(f'gui set value of {config} {task}')
+            if self.clients[config].gui_set_task(task, group, arg, value):
+                return True
+            else:
+                return False
+        else:
+            logger.info(f'script {config} is not running')
+            return False
+
+    @Slot(str, str, str, str, float, result="bool")
+    def gui_set_task_number(self, config: str, task: str, group: str, arg: str, value) -> bool:
+        """
+        设置task的gui   是float类型的或者是int
+        :param config:
+        :param task:
+        :param group:
+        :param arg:
+        :param value:
+        :return:
+        """
+        if config in self.clients:
+            logger.info(f'gui set value of {config} {task}')
+            if self.clients[config].gui_set_task(task, group, arg, value):
+                return True
+            else:
+                return False
+        else:
+            logger.info(f'script {config} is not running')
+            return False

+ 40 - 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,37 @@ class FluentApp():
         """
         """
         FluentApp.engine.rootContext().setContextProperty(name, context)
         FluentApp.engine.rootContext().setContextProperty(name, context)
 
 
+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
+
+
+

+ 1 - 0
module/gui/qml.qrc

@@ -22,5 +22,6 @@
         <file>qml/Page/Update.qml</file>
         <file>qml/Page/Update.qml</file>
         <file>qml/Component/Args.qml</file>
         <file>qml/Component/Args.qml</file>
         <file>qml/Component/Taskmini.qml</file>
         <file>qml/Component/Taskmini.qml</file>
+        <file>qml/Component/ModelParse.js</file>
     </qresource>
     </qresource>
 </RCC>
 </RCC>

+ 2 - 0
module/gui/qml/Component/Add.qml

@@ -50,6 +50,8 @@ FluContentDialog{
             FluTextBox{
             FluTextBox{
                 id: newNameBox
                 id: newNameBox
                 placeholderText:"推荐:oas+number"
                 placeholderText:"推荐:oas+number"
+//                maxLength: 20
+                validator: RegularExpressionValidator { regularExpression: /^[a-zA-Z0-9]*$/ }
             }
             }
             FluText{
             FluText{
                 text: 'Copy from existing config'
                 text: 'Copy from existing config'

+ 526 - 2
module/gui/qml/Component/Args.qml

@@ -1,8 +1,532 @@
 import QtQuick
 import QtQuick
+import QtQuick.Controls
 import FluentUI
 import FluentUI
+import QtQuick.Layouts
+import "./ModelParse.js" as MP
 
 
 Item {
 Item {
-    FluText{
-        text: 'this args '
+    property string argsData: ""
+    property string valueData: ""
+    // 存入 配置名和 任务名两个 上下文
+    property string configName: ""
+    property string taskName: ""
+    signal updataData
+    FluScrollablePage{
+        id: contentScrollable
+        width: 700
+        height: parent.height
+        spacing: 12
+        anchors.horizontalCenter: parent.horizontalCenter
+    }
+
+    Component{
+        id: group_item
+        FluExpander{
+            id: expander
+            property string groupName: ""
+            property string groupTitle: ""
+            property var argumentValue: {""}
+            expand: true
+            headerText: qsTr(groupTitle) +" "+ qsTr("Setting")
+            width: contentScrollable.width
+            contentHeight: group_column.height
+            Column{
+                id: group_column
+                spacing: 4
+                clip: true
+                anchors{
+                    top: parent.top
+                    topMargin: 12
+                    left: parent.left
+                    leftMargin: 15
+                    right: parent.right
+                    rightMargin: 15
+                    bottomMargin: 12
+                }
+            }
+            onArgumentValueChanged: {
+                for(let index in argumentValue){
+                    const arg = argumentValue[index]
+                    createItem(arg)
+//                    expander.contentHeight = group_column.height
+                }
+            }
+            /**
+             * 创建某个具体的字段
+             * @param {Object} arg 打包的变量大概长这样的:
+                {
+                    "name": "handle_error",
+                    "title": "Handle Error",
+                    "description": "none",
+                    "default": false,
+                    "type": "boolean",
+                    "value": false
+                }
+             * @returns {Object}
+             */
+            function createItem(arg){
+                if(arg === null){
+                    console.error("it is emtry when create arg")
+                    return
+                }
+
+                var object = null
+                if(arg.type === "string"){
+                    object = string_item.createObject(group_column)
+                    if(object === null){
+                        console.error("can not create component string_item", arg.title)
+                        return
+                    }
+                }
+                else if(arg.type === "integer"){
+                    object = int_item.createObject(group_column)
+                    if(object === null){
+                        console.error("can not create component integer_item", arg.title)
+                        return
+                    }
+                }
+                else if(arg.type === "number"){
+                    object = float_item.createObject(group_column)
+                    if(object === null){
+                        console.error("can not create component float_item", arg.title)
+                        return
+                    }
+                }
+                else if(arg.type === "boolean"){
+                    object = bool_item.createObject(group_column)
+                    if(object === null){
+                        console.error("can not create component boolean_item", arg.title)
+                        return
+                    }
+                }
+                else if(arg.type === "enum"){
+                    object = enum_item.createObject(group_column)
+                    if(object === null){
+                        console.error("can not create component enum_item", arg.title)
+                        return
+                    }
+                }
+
+                if(object === null){
+                    console.error("can not create component ", arg.title)
+                    return
+                }
+                object.modelData = arg
+                group_column.data.push(object)
+            }
+        }
+
+    }
+
+    Component{
+        id: string_item
+        Item{
+            id: stringItem
+            property var modelData: null
+            width: parent.width
+            implicitHeight: string_title.implicitHeight + string_description.implicitHeight
+            Layout.fillHeight: true
+            FluTextBox{
+                id: string_text
+                anchors{
+                    top: parent.top
+                    topMargin: 2
+                    right: parent.right
+                }
+                placeholderText: ""
+                onEditingFinished: {
+                    if(set_task(stringItem.parent.parent.parent.groupName, modelData.name, text)){
+                        showSuccess( qsTr("Successful setting"))
+                    }
+                }
+            }
+
+            FluText{
+                id: string_title
+                anchors{
+                    top: parent.top
+                    left: parent.left
+                    right: string_text.left
+                }
+                text: ""
+                font: FluTextStyle.BodyStrong
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+            }
+            FluCopyableText{
+                id: string_description
+                anchors{
+                    top: string_title.bottom
+                    left: parent.left
+                }
+                width: string_title.width
+                text: ""
+                font: FluTextStyle.Caption
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+                rightPadding: 6
+            }
+            onModelDataChanged: {
+                if(modelData === null){
+                    console.error("string model is null")
+                    return
+                }
+                string_text.text = modelData.value
+                string_text.placeholderText = modelData["default"]
+                string_title.text = modelData.title
+                if( typeof modelData.description === 'undefined'){
+                    return
+                }
+                string_description.text = modelData.description
+            }
+        }
+    }
+    Component{
+        id: int_item
+        Item{
+            id: itemArg
+            property var modelData: null
+            width: parent.width
+            implicitHeight: itemArg_title.implicitHeight + itemArg_description.implicitHeight
+            Layout.fillHeight: true
+            FluTextBox{
+                id: itemArg_text
+                anchors{
+                    top: parent.top
+                    topMargin: 2
+                    right: parent.right
+                }
+                validator: IntValidator {}
+                placeholderText: ""
+                onEditingFinished: {
+                    if(set_task(itemArg.parent.parent.parent.groupName, modelData.name, parseInt(text))){
+                        showSuccess( qsTr("Successful setting"))
+                    }
+                }
+            }
+
+            FluText{
+                id: itemArg_title
+                anchors{
+                    top: parent.top
+                    left: parent.left
+                    right: itemArg_text.left
+                }
+                text: ""
+                font: FluTextStyle.BodyStrong
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+            }
+            FluCopyableText{
+                id: itemArg_description
+                anchors{
+                    top: itemArg_title.bottom
+                    left: parent.left
+                }
+                width: itemArg_title.width
+                text: ""
+                font: FluTextStyle.Caption
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+                rightPadding: 6
+            }
+            onModelDataChanged: {
+                if(modelData === null){
+                    console.error("int model is null")
+                    return
+                }
+                itemArg_text.text = modelData.value
+                itemArg_text.placeholderText = modelData["default"]
+                itemArg_title.text = modelData.title
+                if( typeof modelData.description === 'undefined'){
+                    return
+                }
+                itemArg_description.text = modelData.description
+            }
+        }
+    }
+    Component{
+        id: float_item
+        Item{
+            id: itemArg
+            property var modelData: null
+            width: parent.width
+            implicitHeight: itemArg_title.implicitHeight + itemArg_description.implicitHeight
+            Layout.fillHeight: true
+            FluTextBox{
+                id: itemArg_text
+                anchors{
+                    top: parent.top
+                    topMargin: 2
+                    right: parent.right
+                }
+                validator: DoubleValidator {}
+                placeholderText: ""
+                onEditingFinished: {
+                    if(set_task(itemArg.parent.parent.parent.groupName, modelData.name, parseFloat(text))){
+                        showSuccess( qsTr("Successful setting"))
+                    }
+                }
+            }
+
+            FluText{
+                id: itemArg_title
+                anchors{
+                    top: parent.top
+                    left: parent.left
+                    right: itemArg_text.left
+                }
+                text: ""
+                font: FluTextStyle.BodyStrong
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+            }
+            FluCopyableText{
+                id: itemArg_description
+                anchors{
+                    top: itemArg_title.bottom
+                    left: parent.left
+                }
+                width: itemArg_title.width
+                text: ""
+                font: FluTextStyle.Caption
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+                rightPadding: 6
+            }
+            onModelDataChanged: {
+                if(modelData === null){
+                    console.error("float model is null")
+                    return
+                }
+                itemArg_text.text = modelData.value
+                itemArg_text.placeholderText = modelData["default"]
+                itemArg_title.text = modelData.title
+                if( typeof modelData.description === 'undefined'){
+                    return
+                }
+                itemArg_description.text = modelData.description
+            }
+        }
+    }
+    Component{
+        id: bool_item
+        Item{
+            id: itemArg
+            property var modelData: null
+            width: parent.width
+            implicitHeight: itemArg_title.implicitHeight + itemArg_description.implicitHeight
+            Layout.fillHeight: true
+            FluCheckBox{
+                id: itemArg_text
+                anchors{
+                    top: parent.top
+                    topMargin: 2
+                    right: parent.right
+                    rightMargin: 300 - 24
+                }
+                selected: true
+                clickFunc: function click_func(){
+                    selected = !selected
+                    if(set_task(itemArg.parent.parent.parent.groupName, modelData.name, selected)){
+                        showSuccess( qsTr("Successful setting"))
+                    }
+                }
+            }
+
+            FluText{
+                id: itemArg_title
+                anchors{
+                    top: parent.top
+                    left: parent.left
+                    right: itemArg_text.left
+                }
+                text: ""
+                font: FluTextStyle.BodyStrong
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+            }
+            FluCopyableText{
+                id: itemArg_description
+                anchors{
+                    top: itemArg_title.bottom
+                    left: parent.left
+                }
+                width: itemArg_title.width
+                text: ""
+                font: FluTextStyle.Caption
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+                rightPadding: 6
+            }
+            onModelDataChanged: {
+                if(modelData === null){
+                    console.error("bool model is null")
+                    return
+                }
+                itemArg_text.selected = modelData.value
+                itemArg_title.text = modelData.title
+                if( typeof modelData.description === 'undefined'){
+                    return
+                }
+                itemArg_description.text = modelData.description
+            }
+        }
+    }
+    Component{
+        id: enum_item
+        Item{
+            id: itemArg
+            property var modelData: null
+            width: parent.width
+            implicitHeight: itemArg_title.implicitHeight + itemArg_description.implicitHeight
+            Layout.fillHeight: true
+            FComboBox{
+                id: itemArg_text
+                width: 300
+                anchors{
+                    top: parent.top
+                    topMargin: 2
+                    right: parent.right
+                }
+                model: ["0", "1", "2"]
+                onActivated: {
+                    if(set_task(itemArg.parent.parent.parent.groupName, modelData.name, currentText)){
+                        showSuccess( qsTr("Successful setting"))
+                    }
+                }
+            }
+
+            FluText{
+                id: itemArg_title
+                anchors{
+                    top: parent.top
+                    left: parent.left
+                    right: itemArg_text.left
+                }
+                text: ""
+                font: FluTextStyle.BodyStrong
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+            }
+            FluCopyableText{
+                id: itemArg_description
+                anchors{
+                    top: itemArg_title.bottom
+                    left: parent.left
+                }
+                width: itemArg_title.width
+                text: ""
+                font: FluTextStyle.Caption
+                wrapMode: Text.WrapAnywhere
+                topPadding: 6
+                rightPadding: 6
+            }
+            onModelDataChanged: {
+                if(modelData === null){
+                    console.error("enum model is null")
+                    return
+                }
+                itemArg_text.model = modelData.options
+                itemArg_text.show(modelData.value)
+                itemArg_title.text = modelData.title
+                if( typeof modelData.description === 'undefined'){
+                    return
+                }
+                itemArg_description.text = modelData.description
+            }
+        }
+    }
+
+    onArgsDataChanged: {
+
+    }
+    onValueDataChanged: {
+
+    }
+    onUpdataData: {
+        if(argsData === ""){
+            console.error("解析 顺序出问题了")
+            return
+        }
+        if(valueData === ""){
+            console.debug("没有数据")
+        }
+
+        var args = JSON.parse(argsData)
+        var values = JSON.parse(valueData)
+        var group = MP.parseGroup(args["properties"])
+        var groups = MP.parseGroups(args["properties"])
+
+        for(let task in group){
+            var argument = MP.parseArgument(args.definitions, group[task])
+            const groupLetter = groups[group[task]]
+            var argumentVuale = MP.mergeArgument(argument, values[groupLetter])
+//            console.debug(JSON.stringify( argumentVuale ))
+//            console.debug("---------------------------------------------------------------")
+            createGroup(groupLetter, group[task], argumentVuale)
+        }
+    }
+
+    /**
+     * 创建某个组 的显示组件并显示
+     * @param {Object} groupName 变量的名字 是小写的
+     * @param {Object} groupTitle 用于向用户显示的名字 大写的
+     * @param {Object} argumentVaule 总的显示的参数
+     * @returns {Object}
+     */
+    function createGroup(groupName, groupTitle, argumentValue){
+        if(!groupName){
+            console.error("no group name")
+            return
+        }
+        if(!groupTitle){
+            console.error("no group title")
+            return
+        }
+
+        var object = group_item.createObject()
+        if(object !== null){
+            object.groupName = groupName
+            object.groupTitle = groupTitle
+            object.argumentValue = argumentValue
+
+            contentScrollable.content.push(object)
+        }
+        else{
+            console.error('create group item failed!')
+        }
+    }
+
+    function set_task(group, arg, value){
+        //如果是字符串
+        if( typeof value == "string" ){
+        if(process_manager.gui_set_task(configName, taskName, group, arg, value)){
+            return true
+        }
+        else{
+            return false
+        }}
+
+        //如果是整形的
+        else if(typeof value == "number"){
+        if(process_manager.gui_set_task_number(configName, taskName, group, arg, value)){
+            return true
+        }
+        else{
+            return false
+        }}
+
+
+        //如果是bool的
+        else if(typeof value == "boolean"){
+        if(process_manager.gui_set_task_bool(configName, taskName, group, arg, value)){
+            return true
+        }
+        else{
+            return false
+        }}
+
+
     }
     }
 }
 }

+ 4 - 0
module/gui/qml/Component/FComboBox.qml

@@ -125,4 +125,8 @@ ComboBox {
             }
             }
         }
         }
     }
     }
+    // show your selectd value
+    function show(name){
+        currentIndex = find(name)
+    }
 }
 }

+ 133 - 0
module/gui/qml/Component/ModelParse.js

@@ -0,0 +1,133 @@
+.pragma library
+
+
+//
+//*****************************请注意下面的函数只适用与pydantic生成的task的参数
+//
+
+/**
+ * 解析出group的数组,
+ * @param {Object} data.properties
+ * @returns {Array} 类似这样:[Device,Error,Optimization]
+ */
+function parseGroup(properties) {
+    var result = []
+    for(const key in properties){
+        if(!('$ref' in properties[key])){
+            continue
+        }
+        const value = properties[key]['$ref'];
+        const lastPart = value.substring(value.lastIndexOf('/') + 1);
+        result.push(lastPart)
+    }
+    return result
+}
+
+/**
+ * 解析出group一一对应的的数组,
+ * @param {Object} data.properties
+ * @returns {Object} 类似这样:{"Device":"device", "Error":"error", "Optimization":"optimization"}
+ */
+function parseGroups(properties) {
+    var result = {}
+    for(const key in properties){
+        if(!('$ref' in properties[key])){
+            continue
+        }
+        const value = properties[key]['$ref'];
+        const lastPart = value.substring(value.lastIndexOf('/') + 1);
+        result[lastPart] = key
+    }
+    return result
+}
+
+
+/**
+ * 解析ref的最后一个Name
+ * @param {String} ref
+ * @returns {String}
+ */
+function parseRef(ref){
+    return ref.substring(ref.lastIndexOf('/') + 1)
+}
+
+
+/**
+ * 解析出某个group的参数组,
+ * @param {Object} definitions
+ * @param {string} group
+ * @returns {Array} -
+ */
+function parseArgument(definitions, group){
+    if(!(group in definitions)){
+        return null
+    }
+    var result = []
+    var pro = definitions[group]["properties"]
+    for(const key in pro){
+        var arg = {}
+        var argName = pro[key]
+
+        arg["name"] = key
+
+        if("title" in argName){
+            arg["title"] = argName.title
+        }else{
+
+        }
+
+        //如果有allOf表示这个配置字段是一个枚举的, 一般枚举的就是string
+        if("allOf" in argName){
+            const ref = argName.allOf[0]["$ref"]
+            arg["title"] = parseRef(ref)
+            arg["type"] = "enum"
+        }
+
+        if("description" in argName){
+            arg["description"] = argName.description
+        }else{
+            // 没有帮助就没有帮助
+        }
+
+        if("default" in argName){
+            arg["default"] = argName["default"]
+        }else{
+            console.error(arg["title"], 'have not default')
+        }
+
+        if("type" in argName){
+            arg["type"] = argName.type
+        }
+
+        if(arg["type"] === "enum"){
+            arg["options"] = definitions[arg.title]["enum"]
+        }
+
+        result.push(arg)
+
+    }
+    return result
+}
+
+/**
+ * 合并某个group的参数组,
+ * @param {Object} argument
+ * @param {Object} values
+ * @returns {Object} - 就是添加了value这个一个值
+ */
+function mergeArgument(argument, values){
+//    for(let arg in argument){
+//        for(let vname in values){
+//            if(arg.name === vname){
+//                arg["value"] = values[vname]
+//            }
+//        }
+//    }
+    for(let key in argument){
+        const name = argument[key].name
+        if(name in values){
+            argument[key]["value"] = values[name]
+        }
+    }
+    return argument
+}

+ 1 - 1
module/gui/qml/Component/OverStatus.qml

@@ -14,7 +14,7 @@ Item{
         FluText{
         FluText{
             id: menuName
             id: menuName
             Layout.alignment: Qt.AlignVCenter
             Layout.alignment: Qt.AlignVCenter
-            text: MainEvent.menuTitle
+            text: qsTr(MainEvent.menuTitle)
             font: FluTextStyle.BodyStrong
             font: FluTextStyle.BodyStrong
         }
         }
         RunStatusIcon{
         RunStatusIcon{

+ 17 - 1
module/gui/qml/Component/ScriptItem.qml

@@ -6,6 +6,22 @@ FluPaneItem{
     title: "home"
     title: "home"
     icon:FluentIcons.Play36
     icon:FluentIcons.Play36
     onTap:{
     onTap:{
-        navigationView.push(Qt.resolvedUrl("../../qml/Page/ScriptView.qml"))
+//        var component = Qt.createComponent("../../qml/Page/ScriptView.qml")
+//        if (component.status === Component.Ready) {
+//            var object = component.createObject(navigationView);
+
+//            if (object !== null) {
+//                object.configName = title
+//                // 创建成功,可以进行操作
+//                console.debug('创建成功')
+//                navigationView.push(object)
+
+//            }else{
+//                // 创建失败
+//            }
+//        }else{
+//            // 组件加载失败
+//        }
+    navigationView.pushScript(Qt.resolvedUrl("../../qml/Page/ScriptView.qml"), title)
     }
     }
 }
 }

+ 17 - 9
module/gui/qml/Component/SplitPanel.qml

@@ -47,15 +47,8 @@ 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){
@@ -64,6 +57,9 @@ Item {
             }else{
             }else{
                 var da = []
                 var da = []
                 for(var item in data[items]){
                 for(var item in data[items]){
+                    if (typeof data[items][item] !== "string") {
+                      continue
+                    }
                     da.push(menu_tree.createItem(data[items][item], false))
                     da.push(menu_tree.createItem(data[items][item], false))
                 }
                 }
                 datas.push(menu_tree.createItem(items, true, da))
                 datas.push(menu_tree.createItem(items, true, da))
@@ -100,10 +96,22 @@ Item {
 //    function getDefalut(){
 //    function getDefalut(){
 //        return contentDefalut.item
 //        return contentDefalut.item
 //    }
 //    }
-//    //方便更改属性
+    //方便更改属性
 //    function getDefalut(){
 //    function getDefalut(){
 //        return contentLoader.item
 //        return contentLoader.item
 //    }
 //    }
+    //设置右边显示的参数项,输入的序列的字符串
+    function setLoaderData(args, value){
+        contentLoader.item.argsData = args
+        contentLoader.item.valueData = value
+        contentLoader.item.updataData()
+    }
+
+    //设置上下文
+    function setLoaderContext(configName, taskName){
+        contentLoader.item.configName = configName
+        contentLoader.item.taskName = taskName
+    }
 
 
 
 
 }
 }

+ 5 - 5
module/gui/qml/Global/ItemsFooter.qml

@@ -13,27 +13,27 @@ 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
-            navigationView.push(Qt.resolvedUrl("../../qml/Page/O_Settings.qml"))
+//            navigationView.push(Qt.resolvedUrl("../../qml/Page/O_Settings.qml"))
+            navigationView.pushScript(Qt.resolvedUrl("../../qml/Page/O_Settings.qml"), "settings")
         }
         }
     }
     }
 
 

+ 3 - 3
module/gui/qml/Global/ItemsOriginal.qml

@@ -9,10 +9,11 @@ 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"))
+            navigationView.pushScript(Qt.resolvedUrl("../../qml/Page/O_Home.qml"), "home")
         }
         }
     }
     }
     function getRecentlyAddedData(){
     function getRecentlyAddedData(){
@@ -102,7 +103,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)
     }
     }
 }
 }

+ 1 - 0
module/gui/qml/Page/Home.qml

@@ -4,6 +4,7 @@ import FluentUI
 
 
 FluScrollablePage{
 FluScrollablePage{
     spacing: 6
     spacing: 6
+
     Image {
     Image {
         id: name
         id: name
         Layout.preferredHeight: 40
         Layout.preferredHeight: 40

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

@@ -9,13 +9,15 @@ import "../Component"
 
 
 SplitPanel{
 SplitPanel{
 
 
+    property string configName: ""
+
     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 +25,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)

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

@@ -12,6 +12,8 @@ FluScrollablePage{
     bottomPadding:20
     bottomPadding:20
     spacing: 0
     spacing: 0
 
 
+    property string configName: ""
+
     FluArea{
     FluArea{
         Layout.fillWidth: true
         Layout.fillWidth: true
         Layout.topMargin: 0
         Layout.topMargin: 0
@@ -25,12 +27,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 +61,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 +81,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 +121,8 @@ FluScrollablePage{
                 }
                 }
             }
             }
             FluText{
             FluText{
-                text:"native文本渲染"
+                text:qsTr("Native text rendering")
+                font: FluTextStyle.BodyStrong
                 Layout.topMargin: 20
                 Layout.topMargin: 20
             }
             }
             FluToggleSwitch{
             FluToggleSwitch{
@@ -127,5 +135,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
+                        }
+                    }
+                }
+            }
+        }
+    }
+
 
 
 }
 }

+ 19 - 3
module/gui/qml/Page/ScriptView.qml

@@ -7,6 +7,7 @@ import "../Global"
 SplitPanel{
 SplitPanel{
 
 
     property string configName: ""
     property string configName: ""
+
     onTitleChanged: {
     onTitleChanged: {
         if(title === "Overview"){
         if(title === "Overview"){
             showDefalut()
             showDefalut()
@@ -15,23 +16,38 @@ SplitPanel{
             var component = Qt.createComponent("../../qml/Component/Args.qml")
             var component = Qt.createComponent("../../qml/Component/Args.qml")
             if (component.status === Component.Ready) {
             if (component.status === Component.Ready) {
                 setLoader(component)
                 setLoader(component)
+                var args = process_manager.gui_args(configName, title)
+                var value = process_manager.gui_task(configName, title)
+                setLoaderData(args, value)
+                setLoaderContext(configName, title)
             }else{
             }else{
                 // 组件加载失败
                 // 组件加载失败
             }
             }
         }
         }
     }
     }
 
 
+    onConfigNameChanged: {
+        if(configName === ""){
+            console.info('configname is emtry')
+            return
+        }
+        var data = JSON.parse(process_manager.gui_menu(configName))
+        create(data)
+    }
+
 
 
     Component.onCompleted:{
     Component.onCompleted:{
-        var data = {'Overview':[], 'Script': ['Script', 'General', 'Restart']}
-        create(data)
+
+
+//        var data = {'Overview':[], 'Script': ['Script', 'General', 'Restart']}
+
 
 
         var component = Qt.createComponent("../../qml/Component/Overview.qml")
         var component = Qt.createComponent("../../qml/Component/Overview.qml")
         if (component.status === Component.Ready) {
         if (component.status === Component.Ready) {
             setDefalut(component)
             setDefalut(component)
         } else {
         } else {
             // 组件加载失败
             // 组件加载失败
-            console.debug('组件加载失败')
+            console.debug('组件!加载失败')
         }
         }
     }
     }
 }
 }

+ 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('管理员身份运行')

+ 7 - 0
module/tasks/General/config.py

@@ -0,0 +1,7 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+from pydantic import BaseModel, ValidationError, validator, Field
+
+from module.logger import logger

+ 10 - 0
module/tasks/Restart/config.py

@@ -0,0 +1,10 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from pydantic import BaseModel, ValidationError, validator, Field
+
+from module.logger import logger
+from module.tasks.Restart.config_scheduler import Scheduler
+
+class Restart(BaseModel):
+    scheduler: Scheduler = Field(default_factory=Scheduler)

+ 22 - 0
module/tasks/Restart/config_scheduler.py

@@ -0,0 +1,22 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from enum import Enum
+from datetime import datetime, time
+from pydantic import BaseModel, ValidationError, validator, Field
+
+from module.logger import logger
+
+class Scheduler(BaseModel):
+    enable: bool = Field(default=False,
+                         description='none')
+    next_run: datetime = Field(default="2023-01-01 00:00:00",
+                               description='none')
+    command: str = Field(default='Restart',
+                         description='none')
+    success_interval: float = Field(default=0,
+                                    description='none')
+    failure_interval: float = Field(default=0,
+                                    description='none')
+    server_update: time = Field(default="00:00",
+                                description='none')

+ 14 - 0
module/tasks/Script/config.py

@@ -0,0 +1,14 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from pydantic import BaseModel, ValidationError, validator, Field
+
+from module.tasks.Script.config_device import Device
+from module.tasks.Script.config_error import Error
+from module.tasks.Script.config_optimization import Optimization
+from module.logger import logger
+
+class Script(BaseModel):
+    device: Device = Field(default_factory=Device)
+    error: Error = Field(default_factory=Error)
+    optimization: Optimization = Field(default_factory=Optimization)

+ 52 - 0
module/tasks/Script/config_device.py

@@ -0,0 +1,52 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from enum import Enum
+from pydantic import BaseModel, ValidationError, validator, Field
+
+from module.logger import logger
+
+class PackageName(str, Enum):
+    AUTO = 'auto'
+    NETEASE_ONMYOJI = 'com.netease.onmyoji.wyzymnqsd_cps'  # 网易自家的阴阳师
+
+class ScreenshotMethod(str, Enum):
+    ADB = 'adb'
+    ADB_NC = 'adb_nc'
+    UIAUTOMATOR2 = 'uiautomator2'
+    DROIDCAST = 'droidcast'
+    DROIDCAST_RAW = 'droidcast_raw'
+    SCRCPY = 'scrcpy'
+    WINDOW_BACKGROUND = 'window_background'
+
+class ControlMethod(str, Enum):
+    ADB = 'adb'
+    UIAUTOMATOR2 = 'uiautomator2'
+    MINITOUCH = 'minitouch'
+    WINDOW_MESSAGE = 'window_message'
+
+
+class Device(BaseModel):
+    serial: str = Field(default="127.0.0.1:7555",
+                        description='Common emulator Serial can be queried in the list belowUse "auto" to auto-detect emulators, but if multiple emulators are running or use emulators that do not support auto-detect, "auto" cannot be used and serial must be filled in manually')
+    handle: str = Field(default='auto',
+                        description='you can use auto or your emulator title')
+    package_name: PackageName = Field(default=PackageName.AUTO,
+                                      description='package name')
+    screenshot_method: ScreenshotMethod = Field(default=ScreenshotMethod.WINDOW_BACKGROUND,
+                                                description='only support window')
+    control_method: ControlMethod = Field(default=ControlMethod.WINDOW_MESSAGE,
+                                          description='only support window')
+    adb_restart: bool = Field(default=False,
+                              description='')
+
+
+
+if __name__ == '__main__':
+    d = Device()
+    print(d.json())
+    print(d.schema_json())
+    try:
+        d.control_method = 'adb'
+    except ValidationError as e:
+        print(e)

+ 15 - 0
module/tasks/Script/config_error.py

@@ -0,0 +1,15 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from pydantic import BaseModel, ValidationError, validator, Field
+
+from module.logger import logger
+
+
+class Error(BaseModel):
+    handle_error: bool = Field(default=False,
+                               description='none')
+    save_error: bool = Field(default=False,
+                             description='none')
+    screenshot_length: int = Field(default=1,
+                                   description='The number of recent screenshots to save when something goes wrong')

+ 21 - 0
module/tasks/Script/config_optimization.py

@@ -0,0 +1,21 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from enum import Enum
+from pydantic import BaseModel, ValidationError, validator, Field
+
+from module.logger import logger
+
+class WhenTaskQueueEmpty(str, Enum):
+    GOTO_HOME = 'goto_home'
+    CLOSE_GAME = 'close_game'
+
+class Optimization(BaseModel):
+    screenshot_interval: float = Field(default=0.3,
+                                       description='none')
+    combat_screenshot_interval: float = Field(default=1.0,
+                                              description='none')
+    task_hoarding_duration: float = Field(default=0,
+                                          description='none')
+    when_task_queue_empty: WhenTaskQueueEmpty = Field(default=WhenTaskQueueEmpty.GOTO_HOME,
+                                                      description='you can select goto home where nothing to do')

+ 3 - 1
requirements-in.txt

@@ -9,4 +9,6 @@ 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
+pydantic==1.10.7

+ 3 - 1
requirements.txt

@@ -36,6 +36,7 @@ pillow==9.5.0             # via uiautomator2
 progress==1.6             # via uiautomator2
 progress==1.6             # via uiautomator2
 py==1.11.0                # via retry
 py==1.11.0                # via retry
 pycparser==2.21           # via cffi
 pycparser==2.21           # via cffi
+pydantic==1.10.7          # via -r requirements-in.txt
 pyelftools==0.29          # via apkutils2
 pyelftools==0.29          # via apkutils2
 pygments==2.15.1          # via rich
 pygments==2.15.1          # via rich
 pyparsing==3.0.9          # via packaging
 pyparsing==3.0.9          # via packaging
@@ -50,11 +51,12 @@ retry==0.9.2              # via adbutils, uiautomator2
 rich==13.3.5              # via -r requirements-in.txt
 rich==13.3.5              # via -r requirements-in.txt
 shiboken6==6.4.3          # via pyside6, pyside6-addons, pyside6-essentials
 shiboken6==6.4.3          # via pyside6, pyside6-addons, pyside6-essentials
 six==1.16.0               # via adbutils, anytree, uiautomator2
 six==1.16.0               # via adbutils, anytree, uiautomator2
+typing-extensions==4.5.0  # via pydantic
 uiautomator2==2.16.17     # via -r requirements-in.txt
 uiautomator2==2.16.17     # via -r requirements-in.txt
 urllib3==2.0.2            # via requests
 urllib3==2.0.2            # via requests
 websockets==11.0.3        # via -r requirements-in.txt
 websockets==11.0.3        # via -r requirements-in.txt
 whichcraft==0.6.1         # via adbutils, uiautomator2
 whichcraft==0.6.1         # via adbutils, uiautomator2
-wrapt==1.15.0             # via deprecated
+wrapt==1.15.0             # via -r requirements-in.txt, deprecated
 xmltodict==0.13.0         # via apkutils2
 xmltodict==0.13.0         # via apkutils2
 zerorpc==0.6.3            # via -r requirements-in.txt
 zerorpc==0.6.3            # via -r requirements-in.txt
 zope-event==4.6           # via gevent
 zope-event==4.6           # via gevent

+ 69 - 12
script.py

@@ -5,7 +5,9 @@ import zerorpc
 import zmq
 import zmq
 import random
 import random
 from cached_property import cached_property
 from cached_property import cached_property
+from pydantic import BaseModel, ValidationError
 
 
+from module.config.utils import convert_to_underscore
 from module.logger import logger
 from module.logger import logger
 from module.exception import *
 from module.exception import *
 
 
@@ -27,18 +29,18 @@ class Script:
             logger.exception(e)
             logger.exception(e)
             exit(1)
             exit(1)
 
 
-    @cached_property
-    def device(self) -> "Device":
-        try:
-            from module.device.device import Device
-            device = Device(config=self.config)
-            return device
-        except RequestHumanTakeover:
-            logger.critical('Request human takeover')
-            exit(1)
-        except Exception as e:
-            logger.exception(e)
-            exit(1)
+    # @cached_property
+    # def device(self) -> "Device":
+    #     try:
+    #         from module.device.device import Device
+    #         device = Device(config=self.config)
+    #         return device
+    #     except RequestHumanTakeover:
+    #         logger.critical('Request human takeover')
+    #         exit(1)
+    #     except Exception as e:
+    #         logger.exception(e)
+    #         exit(1)
 
 
     def init_server(self, port: int) -> int:
     def init_server(self, port: int) -> int:
         """
         """
@@ -61,3 +63,58 @@ class Script:
         """
         """
         self.server.run()
         self.server.run()
 
 
+    def gui_args(self, task: str) -> str:
+        """
+        获取给gui显示的参数
+        :return:
+        """
+        return self.config.gui_args(task=task)
+
+    def gui_menu(self) -> str:
+        """
+        获取给gui显示的菜单
+        :return:
+        """
+        return self.config.gui_menu
+
+    def gui_task(self, task: str) -> str:
+        """
+        获取给gui显示的任务 的参数的具体值
+        :return:
+        """
+        return self.config.model.gui_task(task=task)
+
+    def gui_set_task(self, task: str, group: str, argument: str, value) -> bool:
+        """
+        设置给gui显示的任务 的参数的具体值
+        :return:
+        """
+        task = convert_to_underscore(task)
+        group = convert_to_underscore(group)
+        argument = convert_to_underscore(argument)
+
+        path = f'{task}.{group}.{argument}'
+        task_object = getattr(self.config.model, task, None)
+        group_object = getattr(task_object, group, None)
+        argument_object = getattr(group_object, argument, None)
+
+        if argument_object is None:
+            logger.error(f'gui_set_task {task}.{group}.{argument}.{value} failed')
+            return False
+
+        try:
+            setattr(group_object, argument, value)
+            argument_object = getattr(group_object, argument, None)
+            logger.info(f'gui_set_task {task}.{group}.{argument}.{argument_object}')
+            self.config.save()  # 我是没有想到什么方法可以使得属性改变自动保存的
+            return True
+        except ValidationError as e:
+            logger.error(e)
+            return False
+
+
+if __name__ == "__main__":
+    script = Script("oas1")
+    print(script.config.model.json())
+    script.gui_set_task("Script", "device", "serial", "175")
+    print(script.config.script.device.serial)