Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
bf16c135
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
720
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bf16c135
编写于
8月 04, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): automator
上级
44ae5f89
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
31 deletion
+31
-31
packages/uni-app-uts/lib/automator/apis/Element.uts
packages/uni-app-uts/lib/automator/apis/Element.uts
+13
-13
packages/uni-app-uts/lib/automator/apis/Page.uts
packages/uni-app-uts/lib/automator/apis/Page.uts
+5
-5
packages/uni-app-uts/lib/automator/apis/util.uts
packages/uni-app-uts/lib/automator/apis/util.uts
+11
-11
packages/uni-app-uts/lib/automator/index.uts
packages/uni-app-uts/lib/automator/index.uts
+2
-2
未找到文件。
packages/uni-app-uts/lib/automator/apis/Element.uts
浏览文件 @
bf16c135
...
@@ -3,7 +3,7 @@ import { JSONObject } from 'com.alibaba.fastjson'
...
@@ -3,7 +3,7 @@ import { JSONObject } from 'com.alibaba.fastjson'
import { getChildrenText, toCamelCase } from './util.uts'
import { getChildrenText, toCamelCase } from './util.uts'
export type GetElementParams = {
export type GetElementParams = {
pageId:
number
pageId:
string
nodeId?: number | null
nodeId?: number | null
elementId?: string | null
elementId?: string | null
selector: string
selector: string
...
@@ -43,7 +43,7 @@ export const getElements = (params: GetElementParams): void => {
...
@@ -43,7 +43,7 @@ export const getElements = (params: GetElementParams): void => {
}
}
export type GetDOMPropertiesParams = {
export type GetDOMPropertiesParams = {
pageId:
number
pageId:
string
elementId?: string | null
elementId?: string | null
nodeId?: number | null
nodeId?: number | null
names: string[]
names: string[]
...
@@ -77,7 +77,7 @@ export const getDOMProperties = (params: GetDOMPropertiesParams): void => {
...
@@ -77,7 +77,7 @@ export const getDOMProperties = (params: GetDOMPropertiesParams): void => {
}
}
export type GetPropertiesParams = {
export type GetPropertiesParams = {
pageId:
number
pageId:
string
elementId?: string | null
elementId?: string | null
nodeId?: number | null
nodeId?: number | null
names: string[]
names: string[]
...
@@ -100,7 +100,7 @@ export const getProperties = (params: GetPropertiesParams): void => {
...
@@ -100,7 +100,7 @@ export const getProperties = (params: GetPropertiesParams): void => {
}
}
export type GetAttributesParams = {
export type GetAttributesParams = {
pageId:
number
pageId:
string
elementId?: string | null
elementId?: string | null
nodeId?: number | null
nodeId?: number | null
names: string[]
names: string[]
...
@@ -121,7 +121,7 @@ export const getAttributes = (params: GetAttributesParams): void => {
...
@@ -121,7 +121,7 @@ export const getAttributes = (params: GetAttributesParams): void => {
}
}
export type CallFunctionParams = {
export type CallFunctionParams = {
pageId:
number
pageId:
string
elementId: string
elementId: string
functionName: string
functionName: string
args: any[]
args: any[]
...
@@ -141,7 +141,7 @@ export const callFunction = (params: CallFunctionParams): void => {
...
@@ -141,7 +141,7 @@ export const callFunction = (params: CallFunctionParams): void => {
}
}
export type TapParams = {
export type TapParams = {
pageId:
number
pageId:
string
elementId?: string | null
elementId?: string | null
nodeId?: number | null
nodeId?: number | null
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
...
@@ -158,7 +158,7 @@ export const tap = (params: TapParams): void => {
...
@@ -158,7 +158,7 @@ export const tap = (params: TapParams): void => {
}
}
export type CallMethodParams = {
export type CallMethodParams = {
pageId:
number
pageId:
string
nodeId: number
nodeId: number
method: string
method: string
args: any[]
args: any[]
...
@@ -174,7 +174,7 @@ export const callMethod = (params: CallMethodParams): void => {
...
@@ -174,7 +174,7 @@ export const callMethod = (params: CallMethodParams): void => {
}
}
export type GetDataParams = {
export type GetDataParams = {
pageId:
number
pageId:
string
nodeId: number
nodeId: number
path: string
path: string
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
...
@@ -188,7 +188,7 @@ export const getData = (params: GetDataParams): void => {
...
@@ -188,7 +188,7 @@ export const getData = (params: GetDataParams): void => {
}
}
export type SetDataParams = {
export type SetDataParams = {
pageId:
number
pageId:
string
nodeId: number
nodeId: number
data: UTSJSONObject
data: UTSJSONObject
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
...
@@ -202,7 +202,7 @@ export const setData = (params: SetDataParams): void => {
...
@@ -202,7 +202,7 @@ export const setData = (params: SetDataParams): void => {
}
}
export type GetOffsetParams = {
export type GetOffsetParams = {
pageId:
number
pageId:
string
elementId?: string | null
elementId?: string | null
nodeId?: number | null
nodeId?: number | null
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
...
@@ -216,7 +216,7 @@ export const getOffset = (params: GetOffsetParams): void => {
...
@@ -216,7 +216,7 @@ export const getOffset = (params: GetOffsetParams): void => {
}
}
export type LongpressParams = {
export type LongpressParams = {
pageId:
number
pageId:
string
elementId?: string | null
elementId?: string | null
nodeId?: number | null
nodeId?: number | null
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
...
@@ -233,7 +233,7 @@ export const longpress = (params: LongpressParams): void => {
...
@@ -233,7 +233,7 @@ export const longpress = (params: LongpressParams): void => {
}
}
export type HandleTouchEventParams = {
export type HandleTouchEventParams = {
pageId:
number
pageId:
string
elementId?: string | null
elementId?: string | null
nodeId?: number | null
nodeId?: number | null
eventName: string
eventName: string
...
@@ -264,7 +264,7 @@ function getTouches(touches: any[]): Touch[] {
...
@@ -264,7 +264,7 @@ function getTouches(touches: any[]): Touch[] {
}
}
export type GetStylesParams = {
export type GetStylesParams = {
pageId:
number
pageId:
string
elementId?: string | null
elementId?: string | null
nodeId?: number | null
nodeId?: number | null
names: string[]
names: string[]
...
...
packages/uni-app-uts/lib/automator/apis/Page.uts
浏览文件 @
bf16c135
import { pageGetData, pageSetData, getPageVm, getValidComponentsOrNodes } from './util.uts'
import { pageGetData, pageSetData, getPageVm, getValidComponentsOrNodes } from './util.uts'
export type GetDataParams = {
export type GetDataParams = {
pageId:
number
pageId:
string
path: string
path: string
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
}
}
...
@@ -17,7 +17,7 @@ export const getData = (params: GetDataParams): void => {
...
@@ -17,7 +17,7 @@ export const getData = (params: GetDataParams): void => {
}
}
export type SetDataParams = {
export type SetDataParams = {
pageId:
number
pageId:
string
data: UTSJSONObject
data: UTSJSONObject
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
}
}
...
@@ -33,7 +33,7 @@ export const setData = (params: SetDataParams): void => {
...
@@ -33,7 +33,7 @@ export const setData = (params: SetDataParams): void => {
}
}
}
}
export type CallMethodParams = {
export type CallMethodParams = {
pageId:
number
pageId:
string
method: string
method: string
args: any[]
args: any[]
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
...
@@ -52,7 +52,7 @@ export const callMethod = (params: CallMethodParams): void => {
...
@@ -52,7 +52,7 @@ export const callMethod = (params: CallMethodParams): void => {
}
}
export type GetElementParams = {
export type GetElementParams = {
pageId:
number
pageId:
string
selector: string
selector: string
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
}
}
...
@@ -91,7 +91,7 @@ export const getElements = (params: GetElementParams): void => {
...
@@ -91,7 +91,7 @@ export const getElements = (params: GetElementParams): void => {
}
}
export type GetWindowPropertiesParams = {
export type GetWindowPropertiesParams = {
pageId:
number
,
pageId:
string
,
names: string[],
names: string[],
callback: (result: any | null, error: any | null) => void
callback: (result: any | null, error: any | null) => void
}
}
...
...
packages/uni-app-uts/lib/automator/apis/util.uts
浏览文件 @
bf16c135
function getPageId(page: BasePage):
number
{
function getPageId(page: BasePage):
string
{
return page.$
.ui
d
return page.$
appPage!.pageI
d
}
}
function getPagePath(page: BasePage): string {
function getPagePath(page: BasePage): string {
...
@@ -10,7 +10,7 @@ function getPageQuery(page: BasePage): Map<string, string | null> {
...
@@ -10,7 +10,7 @@ function getPageQuery(page: BasePage): Map<string, string | null> {
return page.options
return page.options
}
}
function getPageById(id:
number
): BasePage | null {
function getPageById(id:
string
): BasePage | null {
const pages = getCurrentPages()
const pages = getCurrentPages()
let result: BasePage | null = null
let result: BasePage | null = null
pages.forEach((page: BasePage) => {
pages.forEach((page: BasePage) => {
...
@@ -21,7 +21,7 @@ function getPageById(id: number): BasePage | null {
...
@@ -21,7 +21,7 @@ function getPageById(id: number): BasePage | null {
return result
return result
}
}
export function getPageVm(id:
number
): BasePage | null {
export function getPageVm(id:
string
): BasePage | null {
return getPageById(id)
return getPageById(id)
}
}
...
@@ -54,7 +54,7 @@ export function parsePage(page: BasePage): UTSJSONObject {
...
@@ -54,7 +54,7 @@ export function parsePage(page: BasePage): UTSJSONObject {
} as UTSJSONObject
} as UTSJSONObject
}
}
export function getComponentVmBySelector(pageId:
number
, selector: string, callback: (result: any | null, error: any | null) => void): ComponentPublicInstance | null {
export function getComponentVmBySelector(pageId:
string
, selector: string, callback: (result: any | null, error: any | null) => void): ComponentPublicInstance | null {
const page = getPageVm(pageId)
const page = getPageVm(pageId)
if (page == null) {
if (page == null) {
callback(null, { errMsg: `Page[${pageId}] not exists` })
callback(null, { errMsg: `Page[${pageId}] not exists` })
...
@@ -68,7 +68,7 @@ export function getComponentVmBySelector(pageId: number, selector: string, callb
...
@@ -68,7 +68,7 @@ export function getComponentVmBySelector(pageId: number, selector: string, callb
return component
return component
}
}
export function getComponentVmByNodeId(pageId:
number
, nodeId: number, callback: (result: any | null, error: any | null) => void): ComponentPublicInstance | null {
export function getComponentVmByNodeId(pageId:
string
, nodeId: number, callback: (result: any | null, error: any | null) => void): ComponentPublicInstance | null {
const page = getPageVm(pageId)
const page = getPageVm(pageId)
if (page == null) {
if (page == null) {
callback(null, { errMsg: `Page[${pageId}] not exists` })
callback(null, { errMsg: `Page[${pageId}] not exists` })
...
@@ -76,7 +76,7 @@ export function getComponentVmByNodeId(pageId: number, nodeId: number, callback:
...
@@ -76,7 +76,7 @@ export function getComponentVmByNodeId(pageId: number, nodeId: number, callback:
}
}
let component: ComponentPublicInstance | null = null
let component: ComponentPublicInstance | null = null
function getComponentChild(parent: ComponentPublicInstance) {
function getComponentChild(parent: ComponentPublicInstance) {
if (parent.$.uid == nodeId) {
if (parent.$.uid
.toInt()
== nodeId) {
component = parent
component = parent
return
return
}
}
...
@@ -92,7 +92,7 @@ export function getComponentVmByNodeId(pageId: number, nodeId: number, callback:
...
@@ -92,7 +92,7 @@ export function getComponentVmByNodeId(pageId: number, nodeId: number, callback:
return component
return component
}
}
export function getElementByIdOrNodeId(pageId:
number
, elementId: string | null, nodeId: number | null, callback: (result: any | null, error: any | null) => void): INode | null {
export function getElementByIdOrNodeId(pageId:
string
, elementId: string | null, nodeId: number | null, callback: (result: any | null, error: any | null) => void): INode | null {
if (nodeId != null) {
if (nodeId != null) {
return getComponentDomByNodeId(pageId, nodeId, callback)
return getComponentDomByNodeId(pageId, nodeId, callback)
} else if (elementId != null) {
} else if (elementId != null) {
...
@@ -101,7 +101,7 @@ export function getElementByIdOrNodeId(pageId: number, elementId: string | null,
...
@@ -101,7 +101,7 @@ export function getElementByIdOrNodeId(pageId: number, elementId: string | null,
return null
return null
}
}
export function getComponentDomByNodeId(pageId:
number
, nodeId: number, callback: (result: any | null, error: any | null) => void): INode | null {
export function getComponentDomByNodeId(pageId:
string
, nodeId: number, callback: (result: any | null, error: any | null) => void): INode | null {
const component = getComponentVmByNodeId(pageId, nodeId, callback)
const component = getComponentVmByNodeId(pageId, nodeId, callback)
if (component == null) {
if (component == null) {
return null
return null
...
@@ -109,7 +109,7 @@ export function getComponentDomByNodeId(pageId: number, nodeId: number, callback
...
@@ -109,7 +109,7 @@ export function getComponentDomByNodeId(pageId: number, nodeId: number, callback
return component.$el
return component.$el
}
}
export function getElementByNodeIdOrElementId(pageId:
number
, nodeId: number | null, elementId: string | null, callback: (result: any | null, error: any | null) => void): INode | null {
export function getElementByNodeIdOrElementId(pageId:
string
, nodeId: number | null, elementId: string | null, callback: (result: any | null, error: any | null) => void): INode | null {
const page = getPageVm(pageId)
const page = getPageVm(pageId)
if (page == null) {
if (page == null) {
callback(null, { errMsg: `Page[${pageId}] not exists` })
callback(null, { errMsg: `Page[${pageId}] not exists` })
...
@@ -123,7 +123,7 @@ export function getElementByNodeIdOrElementId(pageId: number, nodeId: number | n
...
@@ -123,7 +123,7 @@ export function getElementByNodeIdOrElementId(pageId: number, nodeId: number | n
return null
return null
}
}
export function getElementById(pageId:
number
, elementId: string, callback: (result: any | null, error: any | null) => void): INode | null {
export function getElementById(pageId:
string
, elementId: string, callback: (result: any | null, error: any | null) => void): INode | null {
const page = getPageVm(pageId)
const page = getPageVm(pageId)
if (page == null) {
if (page == null) {
callback(null, { errMsg: `Page[${pageId}] not exists` })
callback(null, { errMsg: `Page[${pageId}] not exists` })
...
...
packages/uni-app-uts/lib/automator/index.uts
浏览文件 @
bf16c135
...
@@ -104,7 +104,7 @@ export function onMessage(msg: string) {
...
@@ -104,7 +104,7 @@ export function onMessage(msg: string) {
break
break
}
}
} else if (method.startsWith('Page.')) {
} else if (method.startsWith('Page.')) {
const pageId = params['pageId'] as
number
const pageId = params['pageId'] as
string
switch (method) {
switch (method) {
case 'Page.getData':
case 'Page.getData':
const path = params['path'] != null ? (params['path'] as string) : ''
const path = params['path'] != null ? (params['path'] as string) : ''
...
@@ -136,7 +136,7 @@ export function onMessage(msg: string) {
...
@@ -136,7 +136,7 @@ export function onMessage(msg: string) {
break
break
}
}
} else if (method.startsWith('Element.')) {
} else if (method.startsWith('Element.')) {
const pageId = params['pageId'] as
number
const pageId = params['pageId'] as
string
switch (method) {
switch (method) {
case 'Element.getElement':
case 'Element.getElement':
const getElementElementId = params['elementId'] != null ? params['elementId'] as string : null
const getElementElementId = params['elementId'] != null ? params['elementId'] as string : null
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录