Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
3c0bf4d3
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
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看板
提交
3c0bf4d3
编写于
9月 04, 2023
作者:
L
lixinnan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lixinnan1@huawei.com
update UIContext Signed-off-by:
N
lixinnan
<
lixinnan1@huawei.com
>
上级
9d2907a0
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
275 addition
and
118 deletion
+275
-118
zh-cn/application-dev/reference/apis/js-apis-animator.md
zh-cn/application-dev/reference/apis/js-apis-animator.md
+15
-13
zh-cn/application-dev/reference/apis/js-apis-arkui-UIContext.md
...application-dev/reference/apis/js-apis-arkui-UIContext.md
+191
-59
zh-cn/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md
...ion-dev/reference/apis/js-apis-arkui-componentSnapshot.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-arkui-dragController.md
...cation-dev/reference/apis/js-apis-arkui-dragController.md
+25
-15
zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md
...on-dev/reference/apis/js-apis-arkui-drawableDescriptor.md
+11
-5
zh-cn/application-dev/reference/apis/js-apis-arkui-inspector.md
...application-dev/reference/apis/js-apis-arkui-inspector.md
+8
-10
zh-cn/application-dev/reference/apis/js-apis-system-app.md
zh-cn/application-dev/reference/apis/js-apis-system-app.md
+15
-12
zh-cn/application-dev/reference/apis/js-apis-uiappearance.md
zh-cn/application-dev/reference/apis/js-apis-uiappearance.md
+8
-2
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-animator.md
浏览文件 @
3c0bf4d3
...
...
@@ -15,7 +15,7 @@
## 导入模块
```
js
import
animator
from
'
@ohos.animator
'
;
import
animator
,
{
AnimatorResult
}
from
'
@ohos.animator
'
;
```
## create<sup>9+</sup>
...
...
@@ -40,7 +40,7 @@ create(options: AnimatorOptions): AnimatorResult
**示例:**
```
js
import
animator
,
{
Animator
Options
}
from
'
@ohos.animator
'
;
import
animator
,
{
Animator
Result
}
from
'
@ohos.animator
'
;
let
options
:
AnimatorOptions
=
{
// xxx.js文件中不需要强调显式类型AnimatorOptions
duration
:
1500
,
...
...
@@ -328,7 +328,7 @@ export default {
### 基于TS扩展的声明式开发范式
```
ts
import
animator
from
'
@ohos.animator
'
;
import
animator
,
{
AnimatorResult
}
from
'
@ohos.animator
'
;
@
Entry
@
Component
...
...
@@ -459,16 +459,18 @@ struct AnimatorTest {
.
onClick
(()
=>
{
if
(
this
.
flag
)
{
this
.
flag
=
false
this
.
backAnimator
.
reset
({
duration
:
5000
,
easing
:
"
ease-in
"
,
delay
:
0
,
fill
:
"
none
"
,
direction
:
"
normal
"
,
iterations
:
4
,
begin
:
100
,
end
:
300
})
if
(
this
.
backAnimator
){
this
.
backAnimator
.
reset
({
duration
:
5000
,
easing
:
"
ease-in
"
,
delay
:
0
,
fill
:
"
none
"
,
direction
:
"
normal
"
,
iterations
:
4
,
begin
:
100
,
end
:
300
})
}
}
else
{
console
.
info
(
this
.
TAG
,
'
Animation not ended
'
)
}
...
...
zh-cn/application-dev/reference/apis/js-apis-arkui-UIContext.md
浏览文件 @
3c0bf4d3
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md
浏览文件 @
3c0bf4d3
...
...
@@ -203,7 +203,7 @@ struct OffscreenSnapshotExample {
Column
()
{
Button
(
"
click to generate offscreen UI snapshot
"
)
.
onClick
(()
=>
{
componentSnapshot
.
createFromBuilder
(
this
.
RandomBuilder
.
bind
(
this
),
componentSnapshot
.
createFromBuilder
(
this
.
RandomBuilder
(
),
(
error
:
Error
,
pixmap
:
image
.
PixelMap
)
=>
{
this
.
pixmap
=
pixmap
// save pixmap to file
...
...
@@ -280,7 +280,7 @@ struct OffscreenSnapshotExample {
Column
()
{
Button
(
"
click to generate offscreen UI snapshot
"
)
.
onClick
(()
=>
{
componentSnapshot
.
createFromBuilder
(
this
.
RandomBuilder
.
bind
(
this
))
componentSnapshot
.
createFromBuilder
(
this
.
RandomBuilder
(
))
.
then
((
pixmap
:
image
.
PixelMap
)
=>
{
this
.
pixmap
=
pixmap
// save pixmap to file
...
...
zh-cn/application-dev/reference/apis/js-apis-arkui-dragController.md
浏览文件 @
3c0bf4d3
...
...
@@ -37,7 +37,7 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo, callback:
```
ts
import
dragController
from
"
@ohos.arkui.dragController
"
import
UD
C
from
'
@ohos.data.unifiedDataChannel
'
;
import
UD
MF
from
'
@ohos.data.unifiedDataChannel
'
;
@
Entry
@
Component
...
...
@@ -57,18 +57,23 @@ struct DragControllerPage {
.
onTouch
((
event
?:
TouchEvent
)
=>
{
if
(
event
){
if
(
event
.
type
==
TouchType
.
Down
)
{
let
text
:
object
=
new
UDMF
.
Text
()
let
unifiedData
:
object
=
new
UDMF
.
UnifiedData
(
text
)
let
text
=
new
UDMF
.
Text
()
let
unifiedData
=
new
UDMF
.
UnifiedData
(
text
)
let
dragInfo
:
dragController
.
DragInfo
=
{
pointerId
:
0
,
data
:
unifiedData
,
extraParams
:
''
}
dragController
.
executeDrag
(
this
.
DraggingBuilder
.
bind
(
this
),
dragInfo
,
(
err
,
{
event
,
extraParams
})
=>
{
if
(
event
.
getResult
()
==
DragResult
.
DRAG_SUCCESSFUL
)
{
class
tmp
{
event
:
DragResult
|
undefined
=
undefined
extraParams
:
string
=
''
}
let
eve
:
tmp
=
new
tmp
()
dragController
.
executeDrag
(
this
.
DraggingBuilder
(),
dragInfo
,
(
err
,
eve
)
=>
{
if
(
eve
.
event
.
getResult
()
==
DragResult
.
DRAG_SUCCESSFUL
)
{
// ...
}
else
if
(
event
.
getResult
()
==
DragResult
.
DRAG_FAILED
)
{
}
else
if
(
eve
.
eve
nt
.
getResult
()
==
DragResult
.
DRAG_FAILED
)
{
// ...
}
})
...
...
@@ -107,7 +112,7 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo): Promise&l
import
dragController
from
"
@ohos.arkui.dragController
"
import
componentSnapshot
from
'
@ohos.arkui.componentSnapshot
'
;
import
image
from
'
@ohos.multimedia.image
'
;
import
UD
C
from
'
@ohos.data.unifiedDataChannel
'
;
import
UD
MF
from
'
@ohos.data.unifiedDataChannel
'
;
@
Entry
@
Component
...
...
@@ -138,31 +143,36 @@ struct DragControllerPage {
.
onTouch
((
event
?:
TouchEvent
)
=>
{
if
(
event
){
if
(
event
.
type
==
TouchType
.
Down
)
{
let
text
:
object
=
new
UDMF
.
Text
()
let
unifiedData
:
object
=
new
UDMF
.
UnifiedData
(
text
)
let
text
=
new
UDMF
.
Text
()
let
unifiedData
=
new
UDMF
.
UnifiedData
(
text
)
let
dragInfo
:
dragController
.
DragInfo
=
{
pointerId
:
0
,
data
:
unifiedData
,
extraParams
:
''
}
componentSnapshot
.
createFromBuilder
(
this
.
PixmapBuilder
.
bind
(
this
)).
then
((
pix
:
image
.
PixelMap
)
=>
{
componentSnapshot
.
createFromBuilder
(
this
.
PixmapBuilder
(
)).
then
((
pix
:
image
.
PixelMap
)
=>
{
this
.
pixmap
=
pix
;
let
dragItemInfo
:
DragItemInfo
=
{
pixelMap
:
this
.
pixmap
,
builder
:
this
.
DraggingBuilder
.
bind
(
this
),
builder
:
this
.
DraggingBuilder
(
),
extraInfo
:
"
DragItemInfoTest
"
}
class
tmp
{
event
:
DragResult
|
undefined
=
undefined
extraParams
:
string
=
''
}
let
eve
:
tmp
=
new
tmp
()
dragController
.
executeDrag
(
dragItemInfo
,
dragInfo
)
.
then
((
{
event
,
extraParams
}
)
=>
{
if
(
event
.
getResult
()
==
DragResult
.
DRAG_SUCCESSFUL
)
{
.
then
((
eve
)
=>
{
if
(
eve
.
eve
nt
.
getResult
()
==
DragResult
.
DRAG_SUCCESSFUL
)
{
// ...
}
else
if
(
event
.
getResult
()
==
DragResult
.
DRAG_FAILED
)
{
}
else
if
(
eve
.
eve
nt
.
getResult
()
==
DragResult
.
DRAG_FAILED
)
{
// ...
}
})
.
catch
((
err
)
=>
{
.
catch
((
err
:
Error
)
=>
{
})
})
}
...
...
zh-cn/application-dev/reference/apis/js-apis-arkui-drawableDescriptor.md
浏览文件 @
3c0bf4d3
...
...
@@ -80,10 +80,11 @@ getPixelMap(): image.PixelMap;
**示例:**
```
ts
import
{
DrawableDescriptor
,
LayeredDrawableDescriptor
}
from
'
@ohos.arkui.drawableDescriptor
'
let
resManager
=
getContext
().
resourceManager
let
pixmap
:
DrawableDescriptor
=
(
resManager
.
getDrawableDescriptor
(
$r
(
'
app.media.icon
'
)
.
id
))
as
DrawableDescriptor
;
let
pixmapNew
:
DrawableDescriptor
=
pixmap
.
getPixelMap
()
let
pixmapNew
:
object
=
pixmap
.
getPixelMap
()
```
## LayeredDrawableDescriptor.getPixelMap
...
...
@@ -101,10 +102,11 @@ getPixelMap(): image.PixelMap;
**示例:**
```
ts
import
{
DrawableDescriptor
,
LayeredDrawableDescriptor
}
from
'
@ohos.arkui.drawableDescriptor
'
let
resManager
=
getContext
().
resourceManager
let
pixmap
:
LayeredDrawableDescriptor
=
(
resManager
.
getDrawableDescriptor
(
$r
(
'
app.media.icon
'
)
.
id
))
as
LayeredDrawableDescriptor
;
let
pixmapNew
:
LayeredDrawableDescriptor
=
pixmap
.
getPixelMap
()
let
pixmapNew
:
object
=
pixmap
.
getPixelMap
()
```
## LayeredDrawableDescriptor.getForeground
...
...
@@ -122,10 +124,11 @@ getForeground(): DrawableDescriptor;
**示例:**
```
ts
import
{
DrawableDescriptor
,
LayeredDrawableDescriptor
}
from
'
@ohos.arkui.drawableDescriptor
'
let
resManager
=
getContext
().
resourceManager
let
drawable
:
LayeredDrawableDescriptor
=
(
resManager
.
getDrawableDescriptor
(
$r
(
'
app.media.icon
'
)
.
id
))
as
LayeredDrawableDescriptor
;
let
drawableNew
:
LayeredDrawableDescriptor
=
drawable
.
getForeground
()
let
drawableNew
:
object
=
drawable
.
getForeground
()
```
## LayeredDrawableDescriptor.getBackground
...
...
@@ -143,10 +146,11 @@ getBackground(): DrawableDescriptor;
**示例:**
```
ts
import
{
DrawableDescriptor
,
LayeredDrawableDescriptor
}
from
'
@ohos.arkui.drawableDescriptor
'
let
resManager
=
getContext
().
resourceManager
let
drawable
:
LayeredDrawableDescriptor
=
(
resManager
.
getDrawableDescriptor
(
$r
(
'
app.media.icon
'
)
.
id
))
as
LayeredDrawableDescriptor
;
let
drawableNew
:
LayeredDrawableDescriptor
=
drawable
.
getBackground
()
let
drawableNew
:
object
=
drawable
.
getBackground
()
```
## LayeredDrawableDescriptor.getMask
...
...
@@ -164,10 +168,11 @@ getMask(): DrawableDescriptor;
**示例:**
```
ts
import
{
DrawableDescriptor
,
LayeredDrawableDescriptor
}
from
'
@ohos.arkui.drawableDescriptor
'
let
resManager
=
getContext
().
resourceManager
let
drawable
:
LayeredDrawableDescriptor
=
(
resManager
.
getDrawableDescriptor
(
$r
(
'
app.media.icon
'
)
.
id
))
as
LayeredDrawableDescriptor
;
let
drawableNew
:
LayeredDrawableDescriptor
=
drawable
.
getMask
()
let
drawableNew
:
object
=
drawable
.
getMask
()
```
## LayeredDrawableDescriptor.getMaskClipPath
static getMaskClipPath(): string
...
...
@@ -184,6 +189,7 @@ LayeredDrawableDescriptor的静态方法,获取系统内置的裁切路径参
**示例:**
```
ts
import
{
DrawableDescriptor
,
LayeredDrawableDescriptor
}
from
'
@ohos.arkui.drawableDescriptor
'
Image
(
$r
(
'
app.media.icon
'
))
.
width
(
'
200px
'
).
height
(
'
200px
'
)
.
clip
(
new
Path
({
commands
:
LayeredDrawableDescriptor
.
getMaskClipPath
()}))
...
...
zh-cn/application-dev/reference/apis/js-apis-arkui-inspector.md
浏览文件 @
3c0bf4d3
...
...
@@ -129,19 +129,17 @@ off(type: 'draw', callback?: () => void): void
listener
:
inspector
.
ComponentObserver
=
inspector
.
createComponentObserver
(
'
IMAGE_ID
'
)
aboutToAppear
()
{
let
FuncLayout
=
this
.
onLayoutComplete
.
bind
(
this
)
// bind current js instance
let
FuncDraw
=
this
.
onDrawComplete
.
bind
(
this
)
// bind current js instance
let
onLayoutComplete
:()
=>
void
=
():
void
=>
{
// do something here
}
let
onDrawComplete
:()
=>
void
=
():
void
=>
{
// do something here
}
let
FuncLayout
=
onLayoutComplete
// bind current js instance
let
FuncDraw
=
onDrawComplete
// bind current js instance
this
.
listener
.
on
(
'
layout
'
,
FuncLayout
)
this
.
listener
.
on
(
'
draw
'
,
FuncDraw
)
}
onLayoutComplete
()
{
// do something here
}
onDrawComplete
()
{
// do something here
}
}
```
zh-cn/application-dev/reference/apis/js-apis-system-app.md
浏览文件 @
3c0bf4d3
...
...
@@ -9,7 +9,7 @@
```
ts
import
app
from
'
@system.app
'
import
app
,
{
AppResponse
}
from
'
@system.app
'
```
## App
...
...
@@ -33,9 +33,10 @@ static getInfo(): AppResponse
**示例:**
```
ts
export
default
{
import
app
,
{
AppResponse
}
from
'
@system.app
'
export
default
class
Info
{
getInfo
()
{
let
info
=
app
.
getInfo
()
let
info
:
AppResponse
=
app
.
getInfo
()
console
.
log
(
JSON
.
stringify
(
info
))
}
}
...
...
@@ -54,7 +55,8 @@ static terminate(): void
**示例:**
```
ts
export
default
{
import
app
,
{
AppResponse
}
from
'
@system.app
'
export
default
class
TerM
{
terminate
()
{
app
.
terminate
()
}
...
...
@@ -78,9 +80,9 @@ static setImageCacheCount(value: number): void
```
ts
// app.ets
import
app
from
'
@system.app
'
import
app
,
{
AppResponse
}
from
'
@system.app
'
export
default
{
export
default
class
OnC
{
onCreate
()
{
app
.
setImageCacheCount
(
100
)
// 设置解码后图片内存缓存上限为100张
console
.
info
(
'
Application onCreate
'
)
...
...
@@ -109,9 +111,9 @@ static setImageRawDataCacheSize(value: number): void
```
ts
// app.ets
import
app
from
'
@system.app
'
import
app
,
{
AppResponse
}
from
'
@system.app
'
export
default
{
export
default
class
OnC
{
onCreate
()
{
app
.
setImageRawDataCacheSize
(
104857600
)
// 设置解码前图片数据内存缓存上限为100MB (100MB=100*1024*1024B=104857600B)
...
...
@@ -141,9 +143,9 @@ static setImageFileCacheSize(value: number): void
```
ts
// app.ets
import
app
from
'
@system.app
'
import
app
,
{
AppResponse
}
from
'
@system.app
'
export
default
{
export
default
class
OnC
{
onCreate
()
{
app
.
setImageFileCacheSize
(
209715200
)
// 设置图片文件数据缓存上限为200MB (200MB=200*1024*1024B=209715200B)
...
...
@@ -188,13 +190,14 @@ static requestFullWindow(options?: RequestFullWindowOptions): void
**示例:**
```
ts
export
default
{
import
app
,
{
AppResponse
}
from
'
@system.app
'
export
default
class
Req
{
requestFullWindow
()
{
app
.
requestFullWindow
({
duration
:
200
})
}
}
}
```
## AppResponse
...
...
zh-cn/application-dev/reference/apis/js-apis-uiappearance.md
浏览文件 @
3c0bf4d3
...
...
@@ -57,6 +57,8 @@ setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void
**示例:**
```
ts
import
uiAppearance
from
'
@ohos.uiAppearance
'
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
uiAppearance
.
setDarkMode
(
uiAppearance
.
DarkMode
.
ALWAYS_DARK
,
(
error
)
=>
{
if
(
error
)
{
...
...
@@ -105,10 +107,12 @@ setDarkMode(mode: DarkMode): Promise\<void>;
**示例:**
```
ts
import
uiAppearance
from
'
@ohos.uiAppearance
'
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
uiAppearance
.
setDarkMode
(
uiAppearance
.
DarkMode
.
ALWAYS_DARK
).
then
(()
=>
{
console
.
info
(
'
Set dark-mode successfully.
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Error
)
=>
{
console
.
error
(
'
Set dark-mode failed,
'
+
error
.
message
);
});
}
catch
(
error
)
{
...
...
@@ -145,9 +149,11 @@ getDarkMode(): DarkMode;
**示例:**
```
ts
import
uiAppearance
from
'
@ohos.uiAppearance
'
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
let
darkMode
=
uiAppearance
.
getDarkMode
();
console
.
info
(
'
Get dark-mode
'
+
m
ode
);
console
.
info
(
'
Get dark-mode
'
+
darkM
ode
);
}
catch
(
error
)
{
let
message
=
(
error
as
BusinessError
).
message
;
console
.
error
(
'
Get dark-mode failed,
'
+
message
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录