Ver Fonte

perf(gui): overview user click

runhey há 3 anos atrás
pai
commit
aec11541df

+ 1 - 1
module/config/config_manual.py

@@ -9,7 +9,7 @@ class ConfigManual:
 
 
     SCHEDULER_PRIORITY = """
     SCHEDULER_PRIORITY = """
         Restart
         Restart
-        > AreaBoss > GoldYoukai > ExperienceYoukai > Nian
+        > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > RealmRaid
         > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea
         > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea
         """
         """
 
 

+ 37 - 11
module/gui/qml/Component/Overview.qml

@@ -35,6 +35,7 @@ Item {
             height: 50
             height: 50
             RowLayout{
             RowLayout{
                 anchors.fill: parent
                 anchors.fill: parent
+                property int scriptState: 0  // 0是
                 FluText{
                 FluText{
                     text: 'Scheduler'
                     text: 'Scheduler'
                     Layout.leftMargin: 16
                     Layout.leftMargin: 16
@@ -48,27 +49,36 @@ Item {
                     onClicked: {
                     onClicked: {
                         showSuccess("Restart"+" "+configName)
                         showSuccess("Restart"+" "+configName)
                         process_manager.restart(configName)
                         process_manager.restart(configName)
-                        startStart.selected = true
-                        textLog.text = ""
+                        setStatus(MainEvent.RunStatus.Free)
                     }
                     }
                 }
                 }
                 FluToggleButton{
                 FluToggleButton{
                     id: startStart
                     id: startStart
                     Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
                     Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
                     Layout.rightMargin: 16
                     Layout.rightMargin: 16
-                    text:"Start"
-                    selected: true
+                    text: {if(overStatus.runStatus === MainEvent.RunStatus.Stop){return "Stop"}
+                           else{return "Start"}}
+                    selected: {if(overStatus.runStatus === MainEvent.RunStatus.Free){return true}
+                                else{return false}}
+                    disabled: {if(overStatus.runStatus === MainEvent.RunStatus.Error ||
+                                  overStatus.runStatus === MainEvent.RunStatus.Empty){return true}
+                               else{return false}
+                    }
                     onClicked: {
                     onClicked: {
-                        selected = !selected
-                        if(selected){
-                            text = "Start"                          
-                            process_manager.stop_script(root.configName)
-                        }else{
-                            // 如果按键颜色变灰色
-                            text = "Stop"
+                        if(overStatus.runStatus === MainEvent.RunStatus.Free){
+                            //如果这个时候初始化好了但是还没有运行脚本
+                            setStatus(MainEvent.RunStatus.Run)
                             process_manager.start_script(root.configName)
                             process_manager.start_script(root.configName)
+                            return
+                        }
+                        if(overStatus.runStatus === MainEvent.RunStatus.Run){
+                            // 如果这个时候运行中
+                            setStatus(MainEvent.RunStatus.Emtpy)
+                            process_manager.stop_script(root.configName)
+                            return
                         }
                         }
                     }
                     }
+
                 }
                 }
             }
             }
         }
         }
@@ -300,6 +310,8 @@ Item {
             padding: 10
             padding: 10
             clip: true
             clip: true
             wrapMode: Text.WordWrap // 设置自动换行模式
             wrapMode: Text.WordWrap // 设置自动换行模式
+            maximumLineCount: 100
+            property int currentLine: 0
             textFormat: Text.RichText
             textFormat: Text.RichText
             text: ''
             text: ''
 
 
@@ -307,7 +319,21 @@ Item {
                 if(config !== root.configName){
                 if(config !== root.configName){
                     return
                     return
                 }
                 }
+                if(log.includes('ERROR') || log.includes('CRITICAL')){
+                    setStatus(MainEvent.RunStatus.Error)
+                }
+
+
+                if (currentLine > maximumLineCount) {
+                    var index = textLog.text.indexOf("<br>"); //找到第一个<br>的位置
+                    if (index !== -1) {
+                        textLog.text = textLog.text.substring(index + 4); //从<br>之后开始截取字符串
+                        currentLine -= 1
+                    }
+                }
+                currentLine += 1
                 textLog.text += log
                 textLog.text += log
+
             }
             }
 
 
             Component.onCompleted:{
             Component.onCompleted:{

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

@@ -82,11 +82,13 @@ Item {
     function showDefalut(){
     function showDefalut(){
         contentDefalut.visible = true
         contentDefalut.visible = true
         contentLoader.visible = false
         contentLoader.visible = false
+        contentDefalut.focus = true
     }
     }
     //显示不固定的
     //显示不固定的
     function showLoader(){
     function showLoader(){
         contentDefalut.visible = false
         contentDefalut.visible = false
         contentLoader.visible = true
         contentLoader.visible = true
+        contentLoader.focus = true
     }
     }
 
 
     //设置固定的部分的具体内容  主要是传一个组件
     //设置固定的部分的具体内容  主要是传一个组件

+ 1 - 1
script.py

@@ -203,7 +203,7 @@ class Script:
             task["next_run"] = str(self.config.task.next_run)
             task["next_run"] = str(self.config.task.next_run)
         data["task"] = task
         data["task"] = task
 
 
-        for p in self.config.pending_task:
+        for p in self.config.pending_task[1:]:
             item = {"name": p.command, "next_run": str(p.next_run)}
             item = {"name": p.command, "next_run": str(p.next_run)}
             pending.append(item)
             pending.append(item)
 
 

+ 1 - 1
tasks/AreaBoss/config.py

@@ -3,7 +3,7 @@
 # github https://github.com/runhey
 # github https://github.com/runhey
 from pydantic import BaseModel, Field
 from pydantic import BaseModel, Field
 
 
-from tasks.AreaBoss.config_scheduler import Scheduler
+from tasks.Utils.config_scheduler import Scheduler
 from tasks.GeneralBattle.config_general_battle import GeneralBattleConfig
 from tasks.GeneralBattle.config_general_battle import GeneralBattleConfig
 from tasks.AreaBoss.config_boss import Boss
 from tasks.AreaBoss.config_boss import Boss
 
 

+ 9 - 0
tasks/AreaBoss/config_scheduler.py

@@ -13,3 +13,12 @@ class Scheduler(BaseModel):
     interval_hours: int = Field(default=0, description='[间隔小时]:默认为0\n 可选0-23')
     interval_hours: int = Field(default=0, description='[间隔小时]:默认为0\n 可选0-23')
     interval_minutes: int = Field(default=0, description='[间隔分钟]:默认为0\n 可选0-59')
     interval_minutes: int = Field(default=0, description='[间隔分钟]:默认为0\n 可选0-59')
 
 
+    @validator('next_run')
+    def parse_next_run(cls, value):
+        if isinstance(value, str):
+            try:
+                return datetime.fromisoformat(value)
+            except ValueError:
+                raise ValueError('Invalid next_run value. Expected format: YYYY-MM-DD HH:MM:SS')
+        return value
+

+ 1 - 1
tasks/RealmRaid/config.py

@@ -4,7 +4,7 @@
 from pydantic import BaseModel, Field
 from pydantic import BaseModel, Field
 from enum import Enum
 from enum import Enum
 
 
-from tasks.RealmRaid.config_scheduler import Scheduler
+from tasks.Utils.config_scheduler import Scheduler
 from tasks.GeneralBattle.config_general_battle import GeneralBattleConfig
 from tasks.GeneralBattle.config_general_battle import GeneralBattleConfig
 
 
 
 

+ 10 - 0
tasks/RealmRaid/config_scheduler.py

@@ -12,3 +12,13 @@ class Scheduler(BaseModel):
     interval_hours: int = Field(default=0, description='[间隔小时]:默认为0\n 可选0-23')
     interval_hours: int = Field(default=0, description='[间隔小时]:默认为0\n 可选0-23')
     interval_minutes: int = Field(default=0, description='[间隔分钟]:默认为0\n 可选0-59')
     interval_minutes: int = Field(default=0, description='[间隔分钟]:默认为0\n 可选0-59')
 
 
+    @validator('next_run', pre=True, always=True)
+    def parse_next_run(cls, value):
+        if isinstance(value, str):
+            print('parse_next_run')
+            try:
+                return datetime.fromisoformat(value)
+            except ValueError:
+                raise ValueError('Invalid next_run value. Expected format: YYYY-MM-DD HH:MM:SS')
+        return value
+

+ 24 - 0
tasks/Utils/config_scheduler.py

@@ -0,0 +1,24 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from enum import Enum
+from datetime import datetime, timedelta
+from pydantic import BaseModel, ValidationError, validator, Field
+
+class Scheduler(BaseModel):
+    enable: bool = Field(default=False, description='[是否启用]:默认为False')
+    next_run: datetime = Field(default="2023-01-01 00:00:00", description='[下次执行时间]:默认为2023-01-01 00:00:00\n 清空后回车设置当前的时间')
+    interval_days: int = Field(default=1, description='[间隔天数]:默认为1\n 可选0-7')
+    interval_hours: int = Field(default=0, description='[间隔小时]:默认为0\n 可选0-23')
+    interval_minutes: int = Field(default=0, description='[间隔分钟]:默认为0\n 可选0-59')
+
+    @validator('next_run', pre=True, always=True)
+    def parse_next_run(cls, value):
+        if isinstance(value, str):
+            print('parse_next_run')
+            try:
+                return datetime.fromisoformat(value)
+            except ValueError:
+                raise ValueError('Invalid next_run value. Expected format: YYYY-MM-DD HH:MM:SS')
+        return value
+