未验证 提交 ba826c1b 编写于 作者: O openharmony_ci 提交者: Gitee

!23722 update api md

Merge pull request !23722 from 李欣楠/master
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
## 导入模块 ## 导入模块
```js ```js
import animator from '@ohos.animator'; import animator, { AnimatorResult } from '@ohos.animator';
``` ```
## create<sup>9+</sup> ## create<sup>9+</sup>
...@@ -40,7 +40,7 @@ create(options: AnimatorOptions): AnimatorResult ...@@ -40,7 +40,7 @@ create(options: AnimatorOptions): AnimatorResult
**示例:** **示例:**
```js ```js
import animator, { AnimatorOptions } from '@ohos.animator'; import animator, { AnimatorResult } from '@ohos.animator';
let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions
duration: 1500, duration: 1500,
...@@ -328,7 +328,7 @@ export default { ...@@ -328,7 +328,7 @@ export default {
### 基于TS扩展的声明式开发范式 ### 基于TS扩展的声明式开发范式
```ts ```ts
import animator from '@ohos.animator'; import animator, { AnimatorResult } from '@ohos.animator';
@Entry @Entry
@Component @Component
...@@ -459,16 +459,18 @@ struct AnimatorTest { ...@@ -459,16 +459,18 @@ struct AnimatorTest {
.onClick(() => { .onClick(() => {
if (this.flag) { if (this.flag) {
this.flag = false this.flag = false
this.backAnimator.reset({ if(this.backAnimator){
duration: 5000, this.backAnimator.reset({
easing: "ease-in", duration: 5000,
delay: 0, easing: "ease-in",
fill: "none", delay: 0,
direction: "normal", fill: "none",
iterations: 4, direction: "normal",
begin: 100, iterations: 4,
end: 300 begin: 100,
}) end: 300
})
}
} else { } else {
console.info(this.TAG, 'Animation not ended') console.info(this.TAG, 'Animation not ended')
} }
......
...@@ -356,7 +356,7 @@ uiContext.showDatePickerDialog({ ...@@ -356,7 +356,7 @@ uiContext.showDatePickerDialog({
selected: selectedDate, selected: selectedDate,
onAccept: (value: DatePickerResult) => { onAccept: (value: DatePickerResult) => {
// 通过Date的setFullYear方法设置按下确定按钮时的日期,这样当弹窗再次弹出时显示选中的是上一次确定的日期 // 通过Date的setFullYear方法设置按下确定按钮时的日期,这样当弹窗再次弹出时显示选中的是上一次确定的日期
selectedDate.setFullYear(value.year, value.month, value.day) selectedDate.setFullYear(Number(value.year), Number(value.month), Number(value.day))
console.info("DatePickerDialog:onAccept()" + JSON.stringify(value)) console.info("DatePickerDialog:onAccept()" + JSON.stringify(value))
}, },
onCancel: () => { onCancel: () => {
...@@ -500,6 +500,7 @@ createAnimator(options: AnimatorOptions): AnimatorResult ...@@ -500,6 +500,7 @@ createAnimator(options: AnimatorOptions): AnimatorResult
**示例:** **示例:**
```ts ```ts
import { AnimatorOptions } from '@ohos.animator';
let options:AnimatorOptions = { let options:AnimatorOptions = {
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
...@@ -558,6 +559,7 @@ registerFont(options: font.FontOptions): void ...@@ -558,6 +559,7 @@ registerFont(options: font.FontOptions): void
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
let font:Font = uiContext.getFont(); let font:Font = uiContext.getFont();
font.registerFont({ font.registerFont({
familyName: 'medium', familyName: 'medium',
...@@ -581,7 +583,8 @@ getSystemFontList(): Array\<string> ...@@ -581,7 +583,8 @@ getSystemFontList(): Array\<string>
**示例:** **示例:**
```ts ```ts
let font:Font = uiContext.getFont(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
let font:Font|undefined = uiContext.getFont();
font.getSystemFontList() font.getSystemFontList()
``` ```
...@@ -608,7 +611,8 @@ getFontByName(fontName: string): font.FontInfo ...@@ -608,7 +611,8 @@ getFontByName(fontName: string): font.FontInfo
**示例:** **示例:**
```ts ```ts
let font:Font = uiContext.getFont(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
let font:Font|undefined = uiContext.getFont();
font.getFontByName('Sans Italic') font.getFontByName('Sans Italic')
``` ```
...@@ -639,10 +643,11 @@ getRectangleById(id: string): componentUtils.ComponentInfo ...@@ -639,10 +643,11 @@ getRectangleById(id: string): componentUtils.ComponentInfo
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
let componentUtils:ComponentUtils = uiContext.getComponentUtils(); let componentUtils:ComponentUtils = uiContext.getComponentUtils();
let modePosition:componentUtils.ComponentInfo = componentUtils.getRectangleById("onClick"); let modePosition = componentUtils.getRectangleById("onClick");
let localOffsetWidth:object = modePosition.size.width; let localOffsetWidth = modePosition.size.width;
let localOffsetHeight:object = modePosition.size.height; let localOffsetHeight = modePosition.size.height;
``` ```
## UIInspector ## UIInspector
...@@ -672,6 +677,7 @@ createComponentObserver(id: string): inspector.ComponentObserver ...@@ -672,6 +677,7 @@ createComponentObserver(id: string): inspector.ComponentObserver
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
let inspector:UIInspector = uiContext.getUIInspector(); let inspector:UIInspector = uiContext.getUIInspector();
let listener = inspector.createComponentObserver('COMPONENT_ID'); let listener = inspector.createComponentObserver('COMPONENT_ID');
``` ```
...@@ -703,6 +709,7 @@ matchMediaSync(condition: string): mediaQuery.MediaQueryListener ...@@ -703,6 +709,7 @@ matchMediaSync(condition: string): mediaQuery.MediaQueryListener
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
let mediaquery: MediaQuery = uiContext.getMediaQuery(); let mediaquery: MediaQuery = uiContext.getMediaQuery();
let listener = mediaquery.matchMediaSync('(orientation: landscape)'); //监听横屏事件 let listener = mediaquery.matchMediaSync('(orientation: landscape)'); //监听横屏事件
``` ```
...@@ -744,6 +751,8 @@ pushUrl(options: router.RouterOptions): Promise&lt;void&gt; ...@@ -744,6 +751,8 @@ pushUrl(options: router.RouterOptions): Promise&lt;void&gt;
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router = uiContext.getRouter(); let router = uiContext.getRouter();
try { try {
router.pushUrl({ router.pushUrl({
...@@ -790,6 +799,8 @@ pushUrl(options: router.RouterOptions, callback: AsyncCallback&lt;void&gt;): voi ...@@ -790,6 +799,8 @@ pushUrl(options: router.RouterOptions, callback: AsyncCallback&lt;void&gt;): voi
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router = uiContext.getRouter(); let router = uiContext.getRouter();
router.pushUrl({ router.pushUrl({
url: 'pages/routerpage2', url: 'pages/routerpage2',
...@@ -801,7 +812,9 @@ router.pushUrl({ ...@@ -801,7 +812,9 @@ router.pushUrl({
} }
}, (err: Error) => { }, (err: Error) => {
if (err) { if (err) {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); let message = (err as BusinessError).message;
let code = (err as BusinessError).code;
console.error(`pushUrl failed, code is ${code}, message is ${message}`);
return; return;
} }
console.info('pushUrl success'); console.info('pushUrl success');
...@@ -842,9 +855,16 @@ pushUrl(options: router.RouterOptions, mode: router.RouterMode): Promise&lt;void ...@@ -842,9 +855,16 @@ pushUrl(options: router.RouterOptions, mode: router.RouterMode): Promise&lt;void
**示例:** **示例:**
```ts ```ts
let router = uiContext.getRouter(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
import router from '@ohos.router';
let routerF:Router = uiContext.getRouter();
class routerTmp{
Standard:router.RouterMode = router.RouterMode.Standard
}
let rtm:routerTmp = new routerTmp()
try { try {
router.pushUrl({ routerF.pushUrl({
url: 'pages/routerpage2', url: 'pages/routerpage2',
params: { params: {
data1: 'message', data1: 'message',
...@@ -852,7 +872,7 @@ try { ...@@ -852,7 +872,7 @@ try {
data3: [123, 456, 789] data3: [123, 456, 789]
} }
} }
}, router.RouterMode.Standard) }, rtm.Standard)
} catch (err) { } catch (err) {
let message = (err as BusinessError).message; let message = (err as BusinessError).message;
let code = (err as BusinessError).code; let code = (err as BusinessError).code;
...@@ -889,8 +909,15 @@ pushUrl(options: router.RouterOptions, mode: router.RouterMode, callback: AsyncC ...@@ -889,8 +909,15 @@ pushUrl(options: router.RouterOptions, mode: router.RouterMode, callback: AsyncC
**示例:** **示例:**
```ts ```ts
let router = uiContext.getRouter(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
router.pushUrl({ import { BusinessError } from '@ohos.base';
import router from '@ohos.router';
let routerF:Router = uiContext.getRouter();
class routerTmp{
Standard:router.RouterMode = router.RouterMode.Standard
}
let rtm:routerTmp = new routerTmp()
routerF.pushUrl({
url: 'pages/routerpage2', url: 'pages/routerpage2',
params: { params: {
data1: 'message', data1: 'message',
...@@ -898,9 +925,11 @@ router.pushUrl({ ...@@ -898,9 +925,11 @@ router.pushUrl({
data3: [123, 456, 789] data3: [123, 456, 789]
} }
} }
}, router.RouterMode.Standard, (err) => { }, rtm.Standard, (err) => {
if (err) { if (err) {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); let message = (err as BusinessError).message;
let code = (err as BusinessError).code;
console.error(`pushUrl failed, code is ${code}, message is ${message}`);
return; return;
} }
console.info('pushUrl success'); console.info('pushUrl success');
...@@ -939,6 +968,8 @@ replaceUrl(options: router.RouterOptions): Promise&lt;void&gt; ...@@ -939,6 +968,8 @@ replaceUrl(options: router.RouterOptions): Promise&lt;void&gt;
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router = uiContext.getRouter(); let router = uiContext.getRouter();
try { try {
router.replaceUrl({ router.replaceUrl({
...@@ -981,6 +1012,8 @@ replaceUrl(options: router.RouterOptions, callback: AsyncCallback&lt;void&gt;): ...@@ -981,6 +1012,8 @@ replaceUrl(options: router.RouterOptions, callback: AsyncCallback&lt;void&gt;):
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router = uiContext.getRouter(); let router = uiContext.getRouter();
router.replaceUrl({ router.replaceUrl({
url: 'pages/detail', url: 'pages/detail',
...@@ -989,7 +1022,9 @@ router.replaceUrl({ ...@@ -989,7 +1022,9 @@ router.replaceUrl({
} }
}, (err: Error) => { }, (err: Error) => {
if (err) { if (err) {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); let message = (err as BusinessError).message;
let code = (err as BusinessError).code;
console.error(`replaceUrl failed, code is ${code}, message is ${message}`);
return; return;
} }
console.info('replaceUrl success'); console.info('replaceUrl success');
...@@ -1029,14 +1064,21 @@ replaceUrl(options: router.RouterOptions, mode: router.RouterMode): Promise&lt;v ...@@ -1029,14 +1064,21 @@ replaceUrl(options: router.RouterOptions, mode: router.RouterMode): Promise&lt;v
**示例:** **示例:**
```ts ```ts
let router = uiContext.getRouter(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
import router from '@ohos.router';
let routerF:Router = uiContext.getRouter();
class routerTmp{
Standard:router.RouterMode = router.RouterMode.Standard
}
let rtm:routerTmp = new routerTmp()
try { try {
router.replaceUrl({ routerF.replaceUrl({
url: 'pages/detail', url: 'pages/detail',
params: { params: {
data1: 'message' data1: 'message'
} }
}, router.RouterMode.Standard) }, rtm.Standard)
} catch (err) { } catch (err) {
let message = (err as BusinessError).message; let message = (err as BusinessError).message;
let code = (err as BusinessError).code; let code = (err as BusinessError).code;
...@@ -1072,15 +1114,24 @@ replaceUrl(options: router.RouterOptions, mode: router.RouterMode, callback: Asy ...@@ -1072,15 +1114,24 @@ replaceUrl(options: router.RouterOptions, mode: router.RouterMode, callback: Asy
**示例:** **示例:**
```ts ```ts
let router = uiContext.getRouter(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
router.replaceUrl({ import { BusinessError } from '@ohos.base';
import router from '@ohos.router';
let routerF:Router = uiContext.getRouter();
class routerTmp{
Standard:router.RouterMode = router.RouterMode.Standard
}
let rtm:routerTmp = new routerTmp()
routerF.replaceUrl({
url: 'pages/detail', url: 'pages/detail',
params: { params: {
data1: 'message' data1: 'message'
} }
}, router.RouterMode.Standard, (err: Error) => { }, rtm.Standard, (err: Error) => {
if (err) { if (err) {
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`); let message = (err as BusinessError).message;
let code = (err as BusinessError).code;
console.error(`replaceUrl failed, code is ${code}, message is ${message}`);
return; return;
} }
console.info('replaceUrl success'); console.info('replaceUrl success');
...@@ -1120,6 +1171,8 @@ pushNamedRoute(options: router.NamedRouterOptions): Promise&lt;void&gt; ...@@ -1120,6 +1171,8 @@ pushNamedRoute(options: router.NamedRouterOptions): Promise&lt;void&gt;
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router = uiContext.getRouter(); let router = uiContext.getRouter();
try { try {
router.pushNamedRoute({ router.pushNamedRoute({
...@@ -1166,6 +1219,8 @@ pushNamedRoute(options: router.NamedRouterOptions, callback: AsyncCallback&lt;vo ...@@ -1166,6 +1219,8 @@ pushNamedRoute(options: router.NamedRouterOptions, callback: AsyncCallback&lt;vo
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router = uiContext.getRouter(); let router = uiContext.getRouter();
router.pushNamedRoute({ router.pushNamedRoute({
name: 'myPage', name: 'myPage',
...@@ -1177,7 +1232,9 @@ router.pushNamedRoute({ ...@@ -1177,7 +1232,9 @@ router.pushNamedRoute({
} }
}, (err: Error) => { }, (err: Error) => {
if (err) { if (err) {
console.error(`pushNamedRoute failed, code is ${err.code}, message is ${err.message}`); let message = (err as BusinessError).message;
let code = (err as BusinessError).code;
console.error(`pushNamedRoute failed, code is ${code}, message is ${message}`);
return; return;
} }
console.info('pushNamedRoute success'); console.info('pushNamedRoute success');
...@@ -1217,9 +1274,16 @@ pushNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode): Pro ...@@ -1217,9 +1274,16 @@ pushNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode): Pro
**示例:** **示例:**
```ts ```ts
let router = uiContext.getRouter(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
import router from '@ohos.router';
let routerF:Router = uiContext.getRouter();
class routerTmp{
Standard:router.RouterMode = router.RouterMode.Standard
}
let rtm:routerTmp = new routerTmp()
try { try {
router.pushNamedRoute({ routerF.pushNamedRoute({
name: 'myPage', name: 'myPage',
params: { params: {
data1: 'message', data1: 'message',
...@@ -1227,7 +1291,7 @@ try { ...@@ -1227,7 +1291,7 @@ try {
data3: [123, 456, 789] data3: [123, 456, 789]
} }
} }
}, router.RouterMode.Standard) }, rtm.Standard)
} catch (err) { } catch (err) {
let message = (err as BusinessError).message; let message = (err as BusinessError).message;
let code = (err as BusinessError).code; let code = (err as BusinessError).code;
...@@ -1264,8 +1328,15 @@ pushNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode, call ...@@ -1264,8 +1328,15 @@ pushNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode, call
**示例:** **示例:**
```ts ```ts
let router = uiContext.getRouter(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
router.pushNamedRoute({ import { BusinessError } from '@ohos.base';
import router from '@ohos.router';
let routerF:Router = uiContext.getRouter();
class routerTmp{
Standard:router.RouterMode = router.RouterMode.Standard
}
let rtm:routerTmp = new routerTmp()
routerF.pushNamedRoute({
name: 'myPage', name: 'myPage',
params: { params: {
data1: 'message', data1: 'message',
...@@ -1273,9 +1344,11 @@ router.pushNamedRoute({ ...@@ -1273,9 +1344,11 @@ router.pushNamedRoute({
data3: [123, 456, 789] data3: [123, 456, 789]
} }
} }
}, router.RouterMode.Standard, (err: Error) => { }, rtm.Standard, (err: Error) => {
if (err) { if (err) {
console.error(`pushNamedRoute failed, code is ${err.code}, message is ${err.message}`); let message = (err as BusinessError).message;
let code = (err as BusinessError).code;
console.error(`pushNamedRoute failed, code is ${code}, message is ${message}`);
return; return;
} }
console.info('pushNamedRoute success'); console.info('pushNamedRoute success');
...@@ -1314,6 +1387,8 @@ replaceNamedRoute(options: router.NamedRouterOptions): Promise&lt;void&gt; ...@@ -1314,6 +1387,8 @@ replaceNamedRoute(options: router.NamedRouterOptions): Promise&lt;void&gt;
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router = uiContext.getRouter(); let router = uiContext.getRouter();
try { try {
router.replaceNamedRoute({ router.replaceNamedRoute({
...@@ -1356,6 +1431,8 @@ replaceNamedRoute(options: router.NamedRouterOptions, callback: AsyncCallback&lt ...@@ -1356,6 +1431,8 @@ replaceNamedRoute(options: router.NamedRouterOptions, callback: AsyncCallback&lt
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router = uiContext.getRouter(); let router = uiContext.getRouter();
router.replaceNamedRoute({ router.replaceNamedRoute({
name: 'myPage', name: 'myPage',
...@@ -1364,7 +1441,9 @@ router.replaceNamedRoute({ ...@@ -1364,7 +1441,9 @@ router.replaceNamedRoute({
} }
}, (err: Error) => { }, (err: Error) => {
if (err) { if (err) {
console.error(`replaceNamedRoute failed, code is ${err.code}, message is ${err.message}`); let message = (err as BusinessError).message;
let code = (err as BusinessError).code;
console.error(`replaceNamedRoute failed, code is ${code}, message is ${message}`);
return; return;
} }
console.info('replaceNamedRoute success'); console.info('replaceNamedRoute success');
...@@ -1405,14 +1484,21 @@ replaceNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode): ...@@ -1405,14 +1484,21 @@ replaceNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode):
**示例:** **示例:**
```ts ```ts
let router = uiContext.getRouter(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
import router from '@ohos.router';
let routerF:Router = uiContext.getRouter();
class routerTmp{
Standard:router.RouterMode = router.RouterMode.Standard
}
let rtm:routerTmp = new routerTmp()
try { try {
router.replaceNamedRoute({ routerF.replaceNamedRoute({
name: 'myPage', name: 'myPage',
params: { params: {
data1: 'message' data1: 'message'
} }
}, router.RouterMode.Standard) }, rtm.Standard)
} catch (err) { } catch (err) {
let message = (err as BusinessError).message; let message = (err as BusinessError).message;
let code = (err as BusinessError).code; let code = (err as BusinessError).code;
...@@ -1448,15 +1534,24 @@ replaceNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode, c ...@@ -1448,15 +1534,24 @@ replaceNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode, c
**示例:** **示例:**
```ts ```ts
let router = uiContext.getRouter(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
router.replaceNamedRoute({ import { BusinessError } from '@ohos.base';
import router from '@ohos.router';
let routerF:Router = uiContext.getRouter();
class routerTmp{
Standard:router.RouterMode = router.RouterMode.Standard
}
let rtm:routerTmp = new routerTmp()
routerF.replaceNamedRoute({
name: 'myPage', name: 'myPage',
params: { params: {
data1: 'message' data1: 'message'
} }
}, router.RouterMode.Standard, (err: Error) => { }, rtm.Standard, (err: Error) => {
if (err) { if (err) {
console.error(`replaceNamedRoute failed, code is ${err.code}, message is ${err.message}`); let message = (err as BusinessError).message;
let code = (err as BusinessError).code;
console.error(`replaceNamedRoute failed, code is ${code}, message is ${message}`);
return; return;
} }
console.info('replaceNamedRoute success'); console.info('replaceNamedRoute success');
...@@ -1480,6 +1575,8 @@ back(options?: router.RouterOptions ): void ...@@ -1480,6 +1575,8 @@ back(options?: router.RouterOptions ): void
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router: Router = uiContext.getRouter(); let router: Router = uiContext.getRouter();
router.back({url:'pages/detail'}); router.back({url:'pages/detail'});
``` ```
...@@ -1495,6 +1592,8 @@ clear(): void ...@@ -1495,6 +1592,8 @@ clear(): void
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router: Router = uiContext.getRouter(); let router: Router = uiContext.getRouter();
router.clear(); router.clear();
``` ```
...@@ -1516,6 +1615,8 @@ getLength(): string ...@@ -1516,6 +1615,8 @@ getLength(): string
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router: Router = uiContext.getRouter(); let router: Router = uiContext.getRouter();
let size = router.getLength(); let size = router.getLength();
console.log('pages stack size = ' + size); console.log('pages stack size = ' + size);
...@@ -1538,6 +1639,8 @@ getState(): router.RouterState ...@@ -1538,6 +1639,8 @@ getState(): router.RouterState
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router: Router = uiContext.getRouter(); let router: Router = uiContext.getRouter();
let page = router.getState(); let page = router.getState();
console.log('current index = ' + page.index); console.log('current index = ' + page.index);
...@@ -1570,6 +1673,8 @@ showAlertBeforeBackPage(options: router.EnableAlertOptions): void ...@@ -1570,6 +1673,8 @@ showAlertBeforeBackPage(options: router.EnableAlertOptions): void
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router: Router = uiContext.getRouter(); let router: Router = uiContext.getRouter();
try { try {
router.showAlertBeforeBackPage({ router.showAlertBeforeBackPage({
...@@ -1593,6 +1698,8 @@ hideAlertBeforeBackPage(): void ...@@ -1593,6 +1698,8 @@ hideAlertBeforeBackPage(): void
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router: Router = uiContext.getRouter(); let router: Router = uiContext.getRouter();
router.hideAlertBeforeBackPage(); router.hideAlertBeforeBackPage();
``` ```
...@@ -1614,6 +1721,8 @@ getParams(): Object ...@@ -1614,6 +1721,8 @@ getParams(): Object
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let router: Router = uiContext.getRouter(); let router: Router = uiContext.getRouter();
router.getParams(); router.getParams();
``` ```
...@@ -1647,6 +1756,8 @@ showToast(options: promptAction.ShowToastOptions): void ...@@ -1647,6 +1756,8 @@ showToast(options: promptAction.ShowToastOptions): void
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let promptAction: PromptAction = uiContext.getPromptAction(); let promptAction: PromptAction = uiContext.getPromptAction();
try { try {
promptAction.showToast({ promptAction.showToast({
...@@ -1686,6 +1797,8 @@ showDialog(options: promptAction.ShowDialogOptions, callback: AsyncCallback&lt;p ...@@ -1686,6 +1797,8 @@ showDialog(options: promptAction.ShowDialogOptions, callback: AsyncCallback&lt;p
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
class buttonsMoabl { class buttonsMoabl {
text: string = "" text: string = ""
color: string = "" color: string = ""
...@@ -1713,7 +1826,9 @@ try { ...@@ -1713,7 +1826,9 @@ try {
console.info('showDialog success callback, click button: ' + data.index); console.info('showDialog success callback, click button: ' + data.index);
}); });
} catch (error) { } catch (error) {
console.error(`showDialog args error code is ${error.code}, message is ${error.message}`); let message = (error as BusinessError).message;
let code = (error as BusinessError).code;
console.error(`showDialog args error code is ${code}, message is ${message}`);
}; };
``` ```
...@@ -1748,6 +1863,8 @@ showDialog(options: promptAction.ShowDialogOptions): Promise&lt;promptAction.Sho ...@@ -1748,6 +1863,8 @@ showDialog(options: promptAction.ShowDialogOptions): Promise&lt;promptAction.Sho
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let promptAction: PromptAction = uiContext.getPromptAction(); let promptAction: PromptAction = uiContext.getPromptAction();
try { try {
promptAction.showDialog({ promptAction.showDialog({
...@@ -1803,27 +1920,40 @@ showActionMenu(options: promptAction.ActionMenuOptions, callback:promptAction.Ac ...@@ -1803,27 +1920,40 @@ showActionMenu(options: promptAction.ActionMenuOptions, callback:promptAction.Ac
**示例:** **示例:**
```ts ```ts
let promptAction: PromptAction = uiContext.getPromptAction(); import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import promptAction from '@ohos.promptAction';
import { BusinessError } from '@ohos.base';
class buttonsMoabl {
text: string = ""
color: string = ""
}
class dataR{
err:Error = new Error;
data:promptAction.ActionMenuSuccessResponse | undefined = undefined;
}
let dataAMSR:dataR = new dataR()
let promptActionF: PromptAction = uiContext.getPromptAction();
try { try {
promptAction.showActionMenu({ if(dataAMSR.data){
title: 'Title Info', promptActionF.showActionMenu({
buttons: [ title: 'Title Info',
{ buttons: [
text: 'item1', {
color: '#666666' text: 'item1',
}, color: '#666666'
{ } as buttonsMoabl,
text: 'item2', {
color: '#000000' text: 'item2',
}, color: '#000000'
] } as buttonsMoabl
}, (err:Error, data:promptAction.ActionMenuSuccessResponse) => { ]
if (err) { }, (dataAMSR.data))
console.info('showActionMenu err: ' + err); if (dataAMSR.err) {
return; console.info('showActionMenu err: ' + dataAMSR.err);
}else{
console.info('showActionMenu success callback, click button: ' + dataAMSR.data.index);
} }
console.info('showActionMenu success callback, click button: ' + data.index); }
})
} catch (error) { } catch (error) {
let message = (error as BusinessError).message; let message = (error as BusinessError).message;
let code = (error as BusinessError).code; let code = (error as BusinessError).code;
...@@ -1862,6 +1992,8 @@ showActionMenu(options: promptAction.ActionMenuOptions): Promise&lt;promptAction ...@@ -1862,6 +1992,8 @@ showActionMenu(options: promptAction.ActionMenuOptions): Promise&lt;promptAction
**示例:** **示例:**
```ts ```ts
import { ComponentUtils, Font, PromptAction, Router, UIInspector, MediaQuery } from '@ohos.arkui.UIContext';
import { BusinessError } from '@ohos.base';
let promptAction: PromptAction = uiContext.getPromptAction(); let promptAction: PromptAction = uiContext.getPromptAction();
try { try {
promptAction.showActionMenu({ promptAction.showActionMenu({
...@@ -1888,4 +2020,4 @@ try { ...@@ -1888,4 +2020,4 @@ try {
let code = (error as BusinessError).code; let code = (error as BusinessError).code;
console.error(`showActionMenu args error code is ${code}, message is ${message}`); console.error(`showActionMenu args error code is ${code}, message is ${message}`);
}; };
``` ```
\ No newline at end of file
...@@ -203,7 +203,7 @@ struct OffscreenSnapshotExample { ...@@ -203,7 +203,7 @@ struct OffscreenSnapshotExample {
Column() { Column() {
Button("click to generate offscreen UI snapshot") Button("click to generate offscreen UI snapshot")
.onClick(() => { .onClick(() => {
componentSnapshot.createFromBuilder(this.RandomBuilder.bind(this), componentSnapshot.createFromBuilder(this.RandomBuilder(),
(error: Error, pixmap: image.PixelMap) => { (error: Error, pixmap: image.PixelMap) => {
this.pixmap = pixmap this.pixmap = pixmap
// save pixmap to file // save pixmap to file
...@@ -280,7 +280,7 @@ struct OffscreenSnapshotExample { ...@@ -280,7 +280,7 @@ struct OffscreenSnapshotExample {
Column() { Column() {
Button("click to generate offscreen UI snapshot") Button("click to generate offscreen UI snapshot")
.onClick(() => { .onClick(() => {
componentSnapshot.createFromBuilder(this.RandomBuilder.bind(this)) componentSnapshot.createFromBuilder(this.RandomBuilder())
.then((pixmap: image.PixelMap) => { .then((pixmap: image.PixelMap) => {
this.pixmap = pixmap this.pixmap = pixmap
// save pixmap to file // save pixmap to file
......
...@@ -37,7 +37,7 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo, callback: ...@@ -37,7 +37,7 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo, callback:
```ts ```ts
import dragController from "@ohos.arkui.dragController" import dragController from "@ohos.arkui.dragController"
import UDC from '@ohos.data.unifiedDataChannel'; import UDMF from '@ohos.data.unifiedDataChannel';
@Entry @Entry
@Component @Component
...@@ -57,18 +57,23 @@ struct DragControllerPage { ...@@ -57,18 +57,23 @@ struct DragControllerPage {
.onTouch((event?:TouchEvent) => { .onTouch((event?:TouchEvent) => {
if(event){ if(event){
if (event.type == TouchType.Down) { if (event.type == TouchType.Down) {
let text:object = new UDMF.Text() let text = new UDMF.Text()
let unifiedData:object = new UDMF.UnifiedData(text) let unifiedData = new UDMF.UnifiedData(text)
let dragInfo: dragController.DragInfo = { let dragInfo: dragController.DragInfo = {
pointerId: 0, pointerId: 0,
data: unifiedData, data: unifiedData,
extraParams: '' extraParams: ''
} }
dragController.executeDrag(this.DraggingBuilder.bind(this), dragInfo, (err, {event, extraParams}) => { class tmp{
if (event.getResult() == DragResult.DRAG_SUCCESSFUL) { 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.event.getResult() == DragResult.DRAG_FAILED) {
// ... // ...
} }
}) })
...@@ -107,7 +112,7 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo): Promise&l ...@@ -107,7 +112,7 @@ executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo): Promise&l
import dragController from "@ohos.arkui.dragController" import dragController from "@ohos.arkui.dragController"
import componentSnapshot from '@ohos.arkui.componentSnapshot'; import componentSnapshot from '@ohos.arkui.componentSnapshot';
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
import UDC from '@ohos.data.unifiedDataChannel'; import UDMF from '@ohos.data.unifiedDataChannel';
@Entry @Entry
@Component @Component
...@@ -138,31 +143,36 @@ struct DragControllerPage { ...@@ -138,31 +143,36 @@ struct DragControllerPage {
.onTouch((event?:TouchEvent) => { .onTouch((event?:TouchEvent) => {
if(event){ if(event){
if (event.type == TouchType.Down) { if (event.type == TouchType.Down) {
let text:object = new UDMF.Text() let text = new UDMF.Text()
let unifiedData:object = new UDMF.UnifiedData(text) let unifiedData = new UDMF.UnifiedData(text)
let dragInfo: dragController.DragInfo = { let dragInfo: dragController.DragInfo = {
pointerId: 0, pointerId: 0,
data: unifiedData, data: unifiedData,
extraParams: '' extraParams: ''
} }
componentSnapshot.createFromBuilder(this.PixmapBuilder.bind(this)).then((pix: image.PixelMap) => { componentSnapshot.createFromBuilder(this.PixmapBuilder()).then((pix: image.PixelMap) => {
this.pixmap = pix; this.pixmap = pix;
let dragItemInfo: DragItemInfo = { let dragItemInfo: DragItemInfo = {
pixelMap: this.pixmap, pixelMap: this.pixmap,
builder: this.DraggingBuilder.bind(this), builder: this.DraggingBuilder(),
extraInfo: "DragItemInfoTest" extraInfo: "DragItemInfoTest"
} }
class tmp{
event:DragResult|undefined = undefined
extraParams:string = ''
}
let eve:tmp = new tmp()
dragController.executeDrag(dragItemInfo, dragInfo) dragController.executeDrag(dragItemInfo, dragInfo)
.then(({event, extraParams}) => { .then((eve) => {
if (event.getResult() == DragResult.DRAG_SUCCESSFUL) { if (eve.event.getResult() == DragResult.DRAG_SUCCESSFUL) {
// ... // ...
} else if (event.getResult() == DragResult.DRAG_FAILED) { } else if (eve.event.getResult() == DragResult.DRAG_FAILED) {
// ... // ...
} }
}) })
.catch((err) => { .catch((err:Error) => {
}) })
}) })
} }
......
...@@ -80,10 +80,11 @@ getPixelMap(): image.PixelMap; ...@@ -80,10 +80,11 @@ getPixelMap(): image.PixelMap;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let pixmap: DrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let pixmap: DrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as DrawableDescriptor; .id)) as DrawableDescriptor;
let pixmapNew: DrawableDescriptor = pixmap.getPixelMap() let pixmapNew: object = pixmap.getPixelMap()
``` ```
## LayeredDrawableDescriptor.getPixelMap ## LayeredDrawableDescriptor.getPixelMap
...@@ -101,10 +102,11 @@ getPixelMap(): image.PixelMap; ...@@ -101,10 +102,11 @@ getPixelMap(): image.PixelMap;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let pixmap: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let pixmap: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as LayeredDrawableDescriptor; .id)) as LayeredDrawableDescriptor;
let pixmapNew: LayeredDrawableDescriptor = pixmap.getPixelMap() let pixmapNew: object = pixmap.getPixelMap()
``` ```
## LayeredDrawableDescriptor.getForeground ## LayeredDrawableDescriptor.getForeground
...@@ -122,10 +124,11 @@ getForeground(): DrawableDescriptor; ...@@ -122,10 +124,11 @@ getForeground(): DrawableDescriptor;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as LayeredDrawableDescriptor; .id)) as LayeredDrawableDescriptor;
let drawableNew: LayeredDrawableDescriptor =drawable.getForeground() let drawableNew: object =drawable.getForeground()
``` ```
## LayeredDrawableDescriptor.getBackground ## LayeredDrawableDescriptor.getBackground
...@@ -143,10 +146,11 @@ getBackground(): DrawableDescriptor; ...@@ -143,10 +146,11 @@ getBackground(): DrawableDescriptor;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as LayeredDrawableDescriptor; .id)) as LayeredDrawableDescriptor;
let drawableNew: LayeredDrawableDescriptor =drawable.getBackground() let drawableNew: object =drawable.getBackground()
``` ```
## LayeredDrawableDescriptor.getMask ## LayeredDrawableDescriptor.getMask
...@@ -164,10 +168,11 @@ getMask(): DrawableDescriptor; ...@@ -164,10 +168,11 @@ getMask(): DrawableDescriptor;
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
let resManager = getContext().resourceManager let resManager = getContext().resourceManager
let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon') let drawable: LayeredDrawableDescriptor = (resManager.getDrawableDescriptor($r('app.media.icon')
.id)) as LayeredDrawableDescriptor; .id)) as LayeredDrawableDescriptor;
let drawableNew: LayeredDrawableDescriptor =drawable.getMask() let drawableNew: object =drawable.getMask()
``` ```
## LayeredDrawableDescriptor.getMaskClipPath ## LayeredDrawableDescriptor.getMaskClipPath
static getMaskClipPath(): string static getMaskClipPath(): string
...@@ -184,6 +189,7 @@ LayeredDrawableDescriptor的静态方法,获取系统内置的裁切路径参 ...@@ -184,6 +189,7 @@ LayeredDrawableDescriptor的静态方法,获取系统内置的裁切路径参
**示例:** **示例:**
```ts ```ts
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
Image($r('app.media.icon')) Image($r('app.media.icon'))
.width('200px').height('200px') .width('200px').height('200px')
.clip(new Path({commands:LayeredDrawableDescriptor.getMaskClipPath()})) .clip(new Path({commands:LayeredDrawableDescriptor.getMaskClipPath()}))
......
...@@ -129,19 +129,17 @@ off(type: 'draw', callback?: () => void): void ...@@ -129,19 +129,17 @@ off(type: 'draw', callback?: () => void): void
listener:inspector.ComponentObserver = inspector.createComponentObserver('IMAGE_ID') listener:inspector.ComponentObserver = inspector.createComponentObserver('IMAGE_ID')
aboutToAppear() { aboutToAppear() {
let FuncLayout = this.onLayoutComplete.bind(this) // bind current js instance let onLayoutComplete:()=>void=():void=>{
let FuncDraw = this.onDrawComplete.bind(this) // bind current js instance // 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('layout', FuncLayout)
this.listener.on('draw', FuncDraw) this.listener.on('draw', FuncDraw)
} }
onLayoutComplete() {
// do something here
}
onDrawComplete() {
// do something here
}
} }
``` ```
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
```ts ```ts
import app from '@system.app' import app, { AppResponse } from '@system.app'
``` ```
## App ## App
...@@ -33,9 +33,10 @@ static getInfo(): AppResponse ...@@ -33,9 +33,10 @@ static getInfo(): AppResponse
**示例:** **示例:**
```ts ```ts
export default { import app, { AppResponse } from '@system.app'
export default class Info {
getInfo() { getInfo() {
let info = app.getInfo() let info:AppResponse = app.getInfo()
console.log(JSON.stringify(info)) console.log(JSON.stringify(info))
} }
} }
...@@ -54,7 +55,8 @@ static terminate(): void ...@@ -54,7 +55,8 @@ static terminate(): void
**示例:** **示例:**
```ts ```ts
export default { import app, { AppResponse } from '@system.app'
export default class TerM {
terminate() { terminate() {
app.terminate() app.terminate()
} }
...@@ -78,9 +80,9 @@ static setImageCacheCount(value: number): void ...@@ -78,9 +80,9 @@ static setImageCacheCount(value: number): void
```ts ```ts
// app.ets // app.ets
import app from '@system.app' import app, { AppResponse } from '@system.app'
export default { export default class OnC {
onCreate() { onCreate() {
app.setImageCacheCount(100) // 设置解码后图片内存缓存上限为100张 app.setImageCacheCount(100) // 设置解码后图片内存缓存上限为100张
console.info('Application onCreate') console.info('Application onCreate')
...@@ -109,9 +111,9 @@ static setImageRawDataCacheSize(value: number): void ...@@ -109,9 +111,9 @@ static setImageRawDataCacheSize(value: number): void
```ts ```ts
// app.ets // app.ets
import app from '@system.app' import app, { AppResponse } from '@system.app'
export default { export default class OnC {
onCreate() { onCreate() {
app.setImageRawDataCacheSize(104857600) app.setImageRawDataCacheSize(104857600)
// 设置解码前图片数据内存缓存上限为100MB (100MB=100*1024*1024B=104857600B) // 设置解码前图片数据内存缓存上限为100MB (100MB=100*1024*1024B=104857600B)
...@@ -141,9 +143,9 @@ static setImageFileCacheSize(value: number): void ...@@ -141,9 +143,9 @@ static setImageFileCacheSize(value: number): void
```ts ```ts
// app.ets // app.ets
import app from '@system.app' import app, { AppResponse } from '@system.app'
export default { export default class OnC {
onCreate() { onCreate() {
app.setImageFileCacheSize(209715200) app.setImageFileCacheSize(209715200)
// 设置图片文件数据缓存上限为200MB (200MB=200*1024*1024B=209715200B) // 设置图片文件数据缓存上限为200MB (200MB=200*1024*1024B=209715200B)
...@@ -188,13 +190,14 @@ static requestFullWindow(options?: RequestFullWindowOptions): void ...@@ -188,13 +190,14 @@ static requestFullWindow(options?: RequestFullWindowOptions): void
**示例:** **示例:**
```ts ```ts
export default { import app, { AppResponse } from '@system.app'
export default class Req {
requestFullWindow() { requestFullWindow() {
app.requestFullWindow({ app.requestFullWindow({
duration: 200 duration: 200
}) })
} }
} }
``` ```
## AppResponse ## AppResponse
......
...@@ -57,6 +57,8 @@ setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void ...@@ -57,6 +57,8 @@ setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```ts ```ts
import uiAppearance from '@ohos.uiAppearance'
import { BusinessError } from '@ohos.base';
try { try {
uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (error) => { uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (error) => {
if (error) { if (error) {
...@@ -105,10 +107,12 @@ setDarkMode(mode: DarkMode): Promise\<void>; ...@@ -105,10 +107,12 @@ setDarkMode(mode: DarkMode): Promise\<void>;
**示例:** **示例:**
```ts ```ts
import uiAppearance from '@ohos.uiAppearance'
import { BusinessError } from '@ohos.base';
try { try {
uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => { uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => {
console.info('Set dark-mode successfully.'); console.info('Set dark-mode successfully.');
}).catch((error) => { }).catch((error:Error) => {
console.error('Set dark-mode failed, ' + error.message); console.error('Set dark-mode failed, ' + error.message);
}); });
} catch (error) { } catch (error) {
...@@ -145,9 +149,11 @@ getDarkMode(): DarkMode; ...@@ -145,9 +149,11 @@ getDarkMode(): DarkMode;
**示例:** **示例:**
```ts ```ts
import uiAppearance from '@ohos.uiAppearance'
import { BusinessError } from '@ohos.base';
try { try {
let darkMode = uiAppearance.getDarkMode(); let darkMode = uiAppearance.getDarkMode();
console.info('Get dark-mode ' + mode); console.info('Get dark-mode ' + darkMode);
} catch (error) { } catch (error) {
let message = (error as BusinessError).message; let message = (error as BusinessError).message;
console.error('Get dark-mode failed, ' + 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.
先完成此消息的编辑!
想要评论请 注册