Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
e67918ce
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e67918ce
编写于
9月 06, 2023
作者:
G
guojin31
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
上传下载、输入法示例代码ArkTs规范整改
Signed-off-by:
N
guojin31
<
guojin31@huawei.com
>
上级
74e05859
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
360 addition
and
378 deletion
+360
-378
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md
...v/reference/apis/js-apis-inputmethod-extension-context.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+36
-36
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+60
-60
zh-cn/application-dev/reference/apis/js-apis-request.md
zh-cn/application-dev/reference/apis/js-apis-request.md
+262
-280
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md
浏览文件 @
e67918ce
...
@@ -43,7 +43,7 @@ destroy(callback: AsyncCallback\<void>): void
...
@@ -43,7 +43,7 @@ destroy(callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
ts
```
ts
this
.
context
.
destroy
((
err
:
Error
)
=>
{
this
.
context
.
destroy
((
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
Failed to destroy context.
'
);
console
.
log
(
'
Failed to destroy context.
'
);
return
;
return
;
...
@@ -71,7 +71,7 @@ destroy(): Promise\<void>;
...
@@ -71,7 +71,7 @@ destroy(): Promise\<void>;
```
ts
```
ts
this
.
context
.
destroy
().
then
(()
=>
{
this
.
context
.
destroy
().
then
(()
=>
{
console
.
log
(
'
Succeed in destroying context.
'
);
console
.
log
(
'
Succeed in destroying context.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
log
(
'
Failed to destroy context.
'
);
console
.
log
(
'
Failed to destroy context.
'
);
});
});
```
```
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
e67918ce
...
@@ -128,7 +128,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
...
@@ -128,7 +128,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
```
ts
```
ts
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
try
{
try
{
inputMethod
.
switchInputMethod
(
currentIme
,
(
err
:
Error
,
result
:
boolean
)
=>
{
inputMethod
.
switchInputMethod
(
currentIme
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to switchInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to switchInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -184,7 +184,7 @@ try {
...
@@ -184,7 +184,7 @@ try {
}
else
{
}
else
{
console
.
error
(
'
Failed to switchInputMethod.
'
);
console
.
error
(
'
Failed to switchInputMethod.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to switchInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to switchInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -257,7 +257,7 @@ try {
...
@@ -257,7 +257,7 @@ try {
icon
:
""
,
icon
:
""
,
iconId
:
0
,
iconId
:
0
,
extra
:
extra
extra
:
extra
},
(
err
:
Error
,
result
:
boolean
)
=>
{
},
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to switchCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to switchCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -329,7 +329,7 @@ try {
...
@@ -329,7 +329,7 @@ try {
}
else
{
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype.
'
);
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to switchCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to switchCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -390,7 +390,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
...
@@ -390,7 +390,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
let
currentIme
=
inputMethod
.
getCurrentInputMethod
();
let
imSubType
=
inputMethod
.
getCurrentInputMethodSubtype
();
let
imSubType
=
inputMethod
.
getCurrentInputMethodSubtype
();
try
{
try
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
currentIme
,
imSubType
,
(
err
:
Error
,
result
:
boolean
)
=>
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
currentIme
,
imSubType
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to switchCurrentInputMethodAndSubtype:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to switchCurrentInputMethodAndSubtype:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -450,7 +450,7 @@ try {
...
@@ -450,7 +450,7 @@ try {
}
else
{
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype.
'
);
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to switchCurrentInputMethodAndSubtype:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to switchCurrentInputMethodAndSubtype:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -704,7 +704,7 @@ try {
...
@@ -704,7 +704,7 @@ try {
enterKeyType
:
1
enterKeyType
:
1
}
}
};
};
inputMethodController
.
attach
(
true
,
textConfig
,
(
err
:
Error
)
=>
{
inputMethodController
.
attach
(
true
,
textConfig
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to attach:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to attach:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -762,7 +762,7 @@ try {
...
@@ -762,7 +762,7 @@ try {
};
};
inputMethodController
.
attach
(
true
,
textConfig
).
then
(()
=>
{
inputMethodController
.
attach
(
true
,
textConfig
).
then
(()
=>
{
console
.
log
(
'
Succeeded in attaching inputMethod.
'
);
console
.
log
(
'
Succeeded in attaching inputMethod.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to attach:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to attach:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -801,7 +801,7 @@ showTextInput(callback: AsyncCallback<void>): void
...
@@ -801,7 +801,7 @@ showTextInput(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
ts
```
ts
inputMethodController
.
showTextInput
((
err
:
Error
)
=>
{
inputMethodController
.
showTextInput
((
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to showTextInput:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to showTextInput:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -843,7 +843,7 @@ showTextInput(): Promise<void>
...
@@ -843,7 +843,7 @@ showTextInput(): Promise<void>
```
ts
```
ts
inputMethodController
.
showTextInput
().
then
(()
=>
{
inputMethodController
.
showTextInput
().
then
(()
=>
{
console
.
log
(
'
Succeeded in showing text input.
'
);
console
.
log
(
'
Succeeded in showing text input.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to showTextInput:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to showTextInput:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -881,7 +881,7 @@ hideTextInput(callback: AsyncCallback<void>): void
...
@@ -881,7 +881,7 @@ hideTextInput(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
ts
```
ts
inputMethodController
.
hideTextInput
((
err
:
Error
)
=>
{
inputMethodController
.
hideTextInput
((
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to hideTextInput:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to hideTextInput:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -925,7 +925,7 @@ hideTextInput(): Promise<void>
...
@@ -925,7 +925,7 @@ hideTextInput(): Promise<void>
```
ts
```
ts
inputMethodController
.
hideTextInput
().
then
(()
=>
{
inputMethodController
.
hideTextInput
().
then
(()
=>
{
console
.
log
(
'
Succeeded in hiding inputMethod.
'
);
console
.
log
(
'
Succeeded in hiding inputMethod.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to hideTextInput:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to hideTextInput:
${
JSON
.
stringify
(
err
)}
`
);
})
})
```
```
...
@@ -956,7 +956,7 @@ detach(callback: AsyncCallback<void>): void
...
@@ -956,7 +956,7 @@ detach(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
ts
```
ts
inputMethodController
.
detach
((
err
:
Error
)
=>
{
inputMethodController
.
detach
((
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to detach:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to detach:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -993,7 +993,7 @@ detach(): Promise<void>
...
@@ -993,7 +993,7 @@ detach(): Promise<void>
```
ts
```
ts
inputMethodController
.
detach
().
then
(()
=>
{
inputMethodController
.
detach
().
then
(()
=>
{
console
.
log
(
'
Succeeded in detaching inputMethod.
'
);
console
.
log
(
'
Succeeded in detaching inputMethod.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to detach:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to detach:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1032,7 +1032,7 @@ setCallingWindow(windowId: number, callback: AsyncCallback<void>): void
...
@@ -1032,7 +1032,7 @@ setCallingWindow(windowId: number, callback: AsyncCallback<void>): void
```
ts
```
ts
try
{
try
{
let
windowId
:
number
=
2000
;
let
windowId
:
number
=
2000
;
inputMethodController
.
setCallingWindow
(
windowId
,
(
err
:
Error
)
=>
{
inputMethodController
.
setCallingWindow
(
windowId
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to setCallingWindow:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to setCallingWindow:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1085,7 +1085,7 @@ try {
...
@@ -1085,7 +1085,7 @@ try {
let
windowId
:
number
=
2000
;
let
windowId
:
number
=
2000
;
inputMethodController
.
setCallingWindow
(
windowId
).
then
(()
=>
{
inputMethodController
.
setCallingWindow
(
windowId
).
then
(()
=>
{
console
.
log
(
'
Succeeded in setting callingWindow.
'
);
console
.
log
(
'
Succeeded in setting callingWindow.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to setCallingWindow:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to setCallingWindow:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1123,7 +1123,7 @@ updateCursor(cursorInfo: CursorInfo, callback: AsyncCallback<void>): void
...
@@ -1123,7 +1123,7 @@ updateCursor(cursorInfo: CursorInfo, callback: AsyncCallback<void>): void
```
ts
```
ts
try
{
try
{
let
cursorInfo
:
inputMethod
.
CursorInfo
=
{
left
:
0
,
top
:
0
,
width
:
600
,
height
:
800
};
let
cursorInfo
:
inputMethod
.
CursorInfo
=
{
left
:
0
,
top
:
0
,
width
:
600
,
height
:
800
};
inputMethodController
.
updateCursor
(
cursorInfo
,
(
err
:
Error
)
=>
{
inputMethodController
.
updateCursor
(
cursorInfo
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to updateCursor:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to updateCursor:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1172,7 +1172,7 @@ try {
...
@@ -1172,7 +1172,7 @@ try {
let
cursorInfo
:
inputMethod
.
CursorInfo
=
{
left
:
0
,
top
:
0
,
width
:
600
,
height
:
800
};
let
cursorInfo
:
inputMethod
.
CursorInfo
=
{
left
:
0
,
top
:
0
,
width
:
600
,
height
:
800
};
inputMethodController
.
updateCursor
(
cursorInfo
).
then
(()
=>
{
inputMethodController
.
updateCursor
(
cursorInfo
).
then
(()
=>
{
console
.
log
(
'
Succeeded in updating cursorInfo.
'
);
console
.
log
(
'
Succeeded in updating cursorInfo.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to updateCursor:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to updateCursor:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1211,7 +1211,7 @@ changeSelection(text: string, start: number, end: number, callback: AsyncCallbac
...
@@ -1211,7 +1211,7 @@ changeSelection(text: string, start: number, end: number, callback: AsyncCallbac
```
ts
```
ts
try
{
try
{
inputMethodController
.
changeSelection
(
'
text
'
,
0
,
5
,
(
err
:
Error
)
=>
{
inputMethodController
.
changeSelection
(
'
text
'
,
0
,
5
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to changeSelection:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to changeSelection:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1261,7 +1261,7 @@ changeSelection(text: string, start: number, end: number): Promise<void>
...
@@ -1261,7 +1261,7 @@ changeSelection(text: string, start: number, end: number): Promise<void>
try
{
try
{
inputMethodController
.
changeSelection
(
'
test
'
,
0
,
5
).
then
(()
=>
{
inputMethodController
.
changeSelection
(
'
test
'
,
0
,
5
).
then
(()
=>
{
console
.
log
(
'
Succeeded in changing selection.
'
);
console
.
log
(
'
Succeeded in changing selection.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to changeSelection:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to changeSelection:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1299,7 +1299,7 @@ updateAttribute(attribute: InputAttribute, callback: AsyncCallback<void>):
...
@@ -1299,7 +1299,7 @@ updateAttribute(attribute: InputAttribute, callback: AsyncCallback<void>):
```
ts
```
ts
try
{
try
{
let
inputAttribute
:
inputMethod
.
InputAttribute
=
{
textInputType
:
0
,
enterKeyType
:
1
};
let
inputAttribute
:
inputMethod
.
InputAttribute
=
{
textInputType
:
0
,
enterKeyType
:
1
};
inputMethodController
.
updateAttribute
(
inputAttribute
,
(
err
:
Error
)
=>
{
inputMethodController
.
updateAttribute
(
inputAttribute
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to updateAttribute:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to updateAttribute:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1348,7 +1348,7 @@ try {
...
@@ -1348,7 +1348,7 @@ try {
let
inputAttribute
:
inputMethod
.
InputAttribute
=
{
textInputType
:
0
,
enterKeyType
:
1
};
let
inputAttribute
:
inputMethod
.
InputAttribute
=
{
textInputType
:
0
,
enterKeyType
:
1
};
inputMethodController
.
updateAttribute
(
inputAttribute
).
then
(()
=>
{
inputMethodController
.
updateAttribute
(
inputAttribute
).
then
(()
=>
{
console
.
log
(
'
Succeeded in updating attribute.
'
);
console
.
log
(
'
Succeeded in updating attribute.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to updateAttribute:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to updateAttribute:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1387,7 +1387,7 @@ stopInputSession(callback: AsyncCallback<boolean>): void
...
@@ -1387,7 +1387,7 @@ stopInputSession(callback: AsyncCallback<boolean>): void
```
ts
```
ts
try
{
try
{
inputMethodController
.
stopInputSession
((
err
:
Error
,
result
:
boolean
)
=>
{
inputMethodController
.
stopInputSession
((
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to stopInputSession:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to stopInputSession:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1440,7 +1440,7 @@ try {
...
@@ -1440,7 +1440,7 @@ try {
}
else
{
}
else
{
console
.
error
(
'
Failed to stopInputSession.
'
);
console
.
error
(
'
Failed to stopInputSession.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to stopInputSession:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to stopInputSession:
${
JSON
.
stringify
(
err
)}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1480,7 +1480,7 @@ showSoftKeyboard(callback: AsyncCallback<void>): void
...
@@ -1480,7 +1480,7 @@ showSoftKeyboard(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
ts
```
ts
inputMethodController
.
showSoftKeyboard
((
err
:
Error
)
=>
{
inputMethodController
.
showSoftKeyboard
((
err
:
Business
Error
)
=>
{
if
(
!
err
)
{
if
(
!
err
)
{
console
.
log
(
'
Succeeded in showing softKeyboard.
'
);
console
.
log
(
'
Succeeded in showing softKeyboard.
'
);
}
else
{
}
else
{
...
@@ -1523,7 +1523,7 @@ showSoftKeyboard(): Promise<void>
...
@@ -1523,7 +1523,7 @@ showSoftKeyboard(): Promise<void>
```
ts
```
ts
inputMethodController
.
showSoftKeyboard
().
then
(()
=>
{
inputMethodController
.
showSoftKeyboard
().
then
(()
=>
{
console
.
log
(
'
Succeeded in showing softKeyboard.
'
);
console
.
log
(
'
Succeeded in showing softKeyboard.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to show softKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to show softKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1560,7 +1560,7 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void
...
@@ -1560,7 +1560,7 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
ts
```
ts
inputMethodController
.
hideSoftKeyboard
((
err
:
Error
)
=>
{
inputMethodController
.
hideSoftKeyboard
((
err
:
Business
Error
)
=>
{
if
(
!
err
)
{
if
(
!
err
)
{
console
.
log
(
'
Succeeded in hiding softKeyboard.
'
);
console
.
log
(
'
Succeeded in hiding softKeyboard.
'
);
}
else
{
}
else
{
...
@@ -1603,7 +1603,7 @@ hideSoftKeyboard(): Promise<void>
...
@@ -1603,7 +1603,7 @@ hideSoftKeyboard(): Promise<void>
```
ts
```
ts
inputMethodController
.
hideSoftKeyboard
().
then
(()
=>
{
inputMethodController
.
hideSoftKeyboard
().
then
(()
=>
{
console
.
log
(
'
Succeeded in hiding softKeyboard.
'
);
console
.
log
(
'
Succeeded in hiding softKeyboard.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to hide softKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to hide softKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1631,7 +1631,7 @@ stopInput(callback: AsyncCallback<boolean>): void
...
@@ -1631,7 +1631,7 @@ stopInput(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
ts
```
ts
inputMethodController
.
stopInput
((
err
:
Error
,
result
:
boolean
)
=>
{
inputMethodController
.
stopInput
((
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to stopInput:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to stopInput:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1673,7 +1673,7 @@ inputMethodController.stopInput().then((result: boolean) => {
...
@@ -1673,7 +1673,7 @@ inputMethodController.stopInput().then((result: boolean) => {
}
else
{
}
else
{
console
.
error
(
'
Failed to stopInput.
'
);
console
.
error
(
'
Failed to stopInput.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to stopInput:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to stopInput:
${
JSON
.
stringify
(
err
)}
`
);
})
})
```
```
...
@@ -2577,7 +2577,7 @@ let inputMethodProperty: inputMethod.InputMethodProperty = {
...
@@ -2577,7 +2577,7 @@ let inputMethodProperty: inputMethod.InputMethodProperty = {
id
:
'
propertyId
'
,
id
:
'
propertyId
'
,
}
}
try
{
try
{
inputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
,
(
err
:
Error
,
data
:
Array
<
InputMethodSubtype
>
)
=>
{
inputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
,
(
err
:
Business
Error
,
data
:
Array
<
InputMethodSubtype
>
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to listInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to listInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2665,7 +2665,7 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub
...
@@ -2665,7 +2665,7 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub
```
ts
```
ts
try
{
try
{
inputMethodSetting
.
listCurrentInputMethodSubtype
((
err
:
Error
,
data
:
Array
<
InputMethodSubtype
>
)
=>
{
inputMethodSetting
.
listCurrentInputMethodSubtype
((
err
:
Business
Error
,
data
:
Array
<
InputMethodSubtype
>
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to listCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to listCurrentInputMethodSubtype:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2748,7 +2748,7 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod
...
@@ -2748,7 +2748,7 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod
```
ts
```
ts
try
{
try
{
inputMethodSetting
.
getInputMethods
(
true
,
(
err
:
Error
,
data
:
Array
<
inputMethod
.
InputMethodProperty
>
)
=>
{
inputMethodSetting
.
getInputMethods
(
true
,
(
err
:
Business
Error
,
data
:
Array
<
inputMethod
.
InputMethodProperty
>
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to getInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2835,7 +2835,7 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void
...
@@ -2835,7 +2835,7 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void
```
ts
```
ts
try
{
try
{
inputMethodSetting
.
showOptionalInputMethods
((
err
:
Error
,
data
:
boolean
)
=>
{
inputMethodSetting
.
showOptionalInputMethods
((
err
:
Business
Error
,
data
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to showOptionalInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to showOptionalInputMethods:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2900,7 +2900,7 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
...
@@ -2900,7 +2900,7 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
**示例:**
**示例:**
```
ts
```
ts
inputMethodSetting
.
listInputMethod
((
err
:
Error
,
data
:
Array
<
inputMethod
.
InputMethodProperty
>
)
=>
{
inputMethodSetting
.
listInputMethod
((
err
:
Business
Error
,
data
:
Array
<
inputMethod
.
InputMethodProperty
>
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to listInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to listInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2958,7 +2958,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
...
@@ -2958,7 +2958,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
ts
```
ts
inputMethodSetting
.
displayOptionalInputMethod
((
err
:
Error
)
=>
{
inputMethodSetting
.
displayOptionalInputMethod
((
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to displayOptionalInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to displayOptionalInputMethod:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
e67918ce
...
@@ -512,7 +512,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
...
@@ -512,7 +512,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
}
}
try
{
try
{
inputMethodEngine
.
getInputMethodAbility
()
inputMethodEngine
.
getInputMethodAbility
()
.
createPanel
(
this
.
context
,
panelInfo
,
(
err
:
Error
,
panel
:
inputMethodEngine
.
Panel
)
=>
{
.
createPanel
(
this
.
context
,
panelInfo
,
(
err
:
Business
Error
,
panel
:
inputMethodEngine
.
Panel
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to createPanel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to createPanel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -560,7 +560,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
...
@@ -560,7 +560,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
)
inputMethodEngine
.
getInputMethodAbility
().
createPanel
(
this
.
context
,
panelInfo
)
.
then
((
panel
:
inputMethodEngine
.
Panel
)
=>
{
.
then
((
panel
:
inputMethodEngine
.
Panel
)
=>
{
console
.
log
(
'
Succeed in creating panel.
'
);
console
.
log
(
'
Succeed in creating panel.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
})
})
```
```
...
@@ -590,7 +590,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
...
@@ -590,7 +590,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
let
inputPanel
:
inputMethodEngine
.
Panel
|
undefined
=
undefined
;
let
inputPanel
:
inputMethodEngine
.
Panel
|
undefined
=
undefined
;
try
{
try
{
inputMethodEngine
.
getInputMethodAbility
()
inputMethodEngine
.
getInputMethodAbility
()
.
createPanel
(
this
.
context
,
panelInfo
,
(
err
:
Error
,
panel
:
inputMethodEngine
.
Panel
)
=>
{
.
createPanel
(
this
.
context
,
panelInfo
,
(
err
:
Business
Error
,
panel
:
inputMethodEngine
.
Panel
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -603,7 +603,7 @@ try {
...
@@ -603,7 +603,7 @@ try {
}
}
try
{
try
{
if
(
inputPanel
)
{
if
(
inputPanel
)
{
inputMethodEngine
.
getInputMethodAbility
().
destroyPanel
(
inputPanel
,
(
err
:
Error
)
=>
{
inputMethodEngine
.
getInputMethodAbility
().
destroyPanel
(
inputPanel
,
(
err
:
Business
Error
)
=>
{
if
(
err
!==
undefined
)
{
if
(
err
!==
undefined
)
{
console
.
error
(
`Failed to destroy panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to destroy panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -645,7 +645,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
...
@@ -645,7 +645,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
let
inputPanel
:
inputMethodEngine
.
Panel
|
undefined
=
undefined
;
let
inputPanel
:
inputMethodEngine
.
Panel
|
undefined
=
undefined
;
try
{
try
{
inputMethodEngine
.
getInputMethodAbility
()
inputMethodEngine
.
getInputMethodAbility
()
.
createPanel
(
this
.
context
,
panelInfo
,
(
err
:
Error
,
panel
:
inputMethodEngine
.
Panel
)
=>
{
.
createPanel
(
this
.
context
,
panelInfo
,
(
err
:
Business
Error
,
panel
:
inputMethodEngine
.
Panel
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to create panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -661,7 +661,7 @@ try {
...
@@ -661,7 +661,7 @@ try {
if
(
inputPanel
)
{
if
(
inputPanel
)
{
inputMethodEngine
.
getInputMethodAbility
().
destroyPanel
(
inputPanel
).
then
(()
=>
{
inputMethodEngine
.
getInputMethodAbility
().
destroyPanel
(
inputPanel
).
then
(()
=>
{
console
.
log
(
'
Succeed in destroying panel.
'
);
console
.
log
(
'
Succeed in destroying panel.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to destroy panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to destroy panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
}
...
@@ -996,7 +996,7 @@ setUiContent(path: string, callback: AsyncCallback\<void>): void
...
@@ -996,7 +996,7 @@ setUiContent(path: string, callback: AsyncCallback\<void>): void
```
ts
```
ts
try
{
try
{
panel
.
setUiContent
(
'
pages/page2/page2
'
,
(
err
:
Error
)
=>
{
panel
.
setUiContent
(
'
pages/page2/page2
'
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1034,7 +1034,7 @@ setUiContent(path: string): Promise\<void>
...
@@ -1034,7 +1034,7 @@ setUiContent(path: string): Promise\<void>
try
{
try
{
panel
.
setUiContent
(
'
pages/page2/page2
'
).
then
(()
=>
{
panel
.
setUiContent
(
'
pages/page2/page2
'
).
then
(()
=>
{
console
.
log
(
'
Succeeded in setting the content.
'
);
console
.
log
(
'
Succeeded in setting the content.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1064,7 +1064,7 @@ setUiContent(path: string, storage: LocalStorage, callback: AsyncCallback\<void>
...
@@ -1064,7 +1064,7 @@ setUiContent(path: string, storage: LocalStorage, callback: AsyncCallback\<void>
let
storage
=
new
LocalStorage
();
let
storage
=
new
LocalStorage
();
storage
.
setOrCreate
(
'
storageSimpleProp
'
,
121
);
storage
.
setOrCreate
(
'
storageSimpleProp
'
,
121
);
try
{
try
{
panel
.
setUiContent
(
'
pages/page2/page2
'
,
storage
,
(
err
:
Error
)
=>
{
panel
.
setUiContent
(
'
pages/page2/page2
'
,
storage
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1105,7 +1105,7 @@ storage.setOrCreate('storageSimpleProp',121);
...
@@ -1105,7 +1105,7 @@ storage.setOrCreate('storageSimpleProp',121);
try
{
try
{
panel
.
setUiContent
(
'
pages/page2/page2
'
)
then
(()
=>
{
panel
.
setUiContent
(
'
pages/page2/page2
'
)
then
(()
=>
{
console
.
log
(
'
Succeeded in setting the content.
'
);
console
.
log
(
'
Succeeded in setting the content.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to setUiContent:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1137,7 +1137,7 @@ resize(width: number, height: number, callback: AsyncCallback\<void>): void
...
@@ -1137,7 +1137,7 @@ resize(width: number, height: number, callback: AsyncCallback\<void>): void
```
ts
```
ts
try
{
try
{
panel
.
resize
(
500
,
1000
,
(
err
:
Error
)
=>
{
panel
.
resize
(
500
,
1000
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to resize panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to resize panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1180,7 +1180,7 @@ resize(width: number, height: number): Promise\<void>;
...
@@ -1180,7 +1180,7 @@ resize(width: number, height: number): Promise\<void>;
try
{
try
{
panel
.
resize
(
500
,
1000
).
then
(()
=>
{
panel
.
resize
(
500
,
1000
).
then
(()
=>
{
console
.
log
(
'
Succeeded in changing the panel size.
'
);
console
.
log
(
'
Succeeded in changing the panel size.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to resize panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to resize panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1208,7 +1208,7 @@ moveTo(x: number, y: number, callback: AsyncCallback\<void>): void
...
@@ -1208,7 +1208,7 @@ moveTo(x: number, y: number, callback: AsyncCallback\<void>): void
```
ts
```
ts
try
{
try
{
panel
.
moveTo
(
300
,
300
,
(
err
:
Error
)
=>
{
panel
.
moveTo
(
300
,
300
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to move panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to move panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1247,7 +1247,7 @@ moveTo(x: number, y: number): Promise\<void>
...
@@ -1247,7 +1247,7 @@ moveTo(x: number, y: number): Promise\<void>
try
{
try
{
panel
.
moveTo
(
300
,
300
).
then
(()
=>
{
panel
.
moveTo
(
300
,
300
).
then
(()
=>
{
console
.
log
(
'
Succeeded in moving the panel.
'
);
console
.
log
(
'
Succeeded in moving the panel.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to move panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to move panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1272,7 +1272,7 @@ show(callback: AsyncCallback\<void>): void
...
@@ -1272,7 +1272,7 @@ show(callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
ts
```
ts
panel
.
show
((
err
:
Error
)
=>
{
panel
.
show
((
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to show panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to show panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1300,7 +1300,7 @@ show(): Promise\<void>
...
@@ -1300,7 +1300,7 @@ show(): Promise\<void>
```
ts
```
ts
panel
.
show
().
then
(()
=>
{
panel
.
show
().
then
(()
=>
{
console
.
log
(
'
Succeeded in showing the panel.
'
);
console
.
log
(
'
Succeeded in showing the panel.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to show panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to show panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1322,7 +1322,7 @@ hide(callback: AsyncCallback\<void>): void
...
@@ -1322,7 +1322,7 @@ hide(callback: AsyncCallback\<void>): void
**示例:**
**示例:**
```
ts
```
ts
panel
.
hide
((
err
:
Error
)
=>
{
panel
.
hide
((
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to hide panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to hide panel:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1350,7 +1350,7 @@ hide(): Promise\<void>
...
@@ -1350,7 +1350,7 @@ hide(): Promise\<void>
```
ts
```
ts
panel
.
hide
().
then
(()
=>
{
panel
.
hide
().
then
(()
=>
{
console
.
log
(
'
Succeeded in hiding the panel.
'
);
console
.
log
(
'
Succeeded in hiding the panel.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to hide panel:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to hide panel:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1493,7 +1493,7 @@ hide(callback: AsyncCallback<void>): void
...
@@ -1493,7 +1493,7 @@ hide(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
ts
```
ts
keyboardController
.
hide
((
err
:
Error
)
=>
{
keyboardController
.
hide
((
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to hide:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to hide:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1529,7 +1529,7 @@ hide(): Promise<void>
...
@@ -1529,7 +1529,7 @@ hide(): Promise<void>
```
ts
```
ts
keyboardController
.
hide
().
then
(()
=>
{
keyboardController
.
hide
().
then
(()
=>
{
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
log
(
`Failed to hide:
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`Failed to hide:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1555,7 +1555,7 @@ hideKeyboard(callback: AsyncCallback<void>): void
...
@@ -1555,7 +1555,7 @@ hideKeyboard(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
ts
```
ts
keyboardController
.
hideKeyboard
((
err
:
Error
)
=>
{
keyboardController
.
hideKeyboard
((
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to hideKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to hideKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1587,7 +1587,7 @@ hideKeyboard(): Promise<void>
...
@@ -1587,7 +1587,7 @@ hideKeyboard(): Promise<void>
```
ts
```
ts
keyboardController
.
hideKeyboard
().
then
(()
=>
{
keyboardController
.
hideKeyboard
().
then
(()
=>
{
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
console
.
log
(
'
Succeeded in hiding keyboard.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
log
(
`Failed to hideKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`Failed to hideKeyboard:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -1671,7 +1671,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
...
@@ -1671,7 +1671,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
```
ts
```
ts
let
action
=
1
;
let
action
=
1
;
try
{
try
{
inputClient
.
sendKeyFunction
(
action
,
(
err
:
Error
,
result
:
boolean
)
=>
{
inputClient
.
sendKeyFunction
(
action
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1726,7 +1726,7 @@ try {
...
@@ -1726,7 +1726,7 @@ try {
}
else
{
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1763,7 +1763,7 @@ getForward(length:number, callback: AsyncCallback<string>): void
...
@@ -1763,7 +1763,7 @@ getForward(length:number, callback: AsyncCallback<string>): void
```
ts
```
ts
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
getForward
(
length
,
(
err
:
Error
,
text
:
string
)
=>
{
inputClient
.
getForward
(
length
,
(
err
:
Business
Error
,
text
:
string
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1811,7 +1811,7 @@ let length = 1;
...
@@ -1811,7 +1811,7 @@ let length = 1;
try
{
try
{
inputClient
.
getForward
(
length
).
then
((
text
:
string
)
=>
{
inputClient
.
getForward
(
length
).
then
((
text
:
string
)
=>
{
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1889,7 +1889,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void
...
@@ -1889,7 +1889,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void
```
ts
```
ts
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
getBackward
(
length
,
(
err
:
Error
,
text
:
string
)
=>
{
inputClient
.
getBackward
(
length
,
(
err
:
Business
Error
,
text
:
string
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -1937,7 +1937,7 @@ let length = 1;
...
@@ -1937,7 +1937,7 @@ let length = 1;
try
{
try
{
inputClient
.
getBackward
(
length
).
then
((
text
:
string
)
=>
{
inputClient
.
getBackward
(
length
).
then
((
text
:
string
)
=>
{
console
.
log
(
'
Succeeded in getting backward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting backward, text:
'
+
text
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -2015,7 +2015,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
...
@@ -2015,7 +2015,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
```
ts
```
ts
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
deleteForward
(
length
,
(
err
:
Error
,
result
:
boolean
)
=>
{
inputClient
.
deleteForward
(
length
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2071,7 +2071,7 @@ try {
...
@@ -2071,7 +2071,7 @@ try {
}
else
{
}
else
{
console
.
error
(
'
Failed to delete Forward.
'
);
console
.
error
(
'
Failed to delete Forward.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -2143,7 +2143,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
...
@@ -2143,7 +2143,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
```
ts
```
ts
let
length
=
1
;
let
length
=
1
;
try
{
try
{
inputClient
.
deleteBackward
(
length
,
(
err
:
Error
,
result
:
boolean
)
=>
{
inputClient
.
deleteBackward
(
length
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2198,7 +2198,7 @@ inputClient.deleteBackward(length).then((result: boolean) => {
...
@@ -2198,7 +2198,7 @@ inputClient.deleteBackward(length).then((result: boolean) => {
}
else
{
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -2265,7 +2265,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
...
@@ -2265,7 +2265,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
ts
```
ts
inputClient
.
insertText
(
'
test
'
,
(
err
:
Error
,
result
:
boolean
)
=>
{
inputClient
.
insertText
(
'
test
'
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2317,7 +2317,7 @@ try {
...
@@ -2317,7 +2317,7 @@ try {
}
else
{
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
console
.
error
(
'
Failed to insertText.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -2384,7 +2384,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
...
@@ -2384,7 +2384,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
**示例:**
**示例:**
```
ts
```
ts
inputClient
.
getEditorAttribute
((
err
:
Error
,
editorAttribute
:
inputMethodEngine
.
EditorAttribute
)
=>
{
inputClient
.
getEditorAttribute
((
err
:
Business
Error
,
editorAttribute
:
inputMethodEngine
.
EditorAttribute
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2422,7 +2422,7 @@ getEditorAttribute(): Promise<EditorAttribute>
...
@@ -2422,7 +2422,7 @@ getEditorAttribute(): Promise<EditorAttribute>
inputClient
.
getEditorAttribute
().
then
((
editorAttribute
:
inputMethodEngine
.
EditorAttribute
)
=>
{
inputClient
.
getEditorAttribute
().
then
((
editorAttribute
:
inputMethodEngine
.
EditorAttribute
)
=>
{
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
log
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
console
.
log
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -2487,7 +2487,7 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void
...
@@ -2487,7 +2487,7 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void
```
ts
```
ts
try
{
try
{
inputClient
.
moveCursor
(
inputMethodEngine
.
Direction
.
CURSOR_UP
,
(
err
:
Error
)
=>
{
inputClient
.
moveCursor
(
inputMethodEngine
.
Direction
.
CURSOR_UP
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to moveCursor:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to moveCursor:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2533,7 +2533,7 @@ moveCursor(direction: number): Promise<void>
...
@@ -2533,7 +2533,7 @@ moveCursor(direction: number): Promise<void>
try
{
try
{
inputClient
.
moveCursor
(
inputMethodEngine
.
Direction
.
CURSOR_UP
).
then
(()
=>
{
inputClient
.
moveCursor
(
inputMethodEngine
.
Direction
.
CURSOR_UP
).
then
(()
=>
{
console
.
log
(
'
Succeeded in moving cursor.
'
);
console
.
log
(
'
Succeeded in moving cursor.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to moveCursor:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to moveCursor:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -2603,7 +2603,7 @@ selectByRange(range: Range, callback: AsyncCallback<void>): void
...
@@ -2603,7 +2603,7 @@ selectByRange(range: Range, callback: AsyncCallback<void>): void
```
ts
```
ts
try
{
try
{
let
range
:
inputMethodEngine
.
Range
=
{
start
:
0
,
end
:
1
};
let
range
:
inputMethodEngine
.
Range
=
{
start
:
0
,
end
:
1
};
inputClient
.
selectByRange
(
range
,
(
err
:
Error
)
=>
{
inputClient
.
selectByRange
(
range
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to selectByRange:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to selectByRange:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2651,7 +2651,7 @@ try {
...
@@ -2651,7 +2651,7 @@ try {
let
range
:
inputMethodEngine
.
Range
=
{
start
:
0
,
end
:
1
};
let
range
:
inputMethodEngine
.
Range
=
{
start
:
0
,
end
:
1
};
inputClient
.
selectByRange
(
range
).
then
(()
=>
{
inputClient
.
selectByRange
(
range
).
then
(()
=>
{
console
.
log
(
'
Succeeded in selecting by range.
'
);
console
.
log
(
'
Succeeded in selecting by range.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to selectByRange:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to selectByRange:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -2723,7 +2723,7 @@ selectByMovement(movement: Movement, callback: AsyncCallback<void>): void
...
@@ -2723,7 +2723,7 @@ selectByMovement(movement: Movement, callback: AsyncCallback<void>): void
```
ts
```
ts
try
{
try
{
let
movement
:
inputMethodEngine
.
Movement
=
{
direction
:
1
};
let
movement
:
inputMethodEngine
.
Movement
=
{
direction
:
1
};
inputClient
.
selectByMovement
(
movement
,
(
err
:
Error
)
=>
{
inputClient
.
selectByMovement
(
movement
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to selectByMovement:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to selectByMovement:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2771,7 +2771,7 @@ try {
...
@@ -2771,7 +2771,7 @@ try {
let
movement
:
inputMethodEngine
.
Movement
=
{
direction
:
1
};
let
movement
:
inputMethodEngine
.
Movement
=
{
direction
:
1
};
inputClient
.
selectByMovement
(
movement
).
then
(()
=>
{
inputClient
.
selectByMovement
(
movement
).
then
(()
=>
{
console
.
log
(
'
Succeeded in selecting by movement.
'
);
console
.
log
(
'
Succeeded in selecting by movement.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to selectByMovement:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to selectByMovement:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -2840,7 +2840,7 @@ getTextIndexAtCursor(callback: AsyncCallback<number>): void
...
@@ -2840,7 +2840,7 @@ getTextIndexAtCursor(callback: AsyncCallback<number>): void
**示例:**
**示例:**
```
ts
```
ts
inputClient
.
getTextIndexAtCursor
((
err
:
Error
,
index
:
number
)
=>
{
inputClient
.
getTextIndexAtCursor
((
err
:
Business
Error
,
index
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to getTextIndexAtCursor:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getTextIndexAtCursor:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2877,7 +2877,7 @@ getTextIndexAtCursor(): Promise<number>
...
@@ -2877,7 +2877,7 @@ getTextIndexAtCursor(): Promise<number>
```
ts
```
ts
inputClient
.
getTextIndexAtCursor
().
then
((
index
:
number
)
=>
{
inputClient
.
getTextIndexAtCursor
().
then
((
index
:
number
)
=>
{
console
.
log
(
'
Succeeded in getTextIndexAtCursor:
'
+
index
);
console
.
log
(
'
Succeeded in getTextIndexAtCursor:
'
+
index
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to getTextIndexAtCursor:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getTextIndexAtCursor:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -2948,7 +2948,7 @@ sendExtendAction(action: ExtendAction, callback: AsyncCallback<void>): voi
...
@@ -2948,7 +2948,7 @@ sendExtendAction(action: ExtendAction, callback: AsyncCallback<void>): voi
```
ts
```
ts
try
{
try
{
inputClient
.
sendExtendAction
(
inputMethodEngine
.
ExtendAction
.
COPY
,
(
err
:
Error
)
=>
{
inputClient
.
sendExtendAction
(
inputMethodEngine
.
ExtendAction
.
COPY
,
(
err
:
Business
Error
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to sendExtendAction:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to sendExtendAction:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -2999,7 +2999,7 @@ sendExtendAction(action: ExtendAction): Promise<void>
...
@@ -2999,7 +2999,7 @@ sendExtendAction(action: ExtendAction): Promise<void>
try
{
try
{
inputClient
.
sendExtendAction
(
inputMethodEngine
.
ExtendAction
.
COPY
).
then
(()
=>
{
inputClient
.
sendExtendAction
(
inputMethodEngine
.
ExtendAction
.
COPY
).
then
(()
=>
{
console
.
log
(
'
Succeeded in sending extend action.
'
);
console
.
log
(
'
Succeeded in sending extend action.
'
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to sendExtendAction:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to sendExtendAction:
${
JSON
.
stringify
(
err
)}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -3093,7 +3093,7 @@ getForward(length:number, callback: AsyncCallback<string>): void
...
@@ -3093,7 +3093,7 @@ getForward(length:number, callback: AsyncCallback<string>): void
```
ts
```
ts
let
length
=
1
;
let
length
=
1
;
textInputClient
.
getForward
(
length
,
(
err
:
Error
,
text
:
string
)
=>
{
textInputClient
.
getForward
(
length
,
(
err
:
Business
Error
,
text
:
string
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -3132,7 +3132,7 @@ getForward(length:number): Promise<string>
...
@@ -3132,7 +3132,7 @@ getForward(length:number): Promise<string>
let
length
=
1
;
let
length
=
1
;
textInputClient
.
getForward
(
length
).
then
((
text
:
string
)
=>
{
textInputClient
.
getForward
(
length
).
then
((
text
:
string
)
=>
{
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
console
.
log
(
'
Succeeded in getting forward, text:
'
+
text
);
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getForward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -3160,7 +3160,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void
...
@@ -3160,7 +3160,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void
```
ts
```
ts
let
length
=
1
;
let
length
=
1
;
textInputClient
.
getBackward
(
length
,
(
err
:
Error
,
text
:
string
)
=>
{
textInputClient
.
getBackward
(
length
,
(
err
:
Business
Error
,
text
:
string
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -3199,7 +3199,7 @@ getBackward(length:number): Promise<string>
...
@@ -3199,7 +3199,7 @@ getBackward(length:number): Promise<string>
let
length
=
1
;
let
length
=
1
;
textInputClient
.
getBackward
(
length
).
then
((
text
:
string
)
=>
{
textInputClient
.
getBackward
(
length
).
then
((
text
:
string
)
=>
{
console
.
log
(
'
Succeeded in getting backward:
'
+
JSON
.
stringify
(
text
));
console
.
log
(
'
Succeeded in getting backward:
'
+
JSON
.
stringify
(
text
));
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getBackward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -3227,7 +3227,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
...
@@ -3227,7 +3227,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
```
ts
```
ts
let
length
=
1
;
let
length
=
1
;
textInputClient
.
deleteForward
(
length
,
(
err
:
Error
,
result
:
boolean
)
=>
{
textInputClient
.
deleteForward
(
length
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -3274,7 +3274,7 @@ textInputClient.deleteForward(length).then((result: boolean) => {
...
@@ -3274,7 +3274,7 @@ textInputClient.deleteForward(length).then((result: boolean) => {
}
else
{
}
else
{
console
.
error
(
'
Failed to delete forward.
'
);
console
.
error
(
'
Failed to delete forward.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to deleteForward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -3302,7 +3302,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
...
@@ -3302,7 +3302,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
```
ts
```
ts
let
length
=
1
;
let
length
=
1
;
textInputClient
.
deleteBackward
(
length
,
(
err
:
Error
,
result
:
boolean
)
=>
{
textInputClient
.
deleteBackward
(
length
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -3349,7 +3349,7 @@ textInputClient.deleteBackward(length).then((result: boolean) => {
...
@@ -3349,7 +3349,7 @@ textInputClient.deleteBackward(length).then((result: boolean) => {
}
else
{
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to deleteBackward:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -3376,7 +3376,7 @@ sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void
...
@@ -3376,7 +3376,7 @@ sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void
```
ts
```
ts
let
action
=
1
;
let
action
=
1
;
textInputClient
.
sendKeyFunction
(
action
,
(
err
:
Error
,
result
:
boolean
)
=>
{
textInputClient
.
sendKeyFunction
(
action
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -3423,7 +3423,7 @@ textInputClient.sendKeyFunction(action).then((result: boolean) => {
...
@@ -3423,7 +3423,7 @@ textInputClient.sendKeyFunction(action).then((result: boolean) => {
}
else
{
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to sendKeyFunction:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -3450,7 +3450,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
...
@@ -3450,7 +3450,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
ts
```
ts
textInputClient
.
insertText
(
'
test
'
,
(
err
:
Error
,
result
:
boolean
)
=>
{
textInputClient
.
insertText
(
'
test
'
,
(
err
:
Business
Error
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -3496,7 +3496,7 @@ textInputClient.insertText('test').then((result: boolean) => {
...
@@ -3496,7 +3496,7 @@ textInputClient.insertText('test').then((result: boolean) => {
}
else
{
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
console
.
error
(
'
Failed to insertText.
'
);
}
}
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to insertText:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
@@ -3522,7 +3522,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
...
@@ -3522,7 +3522,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
**示例:**
**示例:**
```
ts
```
ts
textInputClient
.
getEditorAttribute
((
err
:
Error
,
editorAttribute
:
inputMethodEngine
.
EditorAttribute
)
=>
{
textInputClient
.
getEditorAttribute
((
err
:
Business
Error
,
editorAttribute
:
inputMethodEngine
.
EditorAttribute
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
return
;
return
;
...
@@ -3556,7 +3556,7 @@ getEditorAttribute(): Promise<EditorAttribute>
...
@@ -3556,7 +3556,7 @@ getEditorAttribute(): Promise<EditorAttribute>
textInputClient
.
getEditorAttribute
().
then
((
editorAttribute
:
inputMethodEngine
.
EditorAttribute
)
=>
{
textInputClient
.
getEditorAttribute
().
then
((
editorAttribute
:
inputMethodEngine
.
EditorAttribute
)
=>
{
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
log
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
console
.
log
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
}).
catch
((
err
:
Error
)
=>
{
}).
catch
((
err
:
Business
Error
)
=>
{
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
console
.
error
(
`Failed to getEditorAttribute:
${
JSON
.
stringify
(
err
)}
`
);
});
});
```
```
...
...
zh-cn/application-dev/reference/apis/js-apis-request.md
浏览文件 @
e67918ce
...
@@ -103,10 +103,9 @@ uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask>
...
@@ -103,10 +103,9 @@ uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask>
**示例:**
**示例:**
```
js
```
ts
let
uploadTask
;
let
uploadTask
:
request
.
UploadTask
;
let
context
;
let
uploadConfig
:
request
.
UploadConfig
=
{
let
uploadConfig
=
{
url
:
'
http://patch
'
,
url
:
'
http://patch
'
,
header
:
{
key1
:
"
value1
"
,
key2
:
"
value2
"
},
header
:
{
key1
:
"
value1
"
,
key2
:
"
value2
"
},
method
:
"
POST
"
,
method
:
"
POST
"
,
...
@@ -114,13 +113,13 @@ uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask>
...
@@ -114,13 +113,13 @@ uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask>
data
:
[{
name
:
"
name123
"
,
value
:
"
123
"
}],
data
:
[{
name
:
"
name123
"
,
value
:
"
123
"
}],
};
};
try
{
try
{
request
.
uploadFile
(
context
,
uploadConfig
).
then
((
data
)
=>
{
request
.
uploadFile
(
this
.
context
,
uploadConfig
).
then
((
data
:
request
.
UploadTask
)
=>
{
uploadTask
=
data
;
uploadTask
=
data
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to request the upload. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to request the upload. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
`Failed to request the upload.
Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to request the upload.
err:
${
JSON
.
stringify
(
err
)
}
`
);
}
}
```
```
...
@@ -157,10 +156,9 @@ uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback&l
...
@@ -157,10 +156,9 @@ uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback&l
**示例:**
**示例:**
```
js
```
ts
let
uploadTask
;
let
uploadTask
:
request
.
UploadTask
;
let
context
;
let
uploadConfig
:
request
.
UploadConfig
=
{
let
uploadConfig
=
{
url
:
'
http://patch
'
,
url
:
'
http://patch
'
,
header
:
{
key1
:
"
value1
"
,
key2
:
"
value2
"
},
header
:
{
key1
:
"
value1
"
,
key2
:
"
value2
"
},
method
:
"
POST
"
,
method
:
"
POST
"
,
...
@@ -168,7 +166,7 @@ uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback&l
...
@@ -168,7 +166,7 @@ uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback&l
data
:
[{
name
:
"
name123
"
,
value
:
"
123
"
}],
data
:
[{
name
:
"
name123
"
,
value
:
"
123
"
}],
};
};
try
{
try
{
request
.
uploadFile
(
context
,
uploadConfig
,
(
err
,
data
)
=>
{
request
.
uploadFile
(
this
.
context
,
uploadConfig
,
(
err
:
BusinessError
,
data
:
request
.
UploadTask
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to request the upload. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to request the upload. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -176,7 +174,7 @@ uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback&l
...
@@ -176,7 +174,7 @@ uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback&l
uploadTask
=
data
;
uploadTask
=
data
;
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
`Failed to request the upload.
Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to request the upload.
err:
${
JSON
.
stringify
(
err
)
}
`
);
}
}
```
```
...
@@ -306,8 +304,8 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => vo
...
@@ -306,8 +304,8 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => vo
**示例:**
**示例:**
```
j
s
```
t
s
let
upProgressCallback
=
(
uploadedSize
,
totalSize
)
=>
{
let
upProgressCallback
=
(
uploadedSize
:
number
,
totalSize
:
number
)
=>
{
console
.
info
(
"
upload totalSize:
"
+
totalSize
+
"
uploadedSize:
"
+
uploadedSize
);
console
.
info
(
"
upload totalSize:
"
+
totalSize
+
"
uploadedSize:
"
+
uploadedSize
);
};
};
uploadTask
.
on
(
'
progress
'
,
upProgressCallback
);
uploadTask
.
on
(
'
progress
'
,
upProgressCallback
);
...
@@ -339,8 +337,8 @@ on(type: 'headerReceive', callback: (header: object) => void): void
...
@@ -339,8 +337,8 @@ on(type: 'headerReceive', callback: (header: object) => void): void
**示例:**
**示例:**
```
j
s
```
t
s
let
headerCallback
=
(
headers
)
=>
{
let
headerCallback
=
(
headers
:
object
)
=>
{
console
.
info
(
"
upOnHeader headers:
"
+
JSON
.
stringify
(
headers
));
console
.
info
(
"
upOnHeader headers:
"
+
JSON
.
stringify
(
headers
));
};
};
uploadTask
.
on
(
'
headerReceive
'
,
headerCallback
);
uploadTask
.
on
(
'
headerReceive
'
,
headerCallback
);
...
@@ -372,16 +370,16 @@ on(type: 'headerReceive', callback: (header: object) => void): void
...
@@ -372,16 +370,16 @@ on(type: 'headerReceive', callback: (header: object) => void): void
**示例:**
**示例:**
```
j
s
```
t
s
let
upCompleteCallback
=
(
taskStates
)
=>
{
let
upCompleteCallback
=
(
taskStates
:
Array
<
request
.
TaskState
>
)
=>
{
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
console
.
info
(
"
upOnComplete taskState:
"
+
JSON
.
stringify
(
taskStates
[
i
]));
console
.
info
(
"
upOnComplete taskState:
"
+
JSON
.
stringify
(
taskStates
[
i
]));
}
}
};
};
uploadTask
.
on
(
'
complete
'
,
upCompleteCallback
);
uploadTask
.
on
(
'
complete
'
,
upCompleteCallback
);
let
upFailCallback
=
(
taskStates
)
=>
{
let
upFailCallback
=
(
taskStates
:
Array
<
request
.
TaskState
>
)
=>
{
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
console
.
info
(
"
upOnFail taskState:
"
+
JSON
.
stringify
(
taskStates
[
i
]));
console
.
info
(
"
upOnFail taskState:
"
+
JSON
.
stringify
(
taskStates
[
i
]));
}
}
};
};
...
@@ -408,8 +406,8 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g
...
@@ -408,8 +406,8 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g
**示例:**
**示例:**
```
j
s
```
t
s
let
upProgressCallback
=
(
uploadedSize
,
totalSize
)
=>
{
let
upProgressCallback
=
(
uploadedSize
:
number
,
totalSize
:
number
)
=>
{
console
.
info
(
'
Upload delete progress notification.
'
+
'
totalSize:
'
+
totalSize
+
'
uploadedSize:
'
+
uploadedSize
);
console
.
info
(
'
Upload delete progress notification.
'
+
'
totalSize:
'
+
totalSize
+
'
uploadedSize:
'
+
uploadedSize
);
};
};
uploadTask
.
off
(
'
progress
'
,
upProgressCallback
);
uploadTask
.
off
(
'
progress
'
,
upProgressCallback
);
...
@@ -435,8 +433,8 @@ off(type: 'headerReceive', callback?: (header: object) => void): void
...
@@ -435,8 +433,8 @@ off(type: 'headerReceive', callback?: (header: object) => void): void
**示例:**
**示例:**
```
j
s
```
t
s
let
headerCallback
=
(
header
)
=>
{
let
headerCallback
=
(
header
:
object
)
=>
{
console
.
info
(
`Upload delete headerReceive notification. header:
${
JSON
.
stringify
(
header
)}
`
);
console
.
info
(
`Upload delete headerReceive notification. header:
${
JSON
.
stringify
(
header
)}
`
);
};
};
uploadTask
.
off
(
'
headerReceive
'
,
headerCallback
);
uploadTask
.
off
(
'
headerReceive
'
,
headerCallback
);
...
@@ -461,18 +459,18 @@ off(type: 'headerReceive', callback?: (header: object) => void): void
...
@@ -461,18 +459,18 @@ off(type: 'headerReceive', callback?: (header: object) => void): void
**示例:**
**示例:**
```
j
s
```
t
s
let
upCompleteCallback
=
(
taskStates
)
=>
{
let
upCompleteCallback
=
(
taskStates
:
Array
<
request
.
TaskState
>
)
=>
{
console
.
info
(
'
Upload delete complete notification.
'
);
console
.
info
(
'
Upload delete complete notification.
'
);
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
console
.
info
(
'
taskState:
'
+
JSON
.
stringify
(
taskStates
[
i
]));
console
.
info
(
'
taskState:
'
+
JSON
.
stringify
(
taskStates
[
i
]));
}
}
};
};
uploadTask
.
off
(
'
complete
'
,
upCompleteCallback
);
uploadTask
.
off
(
'
complete
'
,
upCompleteCallback
);
let
upFailCallback
=
(
taskStates
)
=>
{
let
upFailCallback
=
(
taskStates
:
Array
<
request
.
TaskState
>
)
=>
{
console
.
info
(
'
Upload delete fail notification.
'
);
console
.
info
(
'
Upload delete fail notification.
'
);
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
taskStates
.
length
;
i
++
)
{
console
.
info
(
'
taskState:
'
+
JSON
.
stringify
(
taskStates
[
i
]));
console
.
info
(
'
taskState:
'
+
JSON
.
stringify
(
taskStates
[
i
]));
}
}
};
};
...
@@ -496,10 +494,10 @@ delete(): Promise<boolean>
...
@@ -496,10 +494,10 @@ delete(): Promise<boolean>
**示例:**
**示例:**
```
j
s
```
t
s
uploadTask
.
delete
().
then
((
result
)
=>
{
uploadTask
.
delete
().
then
((
result
:
boolean
)
=>
{
console
.
info
(
'
Succeeded in deleting the upload task.
'
);
console
.
info
(
'
Succeeded in deleting the upload task.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to delete the upload task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to delete the upload task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -523,8 +521,8 @@ delete(callback: AsyncCallback<boolean>): void
...
@@ -523,8 +521,8 @@ delete(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
j
s
```
t
s
uploadTask
.
delete
((
err
,
result
)
=>
{
uploadTask
.
delete
((
err
:
BusinessError
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to delete the upload task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to delete the upload task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -688,17 +686,16 @@ downloadFile(context: BaseContext, config: DownloadConfig): Promise<DownloadT
...
@@ -688,17 +686,16 @@ downloadFile(context: BaseContext, config: DownloadConfig): Promise<DownloadT
**示例:**
**示例:**
```
js
```
ts
let
downloadTask
;
let
downloadTask
:
request
.
DownloadTask
;
let
context
;
try
{
try
{
request
.
downloadFile
(
context
,
{
url
:
'
https://xxxx/xxxx.hap
'
}).
then
((
data
)
=>
{
request
.
downloadFile
(
this
.
context
,
{
url
:
'
https://xxxx/xxxx.hap
'
}).
then
((
data
:
request
.
DownloadTask
)
=>
{
downloadTask
=
data
;
downloadTask
=
data
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to request the download. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to request the download. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
`Failed to request the download.
Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to request the download.
err:
${
JSON
.
stringify
(
err
)
}
`
);
}
}
```
```
...
@@ -738,12 +735,13 @@ downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallba
...
@@ -738,12 +735,13 @@ downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallba
**示例:**
**示例:**
```
js
```
ts
let
downloadTask
;
let
downloadTask
:
request
.
DownloadTask
;
let
context
;
try
{
try
{
request
.
downloadFile
(
context
,
{
url
:
'
https://xxxx/xxxxx.hap
'
,
request
.
downloadFile
(
this
.
context
,
{
filePath
:
'
xxx/xxxxx.hap
'
},
(
err
,
data
)
=>
{
url
:
'
https://xxxx/xxxxx.hap
'
,
filePath
:
'
xxx/xxxxx.hap
'
},
(
err
:
BusinessError
,
data
:
request
.
DownloadTask
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to request the download. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to request the download. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -751,7 +749,7 @@ downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallba
...
@@ -751,7 +749,7 @@ downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallba
downloadTask
=
data
;
downloadTask
=
data
;
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
`Failed to request the download.
Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to request the download.
err:
${
JSON
.
stringify
(
err
)
}
`
);
}
}
```
```
...
@@ -867,8 +865,8 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo
...
@@ -867,8 +865,8 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo
**示例:**
**示例:**
```
j
s
```
t
s
let
progresCallback
=
(
receivedSize
,
totalSize
)
=>
{
let
progresCallback
=
(
receivedSize
:
number
,
totalSize
:
number
)
=>
{
console
.
info
(
"
download receivedSize:
"
+
receivedSize
+
"
totalSize:
"
+
totalSize
);
console
.
info
(
"
download receivedSize:
"
+
receivedSize
+
"
totalSize:
"
+
totalSize
);
};
};
downloadTask
.
on
(
'
progress
'
,
progresCallback
);
downloadTask
.
on
(
'
progress
'
,
progresCallback
);
...
@@ -894,8 +892,8 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =>
...
@@ -894,8 +892,8 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =>
**示例:**
**示例:**
```
j
s
```
t
s
let
progresCallback
=
(
receivedSize
,
totalSize
)
=>
{
let
progresCallback
=
(
receivedSize
:
number
,
totalSize
:
number
)
=>
{
console
.
info
(
'
Download delete progress notification.
'
+
'
receivedSize:
'
+
receivedSize
+
'
totalSize:
'
+
totalSize
);
console
.
info
(
'
Download delete progress notification.
'
+
'
receivedSize:
'
+
receivedSize
+
'
totalSize:
'
+
totalSize
);
};
};
downloadTask
.
off
(
'
progress
'
,
progresCallback
);
downloadTask
.
off
(
'
progress
'
,
progresCallback
);
...
@@ -921,7 +919,7 @@ on(type: 'complete'|'pause'|'remove', callback:() => void): void
...
@@ -921,7 +919,7 @@ on(type: 'complete'|'pause'|'remove', callback:() => void): void
**示例:**
**示例:**
```
j
s
```
t
s
let
completeCallback
=
()
=>
{
let
completeCallback
=
()
=>
{
console
.
info
(
'
Download task completed.
'
);
console
.
info
(
'
Download task completed.
'
);
};
};
...
@@ -958,7 +956,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() => void): void
...
@@ -958,7 +956,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() => void): void
**示例:**
**示例:**
```
j
s
```
t
s
let
completeCallback
=
()
=>
{
let
completeCallback
=
()
=>
{
console
.
info
(
'
Download delete complete notification.
'
);
console
.
info
(
'
Download delete complete notification.
'
);
};
};
...
@@ -1001,8 +999,8 @@ on(type: 'fail', callback: (err: number) => void): void
...
@@ -1001,8 +999,8 @@ on(type: 'fail', callback: (err: number) => void): void
**示例:**
**示例:**
```
j
s
```
t
s
let
failCallback
=
(
err
)
=>
{
let
failCallback
=
(
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to download the task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to download the task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
};
};
downloadTask
.
on
(
'
fail
'
,
failCallback
);
downloadTask
.
on
(
'
fail
'
,
failCallback
);
...
@@ -1028,8 +1026,8 @@ off(type: 'fail', callback?: (err: number) => void): void
...
@@ -1028,8 +1026,8 @@ off(type: 'fail', callback?: (err: number) => void): void
**示例:**
**示例:**
```
j
s
```
t
s
let
failCallback
=
(
err
)
=>
{
let
failCallback
=
(
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to download the task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to download the task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
};
};
downloadTask
.
off
(
'
fail
'
,
failCallback
);
downloadTask
.
off
(
'
fail
'
,
failCallback
);
...
@@ -1053,10 +1051,10 @@ delete(): Promise<boolean>
...
@@ -1053,10 +1051,10 @@ delete(): Promise<boolean>
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
delete
().
then
((
result
)
=>
{
downloadTask
.
delete
().
then
((
result
:
boolean
)
=>
{
console
.
info
(
'
Succeeded in removing the download task.
'
);
console
.
info
(
'
Succeeded in removing the download task.
'
);
}).
catch
((
er
r
)
=>
{
}).
catch
((
err
:
BusinessErro
r
)
=>
{
console
.
error
(
`Failed to remove the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to remove the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -1080,12 +1078,12 @@ delete(callback: AsyncCallback<boolean>): void
...
@@ -1080,12 +1078,12 @@ delete(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
delete
((
err
,
result
)
=>
{
downloadTask
.
delete
((
err
:
BusinessError
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to remove the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to remove the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in removing the download task.
'
);
console
.
info
(
'
Succeeded in removing the download task.
'
);
});
});
```
```
...
@@ -1109,10 +1107,10 @@ getTaskInfo(): Promise<DownloadInfo>
...
@@ -1109,10 +1107,10 @@ getTaskInfo(): Promise<DownloadInfo>
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
getTaskInfo
().
then
((
downloadInfo
)
=>
{
downloadTask
.
getTaskInfo
().
then
((
downloadInfo
:
request
.
DownloadInfo
)
=>
{
console
.
info
(
'
Succeeded in querying the download task
'
)
console
.
info
(
'
Succeeded in querying the download task
'
)
})
.
catch
((
er
r
)
=>
{
})
.
catch
((
err
:
BusinessErro
r
)
=>
{
console
.
error
(
`Failed to query the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
)
console
.
error
(
`Failed to query the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
)
});
});
```
```
...
@@ -1136,9 +1134,9 @@ getTaskInfo(callback: AsyncCallback<DownloadInfo>): void
...
@@ -1136,9 +1134,9 @@ getTaskInfo(callback: AsyncCallback<DownloadInfo>): void
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
getTaskInfo
((
err
,
downloadInfo
)
=>
{
downloadTask
.
getTaskInfo
((
err
:
BusinessError
,
downloadInfo
:
request
.
DownloadInfo
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to query the download mimeType. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to query the download mimeType. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
'
Succeeded in querying the download mimeType
'
);
console
.
info
(
'
Succeeded in querying the download mimeType
'
);
...
@@ -1165,10 +1163,10 @@ getTaskMimeType(): Promise<string>
...
@@ -1165,10 +1163,10 @@ getTaskMimeType(): Promise<string>
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
getTaskMimeType
().
then
((
data
)
=>
{
downloadTask
.
getTaskMimeType
().
then
((
data
:
string
)
=>
{
console
.
info
(
'
Succeeded in querying the download MimeType
'
);
console
.
info
(
'
Succeeded in querying the download MimeType
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to query the download MimeType. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
)
console
.
error
(
`Failed to query the download MimeType. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
)
});
});
```
```
...
@@ -1192,9 +1190,9 @@ getTaskMimeType(callback: AsyncCallback<string>): void;
...
@@ -1192,9 +1190,9 @@ getTaskMimeType(callback: AsyncCallback<string>): void;
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
getTaskMimeType
((
err
,
data
)
=>
{
downloadTask
.
getTaskMimeType
((
err
:
BusinessError
,
data
:
string
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to query the download mimeType. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to query the download mimeType. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
}
else
{
console
.
info
(
'
Succeeded in querying the download mimeType
'
);
console
.
info
(
'
Succeeded in querying the download mimeType
'
);
...
@@ -1221,10 +1219,10 @@ suspend(): Promise<boolean>
...
@@ -1221,10 +1219,10 @@ suspend(): Promise<boolean>
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
suspend
().
then
((
result
)
=>
{
downloadTask
.
suspend
().
then
((
result
:
boolean
)
=>
{
console
.
info
(
'
Succeeded in pausing the download task.
'
);
console
.
info
(
'
Succeeded in pausing the download task.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to pause the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to pause the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -1248,9 +1246,9 @@ suspend(callback: AsyncCallback<boolean>): void
...
@@ -1248,9 +1246,9 @@ suspend(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
suspend
((
err
,
result
)
=>
{
downloadTask
.
suspend
((
err
:
BusinessError
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to pause the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to pause the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
}
}
...
@@ -1277,10 +1275,10 @@ restore(): Promise<boolean>
...
@@ -1277,10 +1275,10 @@ restore(): Promise<boolean>
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
restore
().
then
((
result
)
=>
{
downloadTask
.
restore
().
then
((
result
:
boolean
)
=>
{
console
.
info
(
'
Succeeded in resuming the download task.
'
)
console
.
info
(
'
Succeeded in resuming the download task.
'
)
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to resume the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to resume the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -1304,12 +1302,12 @@ restore(callback: AsyncCallback<boolean>): void
...
@@ -1304,12 +1302,12 @@ restore(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
j
s
```
t
s
downloadTask
.
restore
((
err
,
result
)
=>
{
downloadTask
.
restore
((
err
:
BusinessError
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to resume the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to resume the download task. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
}
}
console
.
info
(
'
Succeeded in resuming the download task.
'
);
console
.
info
(
'
Succeeded in resuming the download task.
'
);
});
});
```
```
...
@@ -1874,17 +1872,16 @@ on(event: 'progress', callback: (progress: Progress) => void): void
...
@@ -1874,17 +1872,16 @@ on(event: 'progress', callback: (progress: Progress) => void): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
attachments
:
Array
<
request
.
agent
.
FormItem
>
=
[{
let
attachments
=
[{
name
:
"
taskOnTest
"
,
name
:
"
taskOnTest
"
,
value
:
{
value
:
{
filename
:
"
taskOnTest.avi
"
,
filename
:
"
taskOnTest.avi
"
,
mimeType
:
"
application/octet-stream
"
,
mimetype
:
"
application/octet-stream
"
,
path
:
"
./taskOnTest.avi
"
,
path
:
"
./taskOnTest.avi
"
,
}
}
}];
}];
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskOnTest
'
,
title
:
'
taskOnTest
'
,
...
@@ -1906,13 +1903,13 @@ on(event: 'progress', callback: (progress: Progress) => void): void
...
@@ -1906,13 +1903,13 @@ on(event: 'progress', callback: (progress: Progress) => void): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
let
createOnCallback
=
(
progress
)
=>
{
let
createOnCallback
=
(
progress
:
request
.
agent
.
Progress
)
=>
{
console
.
info
(
'
upload task
completed
.
'
);
console
.
info
(
'
upload task
progress
.
'
);
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
task
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
Task
)
=>
{
task
.
on
(
'
progress
'
,
createOnCallback
);
task
.
on
(
'
progress
'
,
createOnCallback
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -1946,17 +1943,16 @@ on(event: 'completed', callback: (progress: Progress) => void): void
...
@@ -1946,17 +1943,16 @@ on(event: 'completed', callback: (progress: Progress) => void): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
attachments
:
Array
<
request
.
agent
.
FormItem
>
=
[{
let
attachments
=
[{
name
:
"
taskOnTest
"
,
name
:
"
taskOnTest
"
,
value
:
{
value
:
{
filename
:
"
taskOnTest.avi
"
,
filename
:
"
taskOnTest.avi
"
,
mimeType
:
"
application/octet-stream
"
,
mimetype
:
"
application/octet-stream
"
,
path
:
"
./taskOnTest.avi
"
,
path
:
"
./taskOnTest.avi
"
,
}
}
}];
}];
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskOnTest
'
,
title
:
'
taskOnTest
'
,
...
@@ -1978,13 +1974,13 @@ on(event: 'completed', callback: (progress: Progress) => void): void
...
@@ -1978,13 +1974,13 @@ on(event: 'completed', callback: (progress: Progress) => void): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
let
createOnCallback
=
(
progress
)
=>
{
let
createOnCallback
=
(
progress
:
request
.
agent
.
Progress
)
=>
{
console
.
info
(
'
upload task completed.
'
);
console
.
info
(
'
upload task completed.
'
);
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
task
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
Task
)
=>
{
task
.
on
(
'
completed
'
,
createOnCallback
);
task
.
on
(
'
completed
'
,
createOnCallback
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2018,17 +2014,16 @@ on(event: 'failed', callback: (progress: Progress) => void): void
...
@@ -2018,17 +2014,16 @@ on(event: 'failed', callback: (progress: Progress) => void): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
attachments
:
Array
<
request
.
agent
.
FormItem
>
=
[{
let
attachments
=
[{
name
:
"
taskOnTest
"
,
name
:
"
taskOnTest
"
,
value
:
{
value
:
{
filename
:
"
taskOnTest.avi
"
,
filename
:
"
taskOnTest.avi
"
,
mimeType
:
"
application/octet-stream
"
,
mimetype
:
"
application/octet-stream
"
,
path
:
"
./taskOnTest.avi
"
,
path
:
"
./taskOnTest.avi
"
,
}
}
}];
}];
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskOnTest
'
,
title
:
'
taskOnTest
'
,
...
@@ -2050,13 +2045,13 @@ on(event: 'failed', callback: (progress: Progress) => void): void
...
@@ -2050,13 +2045,13 @@ on(event: 'failed', callback: (progress: Progress) => void): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
let
createOnCallback
=
(
progress
)
=>
{
let
createOnCallback
=
(
progress
:
request
.
agent
.
Progress
)
=>
{
console
.
info
(
'
upload task
complet
ed.
'
);
console
.
info
(
'
upload task
fail
ed.
'
);
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
task
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
Task
)
=>
{
task
.
on
(
'
failed
'
,
createOnCallback
);
task
.
on
(
'
failed
'
,
createOnCallback
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2091,17 +2086,16 @@ off(event: 'progress', callback?: (progress: Progress) => void): void
...
@@ -2091,17 +2086,16 @@ off(event: 'progress', callback?: (progress: Progress) => void): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
attachments
:
Array
<
request
.
agent
.
FormItem
>
=
[{
let
attachments
=
[{
name
:
"
taskOffTest
"
,
name
:
"
taskOffTest
"
,
value
:
{
value
:
{
filename
:
"
taskOffTest.avi
"
,
filename
:
"
taskOffTest.avi
"
,
mimeType
:
"
application/octet-stream
"
,
mimetype
:
"
application/octet-stream
"
,
path
:
"
./taskOffTest.avi
"
,
path
:
"
./taskOffTest.avi
"
,
}
}
}];
}];
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskOffTest
'
,
title
:
'
taskOffTest
'
,
...
@@ -2123,14 +2117,14 @@ off(event: 'progress', callback?: (progress: Progress) => void): void
...
@@ -2123,14 +2117,14 @@ off(event: 'progress', callback?: (progress: Progress) => void): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
let
createOffCallback
=
(
progress
)
=>
{
let
createOffCallback
=
(
progress
:
request
.
agent
.
Progress
)
=>
{
console
.
info
(
'
upload task
completed
.
'
);
console
.
info
(
'
upload task
progress
.
'
);
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
task
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
Task
)
=>
{
task
.
on
(
'
progress
'
,
createOffCallback
);
task
.
on
(
'
progress
'
,
createOffCallback
);
task
.
off
(
'
progress
'
,
createOffCallback
);
task
.
off
(
'
progress
'
,
createOffCallback
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2164,17 +2158,16 @@ off(event: 'completed', callback?: (progress: Progress) => void): void
...
@@ -2164,17 +2158,16 @@ off(event: 'completed', callback?: (progress: Progress) => void): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
attachments
:
Array
<
request
.
agent
.
FormItem
>
=
[{
let
attachments
=
[{
name
:
"
taskOffTest
"
,
name
:
"
taskOffTest
"
,
value
:
{
value
:
{
filename
:
"
taskOffTest.avi
"
,
filename
:
"
taskOffTest.avi
"
,
mimeType
:
"
application/octet-stream
"
,
mimetype
:
"
application/octet-stream
"
,
path
:
"
./taskOffTest.avi
"
,
path
:
"
./taskOffTest.avi
"
,
}
}
}];
}];
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskOffTest
'
,
title
:
'
taskOffTest
'
,
...
@@ -2196,14 +2189,14 @@ off(event: 'completed', callback?: (progress: Progress) => void): void
...
@@ -2196,14 +2189,14 @@ off(event: 'completed', callback?: (progress: Progress) => void): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
let
createOffCallback
=
(
progress
)
=>
{
let
createOffCallback
=
(
progress
:
request
.
agent
.
Progress
)
=>
{
console
.
info
(
'
upload task completed.
'
);
console
.
info
(
'
upload task completed.
'
);
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
task
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
Task
)
=>
{
task
.
on
(
'
completed
'
,
createOffCallback
);
task
.
on
(
'
completed
'
,
createOffCallback
);
task
.
off
(
'
completed
'
,
createOffCallback
);
task
.
off
(
'
completed
'
,
createOffCallback
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2237,17 +2230,16 @@ off(event: 'failed', callback?: (progress: Progress) => void): void
...
@@ -2237,17 +2230,16 @@ off(event: 'failed', callback?: (progress: Progress) => void): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
attachments
:
Array
<
request
.
agent
.
FormItem
>
=
[{
let
attachments
=
[{
name
:
"
taskOffTest
"
,
name
:
"
taskOffTest
"
,
value
:
{
value
:
{
filename
:
"
taskOffTest.avi
"
,
filename
:
"
taskOffTest.avi
"
,
mimeType
:
"
application/octet-stream
"
,
mimetype
:
"
application/octet-stream
"
,
path
:
"
./taskOffTest.avi
"
,
path
:
"
./taskOffTest.avi
"
,
}
}
}];
}];
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskOffTest
'
,
title
:
'
taskOffTest
'
,
...
@@ -2269,14 +2261,14 @@ off(event: 'failed', callback?: (progress: Progress) => void): void
...
@@ -2269,14 +2261,14 @@ off(event: 'failed', callback?: (progress: Progress) => void): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
let
createOffCallback
=
(
progress
)
=>
{
let
createOffCallback
=
(
progress
:
request
.
agent
.
Progress
)
=>
{
console
.
info
(
'
upload task
complet
ed.
'
);
console
.
info
(
'
upload task
fail
ed.
'
);
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
task
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
Task
)
=>
{
task
.
on
(
'
failed
'
,
createOffCallback
);
task
.
on
(
'
failed
'
,
createOffCallback
);
task
.
off
(
'
failed
'
,
createOffCallback
);
task
.
off
(
'
failed
'
,
createOffCallback
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a upload task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2312,9 +2304,8 @@ start(callback: AsyncCallback<void>): void
...
@@ -2312,9 +2304,8 @@ start(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskStartTest
'
,
title
:
'
taskStartTest
'
,
...
@@ -2336,8 +2327,8 @@ start(callback: AsyncCallback<void>): void
...
@@ -2336,8 +2327,8 @@ start(callback: AsyncCallback<void>): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
t
ask
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
T
ask
)
=>
{
task
.
start
((
err
)
=>
{
task
.
start
((
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to start the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to start the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -2345,7 +2336,7 @@ start(callback: AsyncCallback<void>): void
...
@@ -2345,7 +2336,7 @@ start(callback: AsyncCallback<void>): void
console
.
info
(
`Succeeded in starting a download task.`
);
console
.
info
(
`Succeeded in starting a download task.`
);
});
});
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2381,9 +2372,8 @@ start(): Promise<void>
...
@@ -2381,9 +2372,8 @@ start(): Promise<void>
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskStartTest
'
,
title
:
'
taskStartTest
'
,
...
@@ -2405,14 +2395,14 @@ start(): Promise<void>
...
@@ -2405,14 +2395,14 @@ start(): Promise<void>
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
t
ask
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
T
ask
)
=>
{
task
.
start
().
then
(()
=>
{
task
.
start
().
then
(()
=>
{
console
.
info
(
`Succeeded in starting a download task.`
);
console
.
info
(
`Succeeded in starting a download task.`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to start the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to start the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2447,9 +2437,8 @@ pause(callback: AsyncCallback<void>): void
...
@@ -2447,9 +2437,8 @@ pause(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskPauseTest
'
,
title
:
'
taskPauseTest
'
,
...
@@ -2471,8 +2460,8 @@ pause(callback: AsyncCallback<void>): void
...
@@ -2471,8 +2460,8 @@ pause(callback: AsyncCallback<void>): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
t
ask
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
T
ask
)
=>
{
task
.
pause
((
err
)
=>
{
task
.
pause
((
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to pause the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to pause the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -2480,7 +2469,7 @@ pause(callback: AsyncCallback<void>): void
...
@@ -2480,7 +2469,7 @@ pause(callback: AsyncCallback<void>): void
console
.
info
(
`Succeeded in pausing a download task. `
);
console
.
info
(
`Succeeded in pausing a download task. `
);
});
});
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2512,9 +2501,8 @@ pause(): Promise<void>
...
@@ -2512,9 +2501,8 @@ pause(): Promise<void>
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskPauseTest
'
,
title
:
'
taskPauseTest
'
,
...
@@ -2536,14 +2524,14 @@ pause(): Promise<void>
...
@@ -2536,14 +2524,14 @@ pause(): Promise<void>
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
t
ask
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
T
ask
)
=>
{
task
.
pause
().
then
(()
=>
{
task
.
pause
().
then
(()
=>
{
console
.
info
(
`Succeeded in pausing a download task. `
);
console
.
info
(
`Succeeded in pausing a download task. `
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to pause the upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to pause the upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a upload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2577,9 +2565,8 @@ resume(callback: AsyncCallback<void>): void
...
@@ -2577,9 +2565,8 @@ resume(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskResumeTest
'
,
title
:
'
taskResumeTest
'
,
...
@@ -2601,8 +2588,8 @@ resume(callback: AsyncCallback<void>): void
...
@@ -2601,8 +2588,8 @@ resume(callback: AsyncCallback<void>): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
t
ask
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
T
ask
)
=>
{
task
.
resume
((
err
)
=>
{
task
.
resume
((
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to resume the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to resume the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -2610,7 +2597,7 @@ resume(callback: AsyncCallback<void>): void
...
@@ -2610,7 +2597,7 @@ resume(callback: AsyncCallback<void>): void
console
.
info
(
`Succeeded in resuming a download task. `
);
console
.
info
(
`Succeeded in resuming a download task. `
);
});
});
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2644,9 +2631,8 @@ resume(): Promise<void>
...
@@ -2644,9 +2631,8 @@ resume(): Promise<void>
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskResumeTest
'
,
title
:
'
taskResumeTest
'
,
...
@@ -2668,14 +2654,14 @@ resume(): Promise<void>
...
@@ -2668,14 +2654,14 @@ resume(): Promise<void>
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
t
ask
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
T
ask
)
=>
{
task
.
resume
().
then
(()
=>
{
task
.
resume
().
then
(()
=>
{
console
.
info
(
`Succeeded in resuming a download task. `
);
console
.
info
(
`Succeeded in resuming a download task. `
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to resume the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to resume the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2706,9 +2692,8 @@ stop(callback: AsyncCallback<void>): void
...
@@ -2706,9 +2692,8 @@ stop(callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskStopTest
'
,
title
:
'
taskStopTest
'
,
...
@@ -2730,8 +2715,8 @@ stop(callback: AsyncCallback<void>): void
...
@@ -2730,8 +2715,8 @@ stop(callback: AsyncCallback<void>): void
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
t
ask
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
T
ask
)
=>
{
task
.
stop
((
err
)
=>
{
task
.
stop
((
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to stop the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to stop the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -2739,7 +2724,7 @@ stop(callback: AsyncCallback<void>): void
...
@@ -2739,7 +2724,7 @@ stop(callback: AsyncCallback<void>): void
console
.
info
(
`Succeeded in stopping a download task. `
);
console
.
info
(
`Succeeded in stopping a download task. `
);
});
});
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2770,9 +2755,8 @@ stop(): Promise<void>
...
@@ -2770,9 +2755,8 @@ stop(): Promise<void>
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
taskStopTest
'
,
title
:
'
taskStopTest
'
,
...
@@ -2794,14 +2778,14 @@ stop(): Promise<void>
...
@@ -2794,14 +2778,14 @@ stop(): Promise<void>
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
t
ask
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
T
ask
)
=>
{
task
.
stop
().
then
(()
=>
{
task
.
stop
().
then
(()
=>
{
console
.
info
(
`Succeeded in stopping a download task. `
);
console
.
info
(
`Succeeded in stopping a download task. `
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to stop the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to stop the download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
tid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -2838,17 +2822,16 @@ create(context: BaseContext, config: Config, callback: AsyncCallback<Task>
...
@@ -2838,17 +2822,16 @@ create(context: BaseContext, config: Config, callback: AsyncCallback<Task>
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
attachments
:
Array
<
request
.
agent
.
FormItem
>
=
[{
let
attachments
=
[{
name
:
"
reeateTest
"
,
name
:
"
reeateTest
"
,
value
:
{
value
:
{
filename
:
"
reeateTest.avi
"
,
filename
:
"
reeateTest.avi
"
,
mimeType
:
"
application/octet-stream
"
,
mimetype
:
"
application/octet-stream
"
,
path
:
"
./reeateTest.avi
"
,
path
:
"
./reeateTest.avi
"
,
}
}
}];
}];
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
reeateTest
'
,
title
:
'
reeateTest
'
,
...
@@ -2870,7 +2853,7 @@ create(context: BaseContext, config: Config, callback: AsyncCallback<Task>
...
@@ -2870,7 +2853,7 @@ create(context: BaseContext, config: Config, callback: AsyncCallback<Task>
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
,
(
err
,
t
ask
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
,
(
err
:
BusinessError
,
task
:
request
.
agent
.
T
ask
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -2920,17 +2903,16 @@ create(context: BaseContext, config: Config): Promise<Task>
...
@@ -2920,17 +2903,16 @@ create(context: BaseContext, config: Config): Promise<Task>
**示例:**
**示例:**
```
js
```
ts
let
context
;
let
attachments
:
Array
<
request
.
agent
.
FormItem
>
=
[{
let
attachments
=
[{
name
:
"
reeateTest
"
,
name
:
"
reeateTest
"
,
value
:
{
value
:
{
filename
:
"
reeateTest.avi
"
,
filename
:
"
reeateTest.avi
"
,
mimeType
:
"
application/octet-stream
"
,
mimetype
:
"
application/octet-stream
"
,
path
:
"
./reeateTest.avi
"
,
path
:
"
./reeateTest.avi
"
,
}
}
}];
}];
let
config
:
request
.
agent
.
Config
=
{
let
config
=
{
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
url
:
'
http://127.0.0.1
'
,
url
:
'
http://127.0.0.1
'
,
title
:
'
reeateTest
'
,
title
:
'
reeateTest
'
,
...
@@ -2952,7 +2934,7 @@ create(context: BaseContext, config: Config): Promise<Task>
...
@@ -2952,7 +2934,7 @@ create(context: BaseContext, config: Config): Promise<Task>
precise
:
false
,
precise
:
false
,
token
:
"
it is a secret
"
token
:
"
it is a secret
"
};
};
request
.
agent
.
create
(
context
,
config
).
then
((
task
)
=>
{
request
.
agent
.
create
(
this
.
context
,
config
).
then
((
task
:
request
.
agent
.
Task
)
=>
{
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
config
}
`
);
console
.
info
(
`Succeeded in creating a download task. result:
${
task
.
config
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to create a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
...
@@ -2989,8 +2971,8 @@ remove(id: string, callback: AsyncCallback<void>): void
...
@@ -2989,8 +2971,8 @@ remove(id: string, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
j
s
```
t
s
request
.
agent
.
remove
(
"
id
"
,
(
err
)
=>
{
request
.
agent
.
remove
(
"
id
"
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to removing a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to removing a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -3031,10 +3013,10 @@ remove(id: string): Promise<void>
...
@@ -3031,10 +3013,10 @@ remove(id: string): Promise<void>
**示例:**
**示例:**
```
j
s
```
t
s
request
.
agent
.
remove
(
"
id
"
).
then
(()
=>
{
request
.
agent
.
remove
(
"
id
"
).
then
(()
=>
{
console
.
info
(
`Succeeded in removing a download task. `
);
console
.
info
(
`Succeeded in removing a download task. `
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to remove a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to remove a download task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -3065,8 +3047,8 @@ show(id: string, callback: AsyncCallback<TaskInfo>): void
...
@@ -3065,8 +3047,8 @@ show(id: string, callback: AsyncCallback<TaskInfo>): void
**示例:**
**示例:**
```
j
s
```
t
s
request
.
agent
.
show
(
"
123456
"
,
(
err
,
TaskInfo
)
=>
{
request
.
agent
.
show
(
"
123456
"
,
(
err
:
BusinessError
,
taskInfo
:
request
.
agent
.
TaskInfo
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to show a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to show a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -3106,10 +3088,10 @@ show(id: string): Promise<TaskInfo>
...
@@ -3106,10 +3088,10 @@ show(id: string): Promise<TaskInfo>
**示例:**
**示例:**
```
j
s
```
t
s
request
.
agent
.
show
(
"
123456
"
).
then
((
TaskInfo
)
=>
{
request
.
agent
.
show
(
"
123456
"
).
then
((
taskInfo
:
request
.
agent
.
TaskInfo
)
=>
{
console
.
info
(
`Succeeded in showing a unload task.`
);
console
.
info
(
`Succeeded in showing a unload task.`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to show a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to show a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -3141,8 +3123,8 @@ touch(id: string, token: string, callback: AsyncCallback<TaskInfo>): void
...
@@ -3141,8 +3123,8 @@ touch(id: string, token: string, callback: AsyncCallback<TaskInfo>): void
**示例:**
**示例:**
```
j
s
```
t
s
request
.
agent
.
touch
(
"
123456
"
,
"
token
"
,
(
err
,
TaskInfo
)
=>
{
request
.
agent
.
touch
(
"
123456
"
,
"
token
"
,
(
err
:
BusinessError
,
taskInfo
:
request
.
agent
.
TaskInfo
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to touch a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to touch a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -3183,10 +3165,10 @@ touch(id: string, token: string): Promise<TaskInfo>
...
@@ -3183,10 +3165,10 @@ touch(id: string, token: string): Promise<TaskInfo>
**示例:**
**示例:**
```
j
s
```
t
s
request
.
agent
.
touch
(
"
123456
"
,
"
token
"
).
then
((
TaskInfo
)
=>
{
request
.
agent
.
touch
(
"
123456
"
,
"
token
"
).
then
((
taskInfo
:
request
.
agent
.
TaskInfo
)
=>
{
console
.
info
(
`Succeeded in touching a unload task. `
);
console
.
info
(
`Succeeded in touching a unload task. `
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to touch a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to touch a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -3216,13 +3198,13 @@ search(filter: Filter, callback: AsyncCallback<Array<string>>): void
...
@@ -3216,13 +3198,13 @@ search(filter: Filter, callback: AsyncCallback<Array<string>>): void
**示例:**
**示例:**
```
j
s
```
t
s
let
filter
=
{
let
filter
:
request
.
agent
.
Filter
=
{
bundle
:
"
com.example.myapplication
"
,
bundle
:
"
com.example.myapplication
"
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
mode
:
request
.
agent
.
Mode
.
BACKGROUND
mode
:
request
.
agent
.
Mode
.
BACKGROUND
}
}
request
.
agent
.
search
(
filter
,
(
err
,
data
)
=>
{
request
.
agent
.
search
(
filter
,
(
err
:
BusinessError
,
data
:
Array
<
string
>
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to search a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to search a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
...
@@ -3261,15 +3243,15 @@ search(filter: Filter): Promise<Array<string>>
...
@@ -3261,15 +3243,15 @@ search(filter: Filter): Promise<Array<string>>
**示例:**
**示例:**
```
j
s
```
t
s
let
filter
=
{
let
filter
:
request
.
agent
.
Filter
=
{
bundle
:
"
com.example.myapplication
"
,
bundle
:
"
com.example.myapplication
"
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
action
:
request
.
agent
.
Action
.
UPLOAD
,
mode
:
request
.
agent
.
Mode
.
BACKGROUND
mode
:
request
.
agent
.
Mode
.
BACKGROUND
}
}
request
.
agent
.
search
(
filter
).
then
((
data
)
=>
{
request
.
agent
.
search
(
filter
).
then
((
data
:
Array
<
string
>
)
=>
{
console
.
info
(
`Succeeded in searching a unload task. `
);
console
.
info
(
`Succeeded in searching a unload task. `
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to search a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to search a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
@@ -3304,13 +3286,13 @@ query(id: string, callback: AsyncCallback<TaskInfo>): void
...
@@ -3304,13 +3286,13 @@ query(id: string, callback: AsyncCallback<TaskInfo>): void
**示例:**
**示例:**
```
j
s
```
t
s
request
.
agent
.
query
(
"
123456
"
,
(
err
,
TaskInfo
)
=>
{
request
.
agent
.
query
(
"
123456
"
,
(
err
:
BusinessError
,
taskInfo
:
request
.
agent
.
TaskInfo
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`Failed to query a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to query a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
return
;
}
}
console
.
info
(
`Succeeded in querying a unload task. result:
${
T
askInfo
.
uid
}
`
);
console
.
info
(
`Succeeded in querying a unload task. result:
${
t
askInfo
.
uid
}
`
);
});
});
```
```
...
@@ -3349,10 +3331,10 @@ query(id: string): Promise<TaskInfo>
...
@@ -3349,10 +3331,10 @@ query(id: string): Promise<TaskInfo>
**示例:**
**示例:**
```
j
s
```
t
s
request
.
agent
.
query
(
"
123456
"
,).
then
((
TaskInfo
)
=>
{
request
.
agent
.
query
(
"
123456
"
,).
then
((
taskInfo
:
request
.
agent
.
TaskInfo
)
=>
{
console
.
info
(
`Succeeded in querying a unload task. result:
${
T
askInfo
.
uid
}
`
);
console
.
info
(
`Succeeded in querying a unload task. result:
${
t
askInfo
.
uid
}
`
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`Failed to query a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
console
.
error
(
`Failed to query a unload task, Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
});
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录