@@ -458,6 +458,8 @@ export interface RawRuleProps extends RawCommonProps {
458458 *
459459 * 在 {@link position} 存在的情况下, action 的默认值为 `clickCenter`
460460 *
461+ * 在 {@link swipeArg} 存在的情况下, action 的默认值为 `swipe`
462+ *
461463 * @example
462464 * `click`
463465 * // 为默认值, 如果目标节点是 clickable 的, 则使用 `clickNode`, 反之使用 `clickCenter`
@@ -491,7 +493,11 @@ export interface RawRuleProps extends RawCommonProps {
491493 * @example
492494 * `longClickCenter`
493495 * // 与 clickCenter 类似, 长按时间为 400 毫秒
494- *
496+ *
497+ * @example
498+ * `swipe`
499+ * // 向系统发起一个滑动事件, 使用 swipeArg 定义滑动参数
500+ *
495501 * @example
496502 * `none`
497503 * // 什么都不做, 仅作为匹配标记使用
@@ -518,6 +524,14 @@ export interface RawRuleProps extends RawCommonProps {
518524 */
519525 position ?: Position ;
520526
527+ /**
528+ * 在使用 swipe 时的滑动参数
529+ *
530+ * 在 swipeArg 存在的情况下, {@link action} 的默认值为 `swipe`
531+ *
532+ */
533+ swipeArg ?: SwipeArg ;
534+
521535 /**
522536 * 一个或者多个合法的 GKD 选择器, 如果所有选择器都能匹配上节点, 那么点击最后一个选择器的目标节点
523537 *
@@ -738,14 +752,33 @@ export type StringMatcher = {
738752 pattern ?: string ;
739753} ;
740754
755+ export type SwipeArg = {
756+ /**
757+ * 起始坐标, 计算方式同 {@link Position}
758+ */
759+ start : Position ;
760+
761+ /**
762+ * 结束坐标, 计算方式同 {@link Position}, 默认值为 start 位置
763+ *
764+ * 如果开始坐标和结束坐标完全相同, 可以作为自定义时长的点击使用
765+ */
766+ end ?: Position ;
767+
768+ /**
769+ * 滑动持续时间, 单位毫秒, 滑动曲线为线性移动
770+ */
771+ duration : Integer ;
772+ } ;
773+
741774/**
742775 * 位置类型, 用以描述自定义点击位置
743776 *
744777 * 需要注意是相对目标节点位置, 不是相对屏幕位置
745778 *
746779 * 使用 left/top/right/bottom 四条边实现定位, 此对象只能有两个属性, 也就是两条相邻边
747780 *
748- * 合法的定位组合为: left-top, left-bottom, right-top, right-bottom
781+ * 合法的定位组合为: left-top, left-bottom, right-top, right-bottom, x-y
749782 *
750783 * 示例1-点击目标节点的中心
751784 * ```json5
@@ -773,6 +806,14 @@ export type StringMatcher = {
773806 * top: 'width*0.0852',
774807 * }
775808 * ```
809+ *
810+ * 示例3-点击屏幕中心
811+ * ```json5
812+ * {
813+ * x: 'screenWidth/2',
814+ * y: 'screenHeight/2',
815+ * }
816+ * ```
776817 */
777818export type Position = {
778819 /**
@@ -782,10 +823,14 @@ export type Position = {
782823 *
783824 * 支持两种值类型, 字符串和数字, 数字等价于相同内容的字符串, 如 2.5 等价于 '2.5'
784825 *
785- * 字符串类型支持来自快照属性面板上的 left/top/right/bottom/width/height/random 的数学计算表达式
826+ * 字符串类型支持来自快照属性面板上的 left/top/right/bottom/width/height 的数学计算表达式
827+ *
828+ * 此外有额外的参数 random/screenWidth/screenHeight 可使用
786829 *
787830 * 其中 random 是 0-1 的随机数, 需要注意 random 在单个表达式中是单个固定值, 即表达式 'random-random'=0
788831 *
832+ * 其中 screenWidth/screenHeight 是实时屏幕宽高, 屏幕发生旋转时,screenWidth/screenHeight 的值会交换
833+ *
789834 * @example
790835 * 2.5 // ✅
791836 * '2.5' // ✅
@@ -808,6 +853,16 @@ export type Position = {
808853 * 距离目标节点下边的距离
809854 */
810855 bottom ?: string | number ;
856+
857+ /**
858+ * 距离屏幕左侧的距离
859+ */
860+ x ?: string | number ;
861+
862+ /**
863+ * 距离屏幕顶部的距离
864+ */
865+ y ?: string | number ;
811866} ;
812867
813868/**
0 commit comments