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

Merge pull request #11 from runhey/dev

Dev
huangrunheng 3 лет назад
Родитель
Сommit
3927974ed4
36 измененных файлов с 1931 добавлено и 35 удалено
  1. 2 2
      README.md
  2. 160 0
      module/atom/cBezier.py
  3. 69 0
      module/atom/click.py
  4. 142 0
      module/atom/image.py
  5. 23 0
      module/atom/long_click.py
  6. 3 0
      module/atom/ocr.py
  7. 111 0
      module/atom/swipe.py
  8. 1 1
      module/config/argument/setting-template.json
  9. 3 4
      module/config/config_model.py
  10. BIN
      module/config/i18n/zh_CN.qm
  11. 24 0
      module/config/i18n/zh_CN.ts
  12. 284 0
      module/dev_tools/assets_extract.py
  13. 27 4
      module/gui/fluent_app.py
  14. 0 1
      module/gui/qml/Component/RuleFile.qml
  15. 318 1
      module/gui/qml/Content/ClickRule.qml
  16. 3 3
      module/gui/qml/Content/ImageRule.qml
  17. 277 1
      module/gui/qml/Content/LongClickRule.qml
  18. 287 1
      module/gui/qml/Content/SwipeRule.qml
  19. 38 8
      module/gui/qml/Global/MainEvent.qml
  20. 37 0
      module/gui/qml/Page/O_Settings.qml
  21. 0 1
      module/tasks/CoinChallenge/res/test.json
  22. 41 0
      tasks/CoinChallenge/assets.py
  23. BIN
      tasks/CoinChallenge/res/res_new1.png
  24. BIN
      tasks/CoinChallenge/res/res_new2.png
  25. BIN
      tasks/CoinChallenge/res/res_new3.png
  26. 1 0
      tasks/CoinChallenge/res/test.json
  27. 20 0
      tasks/CoinChallenge/res/test_click.json
  28. 23 0
      tasks/CoinChallenge/res/test_long_click.json
  29. 30 0
      tasks/CoinChallenge/res/test_swipe.json
  30. 0 0
      tasks/General/config.py
  31. 2 3
      tasks/Restart/config.py
  32. 0 0
      tasks/Restart/config_scheduler.py
  33. 5 5
      tasks/Script/config.py
  34. 0 0
      tasks/Script/config_device.py
  35. 0 0
      tasks/Script/config_error.py
  36. 0 0
      tasks/Script/config_optimization.py

+ 2 - 2
README.md

@@ -1,4 +1,4 @@
-![image-20230526205041711](https://runhey-img-stg1.oss-cn-chengdu.aliyuncs.com/img2/202305262050939.png)
+![image-20230605215659764](https://runhey-img-stg1.oss-cn-chengdu.aliyuncs.com/img2/202306052157563.png)
 
 
 ## 设计思路(其实大部分就是alas的设计)
 ## 设计思路(其实大部分就是alas的设计)
 
 
@@ -98,7 +98,7 @@ oas目前还在开发中,我们期待你的加入,Q群: 465946275
 | ✔config读写参数字段                                          |
 | ✔config读写参数字段                                          |
 | ✔优化window截图+控制                                         |
 | ✔优化window截图+控制                                         |
 | ✔投屏到OAS                                                   |
 | ✔投屏到OAS                                                   |
-| 🔨操作格式化json生成工具:可以从用户界面简单操作生成维护数据(包括✔图片匹配,点击操作,长按操作,滑动操作,ocr识别等等) |
+| 🔨操作格式化json生成工具:可以从用户界面简单操作生成维护数据(包括✔图片匹配,✔点击操作,✔长按操作,✔滑动操作,ocr识别等等) |
 | 📆Atom: 对于上一条数据的接口                                  |
 | 📆Atom: 对于上一条数据的接口                                  |
 | 📆实现ocr单独进程                                             |
 | 📆实现ocr单独进程                                             |
 | 📆到此我们可以(读参数)、(对游戏截屏控制)、(操控数据)。实现第一个脚本任务如挖土 |
 | 📆到此我们可以(读参数)、(对游戏截屏控制)、(操控数据)。实现第一个脚本任务如挖土 |

+ 160 - 0
module/atom/cBezier.py

@@ -0,0 +1,160 @@
+'''
+author: cbb
+这个库基于贝塞尔曲线实现模拟人手动滑动的轨迹
+可以用于selenium轨迹的模拟,或者生成轨迹数组用于js加密通过网站服务器后端分控检测
+QQ群 134064772
+里面的人说话好听,个个都是人才
+'''
+
+import numpy as np
+import math
+import random
+
+class BezierTrajectory:
+
+    @classmethod
+    def _bztsg(cls, dataTrajectory):
+        lengthOfdata = len(dataTrajectory)
+
+        def staer(x):
+            t = ((x - dataTrajectory[0][0]) / (dataTrajectory[-1][0] - dataTrajectory[0][0]))
+            y = np.array([0, 0], dtype=np.float64)
+            for s in range(len(dataTrajectory)):
+                y += dataTrajectory[s] * ((math.factorial(lengthOfdata - 1) / (
+                            math.factorial(s) * math.factorial(lengthOfdata - 1 - s))) * math.pow(t, s) * math.pow(
+                    (1 - t), lengthOfdata - 1 - s))
+            return y[1]
+
+        return staer
+
+    @classmethod
+    def _type(cls, type, x, numberList):
+        numberListre = []
+        pin = (x[1] - x[0]) / numberList
+        if type == 0:
+            for i in range(numberList):
+                numberListre.append(i * pin)
+            if pin >= 0:
+                numberListre = numberListre[::-1]
+        elif type == 1:
+            for i in range(numberList):
+                numberListre.append(1 * ((i * pin) ** 2))
+            numberListre = numberListre[::-1]
+        elif type == 2:
+            for i in range(numberList):
+                numberListre.append(1 * ((i * pin - x[1]) ** 2))
+
+        elif type == 3:
+            dataTrajectory = [np.array([0,0]), np.array([(x[1]-x[0])*0.8, (x[1]-x[0])*0.6]), np.array([x[1]-x[0], 0])]
+            fun = cls._bztsg(dataTrajectory)
+            numberListre = [0]
+            for i in range(1,numberList):
+                numberListre.append(fun(i * pin) + numberListre[-1])
+            if pin >= 0:
+                numberListre = numberListre[::-1]
+        numberListre = np.abs(np.array(numberListre) - max(numberListre))
+        biaoNumberList = ((numberListre - numberListre[numberListre.argmin()]) / (
+                    numberListre[numberListre.argmax()] - numberListre[numberListre.argmin()])) * (x[1] - x[0]) + x[0]
+        biaoNumberList[0] = x[0]
+        biaoNumberList[-1] = x[1]
+        return biaoNumberList
+
+    @classmethod
+    def getFun(cls, s):
+        '''
+
+        :param s: 传入P点
+        :return: 返回公式
+        '''
+        dataTrajectory = []
+        for i in s:
+            dataTrajectory.append(np.array(i))
+        return cls._bztsg(dataTrajectory)
+
+    @classmethod
+    def simulation(cls, start, end, le=1, deviation=0, bias=0.5):
+        '''
+
+        :param start:开始点的坐标 如 start = [0, 0]
+        :param end:结束点的坐标 如 end = [100, 100]
+        :param le:几阶贝塞尔曲线,越大越复杂 如 le = 4
+        :param deviation:轨迹上下波动的范围 如 deviation = 10
+        :param bias:波动范围的分布位置 如 bias = 0.5
+        :return:返回一个字典equation对应该曲线的方程,P对应贝塞尔曲线的影响点
+        '''
+        start = np.array(start)
+        end = np.array(end)
+        cbb = []
+        if le != 1:
+            e = (1 - bias) / (le - 1)
+            cbb = [[bias + e * i, bias + e * (i + 1)] for i in range(le - 1)]
+
+        dataTrajectoryList = [start]
+
+        t = random.choice([-1, 1])
+        w = 0
+        for i in cbb:
+            px1 = start[0] + (end[0] - start[0]) * (random.random() * (i[1] - i[0]) + (i[0]))
+            p = np.array([px1, cls._bztsg([start, end])(px1) + t * deviation])
+            dataTrajectoryList.append(p)
+            w += 1
+            if w >= 2:
+                w = 0
+                t = -1 * t
+
+        dataTrajectoryList.append(end)
+        return {"equation": cls._bztsg(dataTrajectoryList), "P": np.array(dataTrajectoryList)}
+
+    @classmethod
+    def trackArray(cls, start, end, numberList, le=1, deviation=0, bias=0.5, type=0, cbb=0, yhh=10):
+        '''
+
+        :param start:开始点的坐标 如 start = [0, 0]
+        :param end:结束点的坐标 如 end = [100, 100]
+        :param numberList:返回的数组的轨迹点的数量 numberList = 150
+        :param le:几阶贝塞尔曲线,越大越复杂 如 le = 4
+        :param deviation:轨迹上下波动的范围 如 deviation = 10
+        :param bias:波动范围的分布位置 如 bias = 0.5
+        :param type:0表示均速滑动,1表示先慢后快,2表示先快后慢,3表示先慢中间快后慢 如 type = 1
+        :param cbb:在终点来回摆动的次数
+        :param yhh:在终点来回摆动的范围
+        :return:返回一个字典trackArray对应轨迹数组,P对应贝塞尔曲线的影响点
+        '''
+        s = []
+        fun = cls.simulation(start, end, le, deviation, bias)
+        w = fun['P']
+        fun = fun["equation"]
+        if cbb != 0:
+            numberListOfcbb = round(numberList*0.2/(cbb+1))
+            numberList -= (numberListOfcbb*(cbb+1))
+
+            xTrackArray = cls._type(type, [start[0], end[0]], numberList)
+            for i in xTrackArray:
+                s.append([i, fun(i)])
+            dq = yhh/cbb
+            kg = 0
+            ends = np.copy(end)
+            for i in range(cbb):
+                if kg == 0:
+                    d = np.array([end[0] + (yhh-dq*i), ((end[1]-start[1])/(end[0]-start[0]))*(end[0]+(yhh-dq*i)) +(end[1]-((end[1]-start[1])/(end[0]-start[0]))*end[0])   ])
+                    kg = 1
+                else:
+                    d = np.array([end[0] - (yhh - dq * i), ((end[1]-start[1])/(end[0]-start[0]))*(end[0]-(yhh-dq*i)) +(end[1]-((end[1]-start[1])/(end[0]-start[0]))*end[0])  ])
+                    kg = 0
+                print(d)
+                y = cls.trackArray(ends, d, numberListOfcbb, le=2, deviation=0, bias=0.5, type=0, cbb=0, yhh=10)
+                s += list(y['trackArray'])
+                ends = d
+            y = cls.trackArray(ends, end, numberListOfcbb, le=2, deviation=0, bias=0.5, type=0, cbb=0, yhh=10)
+            s += list(y['trackArray'])
+
+        else:
+            xTrackArray = cls._type(type, [start[0], end[0]], numberList)
+            for i in xTrackArray:
+                s.append([i, fun(i)])
+        # return {"trackArray": np.array(s), "P": w}
+        return [[int(s[0]), int(s[1])] for s in s]
+
+# print(BezierTrajectory.trackArray(start=[0, 0], end=[100, 100], numberList=50, le=2,
+#                     deviation=0, bias=0.5, type=0, cbb=0, yhh=10))
+

+ 69 - 0
module/atom/click.py

@@ -0,0 +1,69 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import numpy as np
+
+from module.base.decorator import cached_property
+from module.logger import logger
+
+class RuleClick:
+
+    def __init__(self, roi_front: tuple, roi_back: tuple) -> None:
+        """
+        初始化
+        :param roi_front:
+        :param roi_back:
+        """
+        self.roi_front = roi_front
+        self.roi_back = roi_back
+
+    def coord(self) -> tuple:
+        """
+        获取坐标, 从roi_front随机获取坐标
+        :return:
+        """
+        x, y, w, h = self.roi_front
+        x = np.random.randint(x, x + w)
+        y = np.random.randint(y, y + h)
+        return x, y
+
+    def coord_more(self) -> tuple:
+        """
+        从roi_back随机获取坐标
+        :return:
+        """
+        x, y, w, h = self.roi_back
+        x = np.random.randint(x, x + w)
+        y = np.random.randint(y, y + h)
+        return x, y
+
+    @property
+    def center(self) -> tuple:
+        """
+        返回roi_front的中心坐标
+        :return:
+        """
+        x, y, w, h = self.roi_front
+        return x + w // 2, y + h // 2
+
+    def move(self, x: int, y: int) -> None:
+        """
+        移动roi_front, 需要限幅x是0-1280, y是0-720
+        :param x:
+        :param y:
+        :return:
+        """
+        x, y, w, h = self.roi_front
+        x += x
+        y += y
+        if x <= 0 :
+            x = 0
+        elif x >= 1280:
+            x = 1280
+
+        if y <= 0 :
+            y = 0
+        elif y >= 720:
+            y = 720
+
+        self.roi_front = x, y, w, h

+ 142 - 0
module/atom/image.py

@@ -0,0 +1,142 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import cv2
+import numpy as np
+
+from numpy import float32, int32, uint8, fromfile
+from pathlib import Path
+
+from module.base.decorator import cached_property
+from module.logger import logger
+
+class RuleImage:
+
+    def __init__(self, roi_front: tuple, roi_back: tuple, method: str, threshold: float, file: str) -> None:
+        """
+        初始化
+        :param roi_front: 前置roi
+        :param roi_back: 后置roi 用于匹配的区域
+        :param method: 匹配方法
+        :param threshold: 阈值
+        :param file: 相对路径, 带后缀
+        """
+        self.roi_front = roi_front
+        self.roi_back = roi_back
+        self.method = method
+        self.threshold = threshold
+        self.file = file
+
+        self._image = None  # 这个是匹配的目标
+
+    @cached_property
+    def name(self) -> str:
+        """
+
+        :return:
+        """
+        return Path(self.file).stem
+
+    def __str__(self):
+        return self.name
+
+    __repr__ = __str__
+
+    def __eq__(self, other):
+        return str(self) == str(other)
+
+    def __hash__(self):
+        return hash(self.name)
+
+    def __bool__(self):
+        return True
+
+
+
+    def load_image(self) -> None:
+        """
+        加载图片
+        :return:
+        """
+        if self._image is not None:
+            return
+        img = cv2.imdecode(fromfile(self.file, dtype=uint8), -1)
+        # self._image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+        self._image = img
+
+        height, width, channels = self._image.shape
+        if height != self.roi_front[3] or width != self.roi_front[2]:
+            self.roi_front[2] = width
+            self.roi_front[3] = height
+            logger.info(f"roi_front size changed to {width}x{height}")
+
+    @property
+    def image(self):
+        """
+        获取图片
+        :return:
+        """
+        if self._image is None:
+            self.load_image()
+        return self._image
+
+    @cached_property
+    def is_template_match(self) -> bool:
+        """
+        是否是模板匹配
+        :return:
+        """
+        return self.method == "Template matching"
+
+
+    def corp(self, image: np.array) -> np.array:
+        """
+        截取图片
+        :param image:
+        :return:
+        """
+        x, y, w, h = self.roi_back
+        return image[y:y + h, x:x + w]
+
+
+    def match(self, image: np.array, threshold: float = None) -> bool:
+        """
+
+        :param threshold:
+        :param image:
+        :return:
+        """
+        if threshold is None:
+            threshold = self.threshold
+
+        if not self.is_template_match:
+            raise Exception(f"unknown method {self.method}")
+
+        source = self.corp(image)
+        mat = self.image
+        res = cv2.matchTemplate(source, mat, cv2.TM_CCOEFF_NORMED)
+        min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)  # 最小匹配度,最大匹配度,最小匹配度的坐标,最大匹配度的坐标
+        if max_val > threshold:
+            return True
+        else:
+            return False
+
+    def coord(self) -> tuple:
+        """
+        获取roi_front的随机的点击的坐标
+        :return:
+        """
+        x, y, w, h = self.roi_front
+        return x + np.random.randint(0, w), y + np.random.randint(0, h)
+
+    def coord_more(self) -> tuple:
+        """
+         获取roi_back的随机的点击的坐标
+        :return:
+        """
+        x, y, w, h = self.roi_back
+        return x + np.random.randint(0, w), y + np.random.randint(0, h)
+
+
+if __name__ == "__main__":
+    pass

+ 23 - 0
module/atom/long_click.py

@@ -0,0 +1,23 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import numpy as np
+
+from module.base.decorator import cached_property
+from module.logger import logger
+from module.atom.click import RuleClick
+
+
+class RuleLongClick(RuleClick):
+
+    def __init__(self, roi_front: tuple, roi_back: tuple, duration: int = 1000) -> None:
+        """
+        初始化
+        :param roi_front:
+        :param roi_back:
+        :param duration:
+        """
+        super().__init__(roi_front, roi_back)
+        self.duration = duration
+
+

+ 3 - 0
module/atom/ocr.py

@@ -0,0 +1,3 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey

+ 111 - 0
module/atom/swipe.py

@@ -0,0 +1,111 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import numpy as np
+import random
+
+from math import dist
+
+from module.base.decorator import cached_property
+from module.atom.cBezier import BezierTrajectory
+from module.logger import logger
+
+
+class RuleSwipe:
+
+    def __init__(self, roi_front: tuple, roi_back: tuple, mode: str) -> None:
+        """
+        初始化
+        :param roi_front:
+        :param roi_back:
+        :param mode:
+        """
+        self.roi_front = roi_front
+        self.roi_back = roi_back
+        self.mode = mode
+
+        self.interval: int = 8  # 每次移动的间隔时间
+
+    @cached_property
+    def is_default_mode(self) -> bool:
+        """
+        是否是默认模式
+        :return:
+        """
+        return self.mode == 'default'
+
+    @cached_property
+    def is_vector_mode(self) -> bool:
+        """
+        是否是向量模式
+        :return:
+        """
+        return self.mode == 'vector'
+
+    def coord(self) -> tuple:
+        """
+        获取坐标, 从roi_front随机获取坐标 和从roi_back随机获取的坐标
+        :return: 两个坐标的tuple
+        """
+        x, y, w, h = self.roi_front
+        x = np.random.randint(x, x + w)
+        y = np.random.randint(y, y + h)
+        x2, y2, w2, h2 = self.roi_back
+        x2 = np.random.randint(x2, x2 + w2)
+        y2 = np.random.randint(y2, y2 + h2)
+        return x, y, x2, y2
+
+    def trace(self) -> list:
+        """
+        获取滑动的路径,list的每一项都是tuple
+        :return:
+        """
+        if self.is_default_mode:
+            start_pos, end_pos = self.coord()
+            # 表示每秒移动1.5个像素点, 总的时间除以每个点10ms就得到总的点的个数
+            number_list: int = int(dist(start_pos, end_pos) / (1.5 * self.interval))
+            le = random.randint(2, 4)  #
+            deviation = random.randint(20, 40)  # 幅度
+            b_type = 3
+            obbs_type = random.random()  # 0.8的概率是先快中间慢后面快, 0.1概率是先快后慢, 0.1概率先慢后快
+            if 0 < obbs_type <= 0.8:
+                b_type = 3
+            elif obbs_type < 0.9:
+                b_type = 2
+            else:
+                b_type = 1
+
+            return BezierTrajectory.trackArray(start=start_pos, end=end_pos, numberList=number_list, le=le,
+                     deviation=30, bias=0.5, type=b_type, cbb=0, yhh=20)
+
+        elif self.is_vector_mode:
+            # 获取两个点的直线的规矩
+            start_pos, end_pos = self.coord()
+            # 表示每秒移动1.5个像素点, 总的时间除以每个点10ms就得到总的点的个数
+            number_list: int = int(dist(start_pos, end_pos) / (1.5 * self.interval))
+
+            def generate_linear_trajectory(start_pos: tuple, end_pos: tuple, num_points: int) -> list:
+                """
+                生成线性轨迹
+                :param start_pos:
+                :param end_pos:
+                :param num_points:
+                :return:
+                """
+                trajectory = []
+                delta_x = (end_pos[0] - start_pos[0]) / (num_points - 1)
+                delta_y = (end_pos[1] - start_pos[1]) / (num_points - 1)
+                for i in range(num_points):
+                    x = start_pos[0] + delta_x * i
+                    y = start_pos[1] + delta_y * i
+                    trajectory.append((x, y))
+                return trajectory
+
+            return generate_linear_trajectory(start_pos, end_pos, number_list)
+
+        else:
+            raise ValueError(f'Invalid mode: {self.mode}')
+
+
+
+

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

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

+ 3 - 4
module/config/config_model.py

@@ -1,17 +1,16 @@
 # 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 json
 
 
 from pathlib import Path
 from pathlib import Path
-from pydantic import BaseModel, ValidationError, validator, Field, root_validator
+from pydantic import BaseModel, ValidationError, Field
 
 
 from module.config.utils import *
 from module.config.utils import *
 from module.logger import logger
 from module.logger import logger
 
 
 # 导入配置的Python文件
 # 导入配置的Python文件
-from module.tasks.Script.config import Script
-from module.tasks.Restart.config import Restart
+from tasks.Script.config import Script
+from tasks.Restart.config import Restart
 
 
 
 
 
 

BIN
module/config/i18n/zh_CN.qm


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

@@ -73,6 +73,30 @@
         <source>Locale</source>
         <source>Locale</source>
         <translation>语言环境</translation>
         <translation>语言环境</translation>
     </message>
     </message>
+	<message>
+        <source>Dpi Strategy</source>
+        <translation>分辨率DPI缩放策略</translation>
+    </message>
+	<message>
+        <source>default</source>
+        <translation>默认不缩放</translation>
+    </message>
+	<message>
+        <source>floor</source>
+        <translation>始终不缩放</translation>
+    </message>
+	<message>
+        <source>ceil</source>
+        <translation>始终缩放</translation>
+    </message>
+	<message>
+        <source>round</source>
+        <translation>设备像素比0.5及以上的,进行缩放</translation>
+    </message>
+	<message>
+        <source>round_prefer_floor</source>
+        <translation>设备像素比0.75及以上的,进行缩放</translation>
+    </message>
 </context>
 </context>
 <context>
 <context>
     <name>O_Home</name>
     <name>O_Home</name>

+ 284 - 0
module/dev_tools/assets_extract.py

@@ -0,0 +1,284 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import json
+import numpy as np
+
+# from tqdm.contrib.concurrent import process_map
+from pathlib import Path
+
+from module.logger import logger
+
+MODULE_FOLDER = 'tasks'
+ASSETS_FILE = 'assets.py'
+ASSETS_CLASS = '\nclass Assets: \n'
+IMPORT_EXP = """
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+
+# This file was automatically generated by module/dev_tools/assets_extract.py.
+# Don't modify it manually.
+"""
+IMPORT_EXP = IMPORT_EXP.strip().split('MODULE_FOLDER') + ['']
+
+
+
+def name_transform(name: str) -> str:
+    """
+    转换名称, 把小写的转化为大写的, 带有数字的不变,有下划线继续有下划线,
+    如果是全部的大写就不管
+    :param name: 任务名
+    :return: 转换后的名称
+    """
+    if name.isupper():
+        return name
+    if name.islower():
+        return name.upper()
+    return name.upper()
+
+class ImageExtractor:
+
+    def __init__(self, file: str, data: list) -> None:
+        """
+        image rule 提取
+        :param data:  json解析后的数据
+        """
+        # 这个时候的路径分隔符变成了 /
+        self.file = str(Path(file).resolve().relative_to((Path.cwd()).resolve()).as_posix())
+        self.image_path = Path(self.file).parent.as_posix()
+
+        self._result = '\n\t# Image Rule Assets\n'
+        for item in data:
+            self._result += self.extract_item(item)
+
+    @property
+    def result(self) -> str:
+        return self._result
+
+
+    def extract_item(self, item) -> str:
+        """
+        解析每一项,返回字符串
+        :param item:
+        :return:
+        """
+        description: str = f'\t# {item["description"]} \n'
+        name: str = f'\tI_{name_transform(item["itemName"])} = RuleImage(' \
+                    f'roi_front=({item["roiFront"]}), ' \
+                    f'roi_back=({item["roiBack"]}), ' \
+                    f'threshold={item["threshold"]}, ' \
+                    f'method="{item["method"]}", ' \
+                    f'file="./{self.image_path}/{item["imageName"]}")\n'
+        return description + name
+
+class ClickExtractor:
+
+    def __init__(self, file: str, data: list) -> None:
+        """
+        click rule 提取
+        :param data:  json解析后的数据
+        """
+        self._result = '\t# Click Rule Assets\n'
+        for item in data:
+            self._result += self.extract_item(item)
+
+    @property
+    def result(self) -> str:
+        return self._result
+
+    def extract_item(self, item) -> str:
+        """
+        解析每一项,返回字符串
+        :param item:
+        :return:
+        """
+        description: str = f'\t# {item["description"]} \n'
+        name: str = f'\tC_{name_transform(item["itemName"])} = RuleClick(' \
+                    f'roi_front=({item["roiFront"]}), ' \
+                    f'roi_back=({item["roiBack"]}))\n'
+        return description + name
+
+class LongClickExtractor:
+
+    def __init__(self, file: str, data: list) -> None:
+        """
+        long click rule 提取
+        :param data:  json解析后的数据
+        """
+        self._result = '\t# Long Click Rule Assets\n'
+        for item in data:
+            self._result += self.extract_item(item)
+
+    @property
+    def result(self) -> str:
+        return self._result
+
+    def extract_item(self, item) -> str:
+        """
+        解析每一项,返回字符串
+        :param item:
+        :return:
+        """
+        description: str = f'\t# {item["description"]} \n'
+        name: str = f'\tL_{name_transform(item["itemName"])} = RuleLongClick(' \
+                    f'roi_front=({item["roiFront"]}), ' \
+                    f'roi_back=({item["roiBack"]}), ' \
+                    f'duration={item["duration"]})\n'
+        return description + name
+
+class SwipeExtractor:
+
+    def __init__(self, file: str, data: list) -> None:
+        """
+        swipe rule 提取
+        :param data:  json解析后的数据
+        """
+        self._result = '\t# Swipe Rule Assets\n'
+        for item in data:
+            self._result += self.extract_item(item)
+
+    @property
+    def result(self) -> str:
+        return self._result
+
+    def extract_item(self, item) -> str:
+        """
+        解析每一项,返回字符串
+        :param item:
+        :return:
+        """
+        description: str = f'\t# {item["description"]} \n'
+        name: str = f'\tS_{name_transform(item["itemName"])} = RuleSwipe(' \
+                    f'roi_front=({item["roiFront"]}), ' \
+                    f'roi_back=({item["roiBack"]}), ' \
+                    f'mode="{item["mode"]}")\n'
+        return description + name
+
+
+class AssetsExtractor:
+
+    def __init__(self, task_name: str) -> None:
+        """
+        assets 提取某个任务文件夹下的所以的资源
+        :param task_name: 任务名
+        """
+        self.task_name = task_name
+        self.task_path = Path.cwd() / MODULE_FOLDER / task_name
+        self.assets_file = Path.cwd() / MODULE_FOLDER / task_name / ASSETS_FILE
+
+        self._result = ''
+        for import_exp in IMPORT_EXP:
+            self._result += import_exp
+        self._result += ASSETS_CLASS
+
+
+    def all_json_file(self) -> list:
+        """
+        获取所有json文件
+        :return: json文件(带后缀)列表
+        """
+        return [str(x) for x in self.task_path.rglob('*.json')]
+
+    @classmethod
+    def read_file(cls, file: str) -> list:
+        """
+        读文件并随带解析
+        :param file:
+        :return:
+        """
+        with open(file, 'r', encoding='utf-8') as f:
+            data = json.load(f)
+        if not isinstance(data, list):
+            logger.error(f'{file} 文件解析错误,不是list')
+            return None
+        return data
+
+    @classmethod
+    def is_image_file(cls, data: list) -> bool:
+        """
+        判断是不是imagerule 文件
+        :param data: 解析后的json数据,是list
+        :return:
+        """
+        item = data[0]
+        if 'imageName' in item:
+            return True
+        return False
+
+    @classmethod
+    def is_click_file(cls, data: list) -> bool:
+        """
+        判断是不是clickrule 文件, 我这样的判断是有点不合规的
+        :param data: 解析后的json数据,是list
+        :return:
+        """
+        item = data[0]
+        return len(item) == 4
+
+    @classmethod
+    def is_long_click_file(cls, data: list) -> bool:
+        """
+        判断是不是longclickrule 文件
+        :param data: 解析后的json数据,是list
+        :return:
+        """
+        item = data[0]
+        if 'duration' in item:
+            return True
+        return False
+
+    @classmethod
+    def is_swipe_file(cls, data: list) -> bool:
+        """
+        判断是不是swiperule 文件
+        :param data: 解析后的json数据,是list
+        :return:
+        """
+        item = data[0]
+        if 'mode' in item:
+            return True
+        return False
+
+    def write_file(self) -> None:
+        """
+        将自身的_resule写入文件
+        :return:
+        """
+        with open(self.assets_file, 'w', encoding='utf-8') as f:
+            f.write(self._result)
+
+    def extract(self) -> str:
+        """
+        生成一个assets.py文件
+        :return:
+        """
+        for file in self.all_json_file():
+            data = self.read_file(file)
+            if not data:
+                continue
+            if self.is_image_file(data):
+                self._result += ImageExtractor(file, data).result
+            elif self.is_click_file(data):
+                self._result += ClickExtractor(file, data).result
+            elif self.is_long_click_file(data):
+                self._result += LongClickExtractor(file, data).result
+            elif self.is_swipe_file(data):
+                self._result += SwipeExtractor(file, data).result
+
+        self._result += '\n\n'
+        self.write_file()
+
+
+class AllAssetsExtractor:
+    pass
+
+
+if __name__ == "__main__":
+    c = AssetsExtractor('CoinChallenge')
+    # print(c.assets_file)
+    # print(c.task_path)
+    # print(c.all_json_file())
+
+    c.extract()

+ 27 - 4
module/gui/fluent_app.py

@@ -20,14 +20,16 @@ class FluentApp():
     app = None
     app = None
     engine = None
     engine = None
     translator = None
     translator = None
+    dpi = None
 
 
     def __init__(self):
     def __init__(self):
         super().__init__()
         super().__init__()
         # 适配高分辨率、声明、设置Logo、设置软件名字
         # 适配高分辨率、声明、设置Logo、设置软件名字
-        QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.Round)
-        QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
-        QGuiApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
-        QGuiApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
+        # 后面的这三条失效了 使用 QGuiApplication.setHighDpiScaleFactorRoundingPolicy
+        # https://blog.weimo.info/archives/602/
+        # QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
+        # QGuiApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
+        # QGuiApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
         os.putenv("QT_QUICK_CONTROLS_STYLE", "Basic")
         os.putenv("QT_QUICK_CONTROLS_STYLE", "Basic")
 
 
         FluentApp.app = QGuiApplication(sys.argv)
         FluentApp.app = QGuiApplication(sys.argv)
@@ -39,7 +41,9 @@ class FluentApp():
         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)
         FluentApp.translator = Translator(engine=FluentApp.engine, app=FluentApp.app)
+        FluentApp.dpi = DpiScale()
         self.set_context_property(context=FluentApp.translator, name='translator')
         self.set_context_property(context=FluentApp.translator, name='translator')
+        self.set_context_property(context=FluentApp.dpi, name='dpi')
 
 
     @classmethod
     @classmethod
     def run(cls):
     def run(cls):
@@ -102,5 +106,24 @@ class Translator(QObject):
             self._engine.retranslate()
             self._engine.retranslate()
             return
             return
 
 
+class DpiScale(QObject):
+    def __init__(self) -> None:
+        super().__init__()
+
+    @Slot(str)
+    def set_dpi_scale(self, strategy: str) -> None:
+        """
+        设置dpi缩放
+        :param strategy:
+        :return:
+        """
+        match strategy:
+            case "default": QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)  # 不缩放
+            case "round": QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.Round)  # 设备像素比0.5及以上的,进行缩放
+            case "floor": QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.Floor)  # 始终不缩放
+            case "ceil": QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.Ceil)  # 始终缩放
+            case "round_prefer_floor": QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.RoundPreferFloor)  # 设备像素比0.75及以上的,进行缩放
+            case _: QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
+
 
 
 
 

+ 0 - 1
module/gui/qml/Component/RuleFile.qml

@@ -209,7 +209,6 @@ FluArea {
             // 如果是空的表示这个是一个刚刚建立的rule文件
             // 如果是空的表示这个是一个刚刚建立的rule文件
             return
             return
         }
         }
-        console.debug('加载文件的数据', getData)
         data = JSON.parse(getData)
         data = JSON.parse(getData)
         for(let item of data){
         for(let item of data){
             listModel.append(item)
             listModel.append(item)

+ 318 - 1
module/gui/qml/Content/ClickRule.qml

@@ -1,5 +1,322 @@
-import QtQuick 2.0
+import QtQuick
+import QtQuick.Controls
+import FluentUI
+import "../Component"
 
 
 Item {
 Item {
 
 
+    MirrorImage{
+        id: mirrorImage
+        anchors{
+            left: parent.left
+            top: parent.top
+        }
+        width: 1280
+        height: 720 + 50
+        imageWidth: 1280
+        imageHeight: 720
+
+        onRoi_red_changed: function(roi){
+            if(typeof ruleFile.currentItem === "undefined"){
+                return
+            }
+            ruleFile.currentItem.roiFront = roi
+        }
+
+        onRoi_green_changed: function(roi){
+            if(typeof ruleFile.currentItem === "undefined"){
+                return
+            }
+            ruleFile.currentItem.roiBack = roi
+        }
+    }
+    RuleFile{
+        id: ruleFile
+        anchors{
+            left: mirrorImage.right
+            leftMargin: 10
+            right: parent.right
+            top: parent.top
+        }
+        height: 600
+        addFunc: add
+        editFunc: edit
+        saveFunc: save
+
+        onCurrentItemChanged: {
+            if(currentItem === "" || typeof currentItem === "undefined"){
+                return
+            }
+            var [x, y, width, height] = currentItem.roiFront.split(',')
+            mirrorImage.roiRed_x = parseInt(x)
+            mirrorImage.roiRed_y = parseInt(y)
+            mirrorImage.roiRed_width = parseInt(width)
+            mirrorImage.roiRed_height = parseInt(height)
+            var [x, y, width, height] = currentItem.roiBack.split(',')
+            mirrorImage.roiGreen_x = parseInt(x)
+            mirrorImage.roiGreen_y = parseInt(y)
+            mirrorImage.roiGreen_width = parseInt(width)
+            mirrorImage.roiGreen_height = parseInt(height)
+
+        }
+    }
+
+    FluArea {
+        id: ruleArea
+        anchors{
+            left: mirrorImage.right
+            leftMargin: 10
+            right: parent.right
+            top: ruleFile.bottom
+            topMargin: 12
+            bottom: parent.bottom
+        }
+        Column{
+            id: coi
+            anchors{
+                top: parent.top
+                bottom: parent.bottom
+                left: parent.left
+                leftMargin: 20
+                right: parent.right
+                rightMargin: 20
+            }
+            spacing: 5
+            //头
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Editing rule"
+                    font: FluTextStyle.Subtitle
+                }
+            }
+            //item name 这个参数项的名称
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Item name"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: itemName
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    placeholderText:"单行输入框"
+                    disabled: true
+                    text: (typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.itemName
+                    width: 200
+                }
+            }
+            // 文件名
+//            Item{
+//                width: coi.width
+//                height: 40
+//                FluText{
+//                    anchors.left: parent.left
+//                    anchors.verticalCenter: parent.verticalCenter
+//                    text: "Image name"
+//                    font: FluTextStyle.BodyStrong
+//                }
+//                FluTextBox{
+//                    id: imageName
+//                    anchors{
+//                        right: parent.right
+//                        verticalCenter: parent.verticalCenter
+//                    }
+//                    disabled: true
+//                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.imageName
+//                    placeholderText:"Save image name"
+//                    width: 200
+//                }
+//            }
+            // roi front
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Roi front"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: roiFront
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    disabled: true
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.roiFront
+                    placeholderText:"0,0,100,100"
+                    width: 200
+                }
+            }
+            //roi back
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Roi Back"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: roiBack
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    disabled: true
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.roiBack
+                    placeholderText:"0,0,100,100"
+                    width: 200
+
+
+                }
+            }
+            //找图的方法
+//            Item{
+//                width: coi.width
+//                height: 40
+//                FluText{
+//                    anchors.left: parent.left
+//                    anchors.verticalCenter: parent.verticalCenter
+//                    text: "Find method"
+//                    font: FluTextStyle.BodyStrong
+//                }
+//                FComboBox{
+//                    id: method
+//                    anchors{
+//                        right: parent.right
+//                        verticalCenter: parent.verticalCenter
+//                    }
+//                    width: 200
+//                    currentIndex: 0
+//                    model: ["Template matching"]
+//                    onActivated: {
+
+//                    }
+//                }
+//            }
+            //阈值
+//            Item{
+//                width: coi.width
+//                height: 40
+//                FluText{
+//                    anchors.left: parent.left
+//                    anchors.verticalCenter: parent.verticalCenter
+//                    text: "Threshod"
+//                    font: FluTextStyle.BodyStrong
+//                }
+//                FluTextBox{
+//                    id: threshold
+//                    anchors{
+//                        right: parent.right
+//                        verticalCenter: parent.verticalCenter
+//                    }
+//                    width: 200
+//                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.threshold
+//                    placeholderText:"0.8"
+//                    onEditingFinished: {
+//                        if(typeof ruleFile.currentItem === "undefined"){
+//                            return
+//                        }
+//                        ruleFile.currentItem.threshold = parseFloat(text)
+//                    }
+//                }
+//            }
+            //描述 description
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Description"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: description
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    width: 200
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.description
+                    placeholderText:"input your description"
+                    onEditingFinished: {
+                        if(typeof ruleFile.currentItem === "undefined"){
+                            return
+                        }
+                        ruleFile.currentItem.description = text
+                    }
+                }
+            }
+
+        }
+
+    }
+
+    // 帮助
+    FluArea{
+        id: ruleHelp
+        anchors{
+            left: parent.left
+            right: ruleArea.left
+            rightMargin: 10
+            top: mirrorImage.bottom
+            topMargin: 10
+            bottom: parent.bottom
+        }
+        FluText{
+            leftPadding: 12
+            topPadding: 12
+            text: "红色的框(Roi front)表示这一个项点击的默认范围,绿色的框(Roi back)表示备用的范围。
+在移动边框时右边的roi并不会实时显示,当切换软件的焦点时更新显示,但是具体的数值是更新的。
+投屏的设置最上边点击即可"
+        }
+
+    }
+
+    function add(){
+        const item ={}
+        item["itemName"] = "new"
+        item["roiFront"] = "0,0,100,100"
+        item["roiBack"] = "0,0,100,100"
+        item["description"] = "description"
+        showSuccess("Add new item")
+        return item
+    }
+
+    function edit(model){
+
+    }
+
+    function save(){
+        const data = []
+        for(var i=0; i<ruleFile.list_model.count; i++){
+            const item = ruleFile.list_model.get(i)
+            const itemData = {}
+            itemData["itemName"] = item["itemName"]
+            itemData["roiFront"] = item["roiFront"]
+            itemData["roiBack"] = item["roiBack"]
+            itemData["description"] = item["description"]
+            data.push(itemData)
+        }
+
+        ruleFile.rule_file.write_file(ruleFile.file, JSON.stringify(data))
+        showSuccess("Save file")
+
+    }
+
+
 }
 }

+ 3 - 3
module/gui/qml/Content/ImageRule.qml

@@ -303,7 +303,7 @@ Item {
             onClicked: {
             onClicked: {
                 const i = ruleFile.file.lastIndexOf("/")
                 const i = ruleFile.file.lastIndexOf("/")
                 const imagepath = ruleFile.file.substring(0, i)
                 const imagepath = ruleFile.file.substring(0, i)
-                mirrorImage.save_target_image(ruleFile.currentItem.roiFront, imagepath +"/"+ruleFile.currentItem.imageName + ".png")
+                mirrorImage.save_target_image(ruleFile.currentItem.roiFront, imagepath +"/"+ruleFile.currentItem.imageName)
                 showSuccess("Save target image")
                 showSuccess("Save target image")
             }
             }
         }
         }
@@ -312,7 +312,7 @@ Item {
     function add(){
     function add(){
         const item ={}
         const item ={}
         item["itemName"] = "new"
         item["itemName"] = "new"
-        item["imageName"] = "image name"
+        item["imageName"] = "image_name.png"
         item["roiFront"] = "0,0,100,100"
         item["roiFront"] = "0,0,100,100"
         item["roiBack"] = "0,0,100,100"
         item["roiBack"] = "0,0,100,100"
         item["method"] = "Template matching"
         item["method"] = "Template matching"
@@ -323,7 +323,7 @@ Item {
     }
     }
 
 
     function edit(model){
     function edit(model){
-        model.imageName = ruleFile.folder +"_"+ model.itemName
+        model.imageName = ruleFile.folder +"_"+ model.itemName + ".png"
     }
     }
 
 
     function save(){
     function save(){

+ 277 - 1
module/gui/qml/Content/LongClickRule.qml

@@ -1,5 +1,281 @@
-import QtQuick 2.0
+import QtQuick
+import QtQuick.Controls
+import FluentUI
+import "../Component"
 
 
 Item {
 Item {
 
 
+    MirrorImage{
+        id: mirrorImage
+        anchors{
+            left: parent.left
+            top: parent.top
+        }
+        width: 1280
+        height: 720 + 50
+        imageWidth: 1280
+        imageHeight: 720
+
+        onRoi_red_changed: function(roi){
+            if(typeof ruleFile.currentItem === "undefined"){
+                return
+            }
+            ruleFile.currentItem.roiFront = roi
+        }
+
+        onRoi_green_changed: function(roi){
+            if(typeof ruleFile.currentItem === "undefined"){
+                return
+            }
+            ruleFile.currentItem.roiBack = roi
+        }
+    }
+    RuleFile{
+        id: ruleFile
+        anchors{
+            left: mirrorImage.right
+            leftMargin: 10
+            right: parent.right
+            top: parent.top
+        }
+        height: 600
+        addFunc: add
+        editFunc: edit
+        saveFunc: save
+
+        onCurrentItemChanged: {
+            if(currentItem === "" || typeof currentItem === "undefined"){
+                return
+            }
+            var [x, y, width, height] = currentItem.roiFront.split(',')
+            mirrorImage.roiRed_x = parseInt(x)
+            mirrorImage.roiRed_y = parseInt(y)
+            mirrorImage.roiRed_width = parseInt(width)
+            mirrorImage.roiRed_height = parseInt(height)
+            var [x, y, width, height] = currentItem.roiBack.split(',')
+            mirrorImage.roiGreen_x = parseInt(x)
+            mirrorImage.roiGreen_y = parseInt(y)
+            mirrorImage.roiGreen_width = parseInt(width)
+            mirrorImage.roiGreen_height = parseInt(height)
+
+        }
+    }
+
+    FluArea {
+        id: ruleArea
+        anchors{
+            left: mirrorImage.right
+            leftMargin: 10
+            right: parent.right
+            top: ruleFile.bottom
+            topMargin: 12
+            bottom: parent.bottom
+        }
+        Column{
+            id: coi
+            anchors{
+                top: parent.top
+                bottom: parent.bottom
+                left: parent.left
+                leftMargin: 20
+                right: parent.right
+                rightMargin: 20
+            }
+            spacing: 5
+            //头
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Editing rule"
+                    font: FluTextStyle.Subtitle
+                }
+            }
+            //item name 这个参数项的名称
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Item name"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: itemName
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    placeholderText:"单行输入框"
+                    disabled: true
+                    text: (typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.itemName
+                    width: 200
+                }
+            }
+            // 文件名
+
+            // roi front
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Roi front"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: roiFront
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    disabled: true
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.roiFront
+                    placeholderText:"0,0,100,100"
+                    width: 200
+                }
+            }
+            //roi back
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Roi Back"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: roiBack
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    disabled: true
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.roiBack
+                    placeholderText:"0,0,100,100"
+                    width: 200
+
+
+                }
+            }
+            //长按的时间间隔
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Duration"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: duration
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    width: 200
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.duration
+                    placeholderText:"1500"
+                    onEditingFinished: {
+                        if(typeof ruleFile.currentItem === "undefined"){
+                            return
+                        }
+                        ruleFile.currentItem.duration = parseInt(text)
+                    }
+                }
+            }
+
+            //描述 description
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Description"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: description
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    width: 200
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.description
+                    placeholderText:"input your description"
+                    onEditingFinished: {
+                        if(typeof ruleFile.currentItem === "undefined"){
+                            return
+                        }
+                        ruleFile.currentItem.description = text
+                    }
+                }
+            }
+
+        }
+
+    }
+
+    // 帮助
+    FluArea{
+        id: ruleHelp
+        anchors{
+            left: parent.left
+            right: ruleArea.left
+            rightMargin: 10
+            top: mirrorImage.bottom
+            topMargin: 10
+            bottom: parent.bottom
+        }
+        FluText{
+            leftPadding: 12
+            topPadding: 12
+            text: "红色的框(Roi front)表示这一个项点击的默认范围,绿色的框(Roi back)表示备用的范围。
+在移动边框时右边的roi并不会实时显示,当切换软件的焦点时更新显示,但是具体的数值是更新的。
+投屏的设置最上边点击即可"
+        }
+
+    }
+
+    function add(){
+        const item ={}
+        item["itemName"] = "new"
+        item["roiFront"] = "0,0,100,100"
+        item["roiBack"] = "0,0,100,100"
+        item["duration"] = 1500
+        item["description"] = "description"
+        showSuccess("Add new item")
+        return item
+    }
+
+    function edit(model){
+
+    }
+
+    function save(){
+        const data = []
+        for(var i=0; i<ruleFile.list_model.count; i++){
+            const item = ruleFile.list_model.get(i)
+            const itemData = {}
+            itemData["itemName"] = item["itemName"]
+            itemData["roiFront"] = item["roiFront"]
+            itemData["roiBack"] = item["roiBack"]
+            itemData["duration"] = item["duration"]
+            itemData["description"] = item["description"]
+            data.push(itemData)
+        }
+
+        ruleFile.rule_file.write_file(ruleFile.file, JSON.stringify(data))
+        showSuccess("Save file")
+
+    }
+
+
 }
 }

+ 287 - 1
module/gui/qml/Content/SwipeRule.qml

@@ -1,5 +1,291 @@
-import QtQuick 2.0
+import QtQuick
+import QtQuick.Controls
+import FluentUI
+import "../Component"
 
 
 Item {
 Item {
 
 
+    MirrorImage{
+        id: mirrorImage
+        anchors{
+            left: parent.left
+            top: parent.top
+        }
+        width: 1280
+        height: 720 + 50
+        imageWidth: 1280
+        imageHeight: 720
+
+        onRoi_red_changed: function(roi){
+            if(typeof ruleFile.currentItem === "undefined"){
+                return
+            }
+            ruleFile.currentItem.roiFront = roi
+        }
+
+        onRoi_green_changed: function(roi){
+            if(typeof ruleFile.currentItem === "undefined"){
+                return
+            }
+            ruleFile.currentItem.roiBack = roi
+        }
+    }
+    RuleFile{
+        id: ruleFile
+        anchors{
+            left: mirrorImage.right
+            leftMargin: 10
+            right: parent.right
+            top: parent.top
+        }
+        height: 600
+        addFunc: add
+        editFunc: edit
+        saveFunc: save
+
+        onCurrentItemChanged: {
+            if(currentItem === "" || typeof currentItem === "undefined"){
+                return
+            }
+            var [x, y, width, height] = currentItem.roiFront.split(',')
+            mirrorImage.roiRed_x = parseInt(x)
+            mirrorImage.roiRed_y = parseInt(y)
+            mirrorImage.roiRed_width = parseInt(width)
+            mirrorImage.roiRed_height = parseInt(height)
+            var [x, y, width, height] = currentItem.roiBack.split(',')
+            mirrorImage.roiGreen_x = parseInt(x)
+            mirrorImage.roiGreen_y = parseInt(y)
+            mirrorImage.roiGreen_width = parseInt(width)
+            mirrorImage.roiGreen_height = parseInt(height)
+
+        }
+    }
+
+    FluArea {
+        id: ruleArea
+        anchors{
+            left: mirrorImage.right
+            leftMargin: 10
+            right: parent.right
+            top: ruleFile.bottom
+            topMargin: 12
+            bottom: parent.bottom
+        }
+        Column{
+            id: coi
+            anchors{
+                top: parent.top
+                bottom: parent.bottom
+                left: parent.left
+                leftMargin: 20
+                right: parent.right
+                rightMargin: 20
+            }
+            spacing: 5
+            //头
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Editing rule"
+                    font: FluTextStyle.Subtitle
+                }
+            }
+            //item name 这个参数项的名称
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Item name"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: itemName
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    placeholderText:"单行输入框"
+                    disabled: true
+                    text: (typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.itemName
+                    width: 200
+                }
+            }
+            // 文件名
+
+            // roi front
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Roi front"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: roiFront
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    disabled: true
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.roiFront
+                    placeholderText:"0,0,100,100"
+                    width: 200
+                }
+            }
+            //roi back
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Roi Back"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: roiBack
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    disabled: true
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.roiBack
+                    placeholderText:"0,0,100,100"
+                    width: 200
+
+
+                }
+            }
+            //长按的时间间隔
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Duration"
+                    font: FluTextStyle.BodyStrong
+                }
+                FComboBox{
+                    id: mode
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    width: 200
+                    model: ["defalut", "vector"]
+                    currentIndex: if(typeof ruleFile.currentItem !== "undefined"){
+                                     if(ruleFile.currentItem.mode === "default"){
+                                         return 0
+                                     }else{
+                                         return 1
+                                     }
+                                  }else{return 0}
+
+                    onActivated: {
+                        console.debug('接收',currentIndex, currentText)
+                        if(currentIndex === 0){
+                            ruleFile.currentItem.mode = "default"
+                        }
+                        else if(currentIndex === 1){
+                            ruleFile.currentItem.mode = "vector"
+                        }
+                    }
+                }
+            }
+
+            //描述 description
+            Item{
+                width: coi.width
+                height: 40
+                FluText{
+                    anchors.left: parent.left
+                    anchors.verticalCenter: parent.verticalCenter
+                    text: "Description"
+                    font: FluTextStyle.BodyStrong
+                }
+                FluTextBox{
+                    id: description
+                    anchors{
+                        right: parent.right
+                        verticalCenter: parent.verticalCenter
+                    }
+                    width: 200
+                    text:(typeof ruleFile.currentItem === "undefined")? "" : ruleFile.currentItem.description
+                    placeholderText:"input your description"
+                    onEditingFinished: {
+                        if(typeof ruleFile.currentItem === "undefined"){
+                            return
+                        }
+                        ruleFile.currentItem.description = text
+                    }
+                }
+            }
+
+        }
+
+    }
+
+    // 帮助
+    FluArea{
+        id: ruleHelp
+        anchors{
+            left: parent.left
+            right: ruleArea.left
+            rightMargin: 10
+            top: mirrorImage.bottom
+            topMargin: 10
+            bottom: parent.bottom
+        }
+        FluText{
+            leftPadding: 12
+            topPadding: 12
+            text: "红色的框(Roi front)表示滑动的起始范围,绿色的框(Roi back)表示滑动的停止范围。
+在移动边框时右边的roi并不会实时显示,当切换软件的焦点时更新显示,但是具体的数值是更新的。
+投屏的设置最上边点击即可"
+        }
+
+    }
+
+    function add(){
+        const item ={}
+        item["itemName"] = "new"
+        item["roiFront"] = "0,0,100,100"
+        item["roiBack"] = "0,0,100,100"
+        item["mode"] = "default"
+        item["description"] = "description"
+        showSuccess("Add new item")
+        return item
+    }
+
+    function edit(model){
+
+    }
+
+    function save(){
+        const data = []
+        for(var i=0; i<ruleFile.list_model.count; i++){
+            const item = ruleFile.list_model.get(i)
+            const itemData = {}
+            itemData["itemName"] = item["itemName"]
+            itemData["roiFront"] = item["roiFront"]
+            itemData["roiBack"] = item["roiBack"]
+            itemData["mode"] = item["mode"]
+            itemData["description"] = item["description"]
+            data.push(itemData)
+        }
+
+        ruleFile.rule_file.write_file(ruleFile.file, JSON.stringify(data))
+        showSuccess("Save file")
+
+    }
+
+
 }
 }

+ 38 - 8
module/gui/qml/Global/MainEvent.qml

@@ -16,11 +16,13 @@ QtObject {
 
 
     // 界面的自定义设置
     // 界面的自定义设置
     property var settings: {""}
     property var settings: {""}
+    property bool settingInit: true  // 表示这个时候是初始化的,初始化后变为false
     property int displayMode : FluNavigationView.Compact
     property int displayMode : FluNavigationView.Compact
     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: ""
     property string language: ""
+    property string dpiStrategy: ""
 
 
     property int runStatus: MainEvent.RunStatus.Empty
     property int runStatus: MainEvent.RunStatus.Empty
     property string menuTitle: ""
     property string menuTitle: ""
@@ -41,14 +43,15 @@ QtObject {
                 "darkMode": 2,
                 "darkMode": 2,
                 "primaryColor": "Orange",
                 "primaryColor": "Orange",
                 "nativeText": true,
                 "nativeText": true,
-                "language": "简体中文"}
+                "language": "简体中文",
+                "dpiStrategy": ""}
         }
         }
 
 
         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")
+        mainEvent.dpiStrategy = set["dpiStrategy"]
 
 
         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}
@@ -59,24 +62,32 @@ QtObject {
         else if(primary_color === "Blue"){mainEvent.primaryColor = FluColors.Blue}
         else if(primary_color === "Blue"){mainEvent.primaryColor = FluColors.Blue}
         else if(primary_color === "Teal"){mainEvent.primaryColor = FluColors.Teal}
         else if(primary_color === "Teal"){mainEvent.primaryColor = FluColors.Teal}
         else if(primary_color === "Green"){mainEvent.primaryColor = FluColors.Green}
         else if(primary_color === "Green"){mainEvent.primaryColor = FluColors.Green}
+
+        settingInit = false
     }
     }
     onDisplayModeChanged: {
     onDisplayModeChanged: {
+
         if(mainEvent.settings === ""){
         if(mainEvent.settings === ""){
             console.debug('display mode and is none')
             console.debug('display mode and is none')
         }
         }
 
 
         mainEvent.settings["displayMode"] = mainEvent.displayMode
         mainEvent.settings["displayMode"] = mainEvent.displayMode
+        if(settingInit){
+            return
+        }
         setting.update(JSON.stringify(mainEvent.settings))
         setting.update(JSON.stringify(mainEvent.settings))
-//        showSuccess('update dark mode')
     }
     }
     onDarkModeChanged: {
     onDarkModeChanged: {
+
         if(mainEvent.settings === ""){
         if(mainEvent.settings === ""){
             console.debug('darkMode and is none')
             console.debug('darkMode and is none')
         }
         }
         FluTheme.darkMode = mainEvent.darkMode
         FluTheme.darkMode = mainEvent.darkMode
         mainEvent.settings["darkMode"] = FluTheme.darkMode
         mainEvent.settings["darkMode"] = FluTheme.darkMode
+        if(settingInit){
+            return
+        }
         setting.update(JSON.stringify(mainEvent.settings))
         setting.update(JSON.stringify(mainEvent.settings))
-//        showSuccess('update dark mode' + FluTheme.darkMode)
     }
     }
     onPrimaryColorChanged: {
     onPrimaryColorChanged: {
         if(mainEvent.settings === ""){
         if(mainEvent.settings === ""){
@@ -97,19 +108,23 @@ QtObject {
         else if(FluTheme.primaryColor === FluColors.Teal){primary_color="Teal"}
         else if(FluTheme.primaryColor === FluColors.Teal){primary_color="Teal"}
         else if(FluTheme.primaryColor === FluColors.Green){primary_color="Green"}
         else if(FluTheme.primaryColor === FluColors.Green){primary_color="Green"}
         mainEvent.settings["primaryColor"] = primary_color
         mainEvent.settings["primaryColor"] = primary_color
+        if(settingInit){
+            return
+        }
         setting.update(JSON.stringify(mainEvent.settings))
         setting.update(JSON.stringify(mainEvent.settings))
-//        showSuccess('update primary color' + FluTheme.primaryColor)
     }
     }
     onNativeTextChanged: {
     onNativeTextChanged: {
+
         if(mainEvent.settings === ""){
         if(mainEvent.settings === ""){
             console.debug('nativeText and is none')
             console.debug('nativeText and is none')
         }
         }
 
 
         FluTheme.nativeText = mainEvent.nativeText
         FluTheme.nativeText = mainEvent.nativeText
         mainEvent.settings["nativeText"] = FluTheme.nativeText
         mainEvent.settings["nativeText"] = FluTheme.nativeText
+        if(settingInit){
+            return
+        }
         setting.update(JSON.stringify(mainEvent.settings))
         setting.update(JSON.stringify(mainEvent.settings))
-//        var message = 'update native text' + FluTheme.nativeText
-//        showSuccess(message)
     }
     }
     onLanguageChanged: {
     onLanguageChanged: {
         if(mainEvent.settings === ""){
         if(mainEvent.settings === ""){
@@ -117,7 +132,22 @@ QtObject {
         }
         }
 
 
         mainEvent.settings["language"] = mainEvent.language
         mainEvent.settings["language"] = mainEvent.language
-        setting.update(JSON.stringify(mainEvent.settings))
         translator.set_language(mainEvent.language)
         translator.set_language(mainEvent.language)
+        if(settingInit){
+            return
+        }
+        setting.update(JSON.stringify(mainEvent.settings))
+
+    }
+    onDpiStrategyChanged: {
+        if(mainEvent.settings === ""){
+            console.debug('dpiStrategy and is none')
+        }
+        mainEvent.settings["dpiStrategy"] = mainEvent.dpiStrategy
+        dpi.set_dpi_scale(mainEvent.dpiStrategy)
+        if(settingInit){
+            return
+        }
+        setting.update(JSON.stringify(mainEvent.settings))
     }
     }
 }
 }

+ 37 - 0
module/gui/qml/Page/O_Settings.qml

@@ -171,4 +171,41 @@ FluScrollablePage{
     }
     }
 
 
 
 
+    FluArea{
+        Layout.fillWidth: true
+        Layout.topMargin: 20
+        height: 200
+        paddings: 10
+
+        ColumnLayout{
+            spacing: 10
+            anchors{
+                top: parent.top
+                left: parent.left
+            }
+
+            FluText{
+                text: qsTr("Dpi Strategy")
+                font: FluTextStyle.BodyStrong
+                Layout.bottomMargin: 4
+            }
+            Repeater{
+                model: [{title:qsTr("default"),mode:"default"},  // 默认不缩放
+                        {title:qsTr("floor"),mode:"floor"},  // 始终不缩放
+                        {title:qsTr("ceil"),mode:"ceil"},  // 始终缩放
+                        {title:qsTr("round"),mode:"round"}, // 设备像素比0.5及以上的,进行缩放
+                        {title:qsTr("round_prefer_floor"),mode:"round_prefer_floor"} // 设备像素比0.75及以上的,进行缩放
+                        ]
+                delegate:  FluRadioButton{
+                    selected : MainEvent.dpiStrategy===modelData.mode
+                    text:modelData.title
+                    onClicked:{
+                        MainEvent.dpiStrategy = modelData.mode
+                    }
+                }
+            }
+        }
+    }
+
+
 }
 }

+ 0 - 1
module/tasks/CoinChallenge/res/test.json

@@ -1 +0,0 @@
-[{"itemName":"new1","imageName":"res_new1","roiFront":"179,241,70,79","roiBack":"595,238,100,100","method":"Template matching","threshold":0.8,"description":"description"},{"itemName":"new2","imageName":"res_new2","roiFront":"362,243,100,100","roiBack":"803,101,100,100","method":"Template matching","threshold":0.8,"description":"description"},{"itemName":"new3","imageName":"res_new3","roiFront":"568,212,240,220","roiBack":"0,0,100,100","method":"Template matching","threshold":0.9,"description":"desc55"}]

+ 41 - 0
tasks/CoinChallenge/assets.py

@@ -0,0 +1,41 @@
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+
+# This file was automatically generated by module/dev_tools/assets_extract.py.
+# Don't modify it manually.
+class Assets: 
+
+	# Image Rule Assets
+	# description 
+	I_NEW1 = RuleImage(roi_front=(157,240,70,79), roi_back=(41,185,279,207), threshold=0.8, method="Template matching", file="./tasks/CoinChallenge/res/res_new1.png")
+	# description 
+	I_NEW2 = RuleImage(roi_front=(362,243,100,100), roi_back=(803,101,100,100), threshold=0.8, method="Template matching", file="./tasks/CoinChallenge/res/res_new2.png")
+	# desc55 
+	I_NEW3 = RuleImage(roi_front=(568,212,240,220), roi_back=(0,0,100,100), threshold=0.9, method="Template matching", file="./tasks/CoinChallenge/res/res_new3.png")
+	# Click Rule Assets
+	# description 
+	C_NEW1 = RuleClick(roi_front=(268,268,100,100), roi_back=(614,214,100,100))
+	# description 
+	C_NEW2 = RuleClick(roi_front=(171,236,100,100), roi_back=(554,225,100,100))
+	# desc444n 
+	C_NEW3 = RuleClick(roi_front=(180,150,100,100), roi_back=(596,247,100,100))
+	# Long Click Rule Assets
+	# description 
+	L_NEW1 = RuleLongClick(roi_front=(208,151,100,100), roi_back=(542,279,100,100), duration=1500)
+	# description 
+	L_NEW2 = RuleLongClick(roi_front=(355,191,100,100), roi_back=(526,323,100,100), duration=1500)
+	# de66666n 
+	L_NEW3 = RuleLongClick(roi_front=(112,156,100,100), roi_back=(469,200,100,100), duration=1000)
+	# Swipe Rule Assets
+	# description 
+	S_NEW1 = RuleSwipe(roi_front=(253,212,100,100), roi_back=(652,292,100,100), mode="default")
+	# description 
+	S_NEW2 = RuleSwipe(roi_front=(265,272,100,100), roi_back=(622,338,100,100), mode="default")
+	# description 
+	S_NEW3 = RuleSwipe(roi_front=(198,160,100,100), roi_back=(626,305,100,100), mode="default")
+	# description 
+	S_NEW4 = RuleSwipe(roi_front=(150,145,100,100), roi_back=(535,199,100,100), mode="vector")
+
+

BIN
tasks/CoinChallenge/res/res_new1.png


BIN
tasks/CoinChallenge/res/res_new2.png


BIN
tasks/CoinChallenge/res/res_new3.png


+ 1 - 0
tasks/CoinChallenge/res/test.json

@@ -0,0 +1 @@
+[{"itemName":"new1","imageName":"res_new1.png","roiFront":"157,240,70,79","roiBack":"41,185,279,207","method":"Template matching","threshold":0.8,"description":"description"},{"itemName":"new2","imageName":"res_new2.png","roiFront":"362,243,100,100","roiBack":"803,101,100,100","method":"Template matching","threshold":0.8,"description":"description"},{"itemName":"new3","imageName":"res_new3.png","roiFront":"568,212,240,220","roiBack":"0,0,100,100","method":"Template matching","threshold":0.9,"description":"desc55"}]

+ 20 - 0
tasks/CoinChallenge/res/test_click.json

@@ -0,0 +1,20 @@
+[
+    {
+        "itemName": "new1",
+        "roiFront": "268,268,100,100",
+        "roiBack": "614,214,100,100",
+        "description": "description"
+    },
+    {
+        "itemName": "new2",
+        "roiFront": "171,236,100,100",
+        "roiBack": "554,225,100,100",
+        "description": "description"
+    },
+    {
+        "itemName": "new3",
+        "roiFront": "180,150,100,100",
+        "roiBack": "596,247,100,100",
+        "description": "desc444n"
+    }
+]

+ 23 - 0
tasks/CoinChallenge/res/test_long_click.json

@@ -0,0 +1,23 @@
+[
+    {
+        "itemName": "new1",
+        "roiFront": "208,151,100,100",
+        "roiBack": "542,279,100,100",
+        "duration": 1500,
+        "description": "description"
+    },
+    {
+        "itemName": "new2",
+        "roiFront": "355,191,100,100",
+        "roiBack": "526,323,100,100",
+        "duration": 1500,
+        "description": "description"
+    },
+    {
+        "itemName": "new3",
+        "roiFront": "112,156,100,100",
+        "roiBack": "469,200,100,100",
+        "duration": 1000,
+        "description": "de66666n"
+    }
+]

+ 30 - 0
tasks/CoinChallenge/res/test_swipe.json

@@ -0,0 +1,30 @@
+[
+    {
+        "itemName": "new1",
+        "roiFront": "253,212,100,100",
+        "roiBack": "652,292,100,100",
+        "mode": "default",
+        "description": "description"
+    },
+    {
+        "itemName": "new2",
+        "roiFront": "265,272,100,100",
+        "roiBack": "622,338,100,100",
+        "mode": "default",
+        "description": "description"
+    },
+    {
+        "itemName": "new3",
+        "roiFront": "198,160,100,100",
+        "roiBack": "626,305,100,100",
+        "mode": "default",
+        "description": "description"
+    },
+    {
+        "itemName": "new4",
+        "roiFront": "150,145,100,100",
+        "roiBack": "535,199,100,100",
+        "mode": "vector",
+        "description": "description"
+    }
+]

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


+ 2 - 3
module/tasks/Restart/config.py → tasks/Restart/config.py

@@ -1,10 +1,9 @@
 # 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
-from pydantic import BaseModel, ValidationError, validator, Field
+from pydantic import BaseModel, Field
 
 
-from module.logger import logger
-from module.tasks.Restart.config_scheduler import Scheduler
+from tasks.Restart.config_scheduler import Scheduler
 
 
 class Restart(BaseModel):
 class Restart(BaseModel):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     scheduler: Scheduler = Field(default_factory=Scheduler)

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


+ 5 - 5
module/tasks/Script/config.py → tasks/Script/config.py

@@ -1,12 +1,12 @@
 # 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
-from pydantic import BaseModel, ValidationError, validator, Field
+from pydantic import BaseModel, Field
+
+from tasks.Script.config_device import Device
+from tasks.Script.config_error import Error
+from tasks.Script.config_optimization import Optimization
 
 
-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):
 class Script(BaseModel):
     device: Device = Field(default_factory=Device)
     device: Device = Field(default_factory=Device)

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


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


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