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

!7943 【轻量级 PR】:update zh-cn/application-dev/reference/apis/js-apis-window.md.

Merge pull request !7943 from 葛亚芳/N/A
...@@ -302,13 +302,14 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi ...@@ -302,13 +302,14 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi
```js ```js
var windowClass = null; var windowClass = null;
let promise = window.create("first", window.WindowType.TYPE_APP); window.create("first", window.WindowType.TYPE_APP,(err,data) => {
promise.then((data)=> { if(err.code){
windowClass = data; console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
console.info('SubWindow created. Data: ' + JSON.stringify(data)); return;
}).catch((err)=>{ }
console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); windowClass = data;
}); console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
});
``` ```
## window.create<sup>7+</sup> ## window.create<sup>7+</sup>
...@@ -341,7 +342,7 @@ var windowClass = null; ...@@ -341,7 +342,7 @@ var windowClass = null;
let promise = window.create("first", window.WindowType.TYPE_APP); let promise = window.create("first", window.WindowType.TYPE_APP);
promise.then((data)=> { promise.then((data)=> {
windowClass = data; windowClass = data;
console.info('SubWindow created. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the subWindow. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err));
}); });
...@@ -372,11 +373,11 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Wi ...@@ -372,11 +373,11 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Wi
var windowClass = null; var windowClass = null;
window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return; return;
} }
windowClass = data; windowClass = data;
console.info('Window created. Data: ' + JSON.stringify(data)); console.info('Succeeded in creating the window. Data: ' + JSON.stringify(data));
windowClass.resetSize(500, 1000); windowClass.resetSize(500, 1000);
}); });
``` ```
...@@ -411,8 +412,8 @@ create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt; ...@@ -411,8 +412,8 @@ create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt;
var windowClass = null; var windowClass = null;
let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT);
promise.then((data)=> { promise.then((data)=> {
windowClass = data; windowClass = data;
console.info('Window created. Data:' + JSON.stringify(data)); console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to create the Window. Cause:' + JSON.stringify(err)); console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
}); });
...@@ -443,7 +444,7 @@ var windowClass = null; ...@@ -443,7 +444,7 @@ var windowClass = null;
return; return;
} }
windowClass = data; windowClass = data;
console.info('window found. Data: ' + JSON.stringify(data)); console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
}); });
``` ```
...@@ -474,7 +475,7 @@ var windowClass = null; ...@@ -474,7 +475,7 @@ var windowClass = null;
let promise = window.find("alertWindow"); let promise = window.find("alertWindow");
promise.then((data)=> { promise.then((data)=> {
windowClass = data; windowClass = data;
console.info('window found. Data: ' + JSON.stringify(data)); console.info('Succeeded in finding the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
}); });
...@@ -868,7 +869,7 @@ windowClass.hide((err, data) => { ...@@ -868,7 +869,7 @@ windowClass.hide((err, data) => {
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('window hidden. data: ' + JSON.stringify(data)); console.info('Succeeded in hiding the window. data: ' + JSON.stringify(data));
}) })
``` ```
...@@ -893,7 +894,7 @@ hide(): Promise&lt;void&gt; ...@@ -893,7 +894,7 @@ hide(): Promise&lt;void&gt;
```js ```js
let promise = windowClass.hide(); let promise = windowClass.hide();
promise.then((data)=> { promise.then((data)=> {
console.info('window hidden. Data: ' + JSON.stringify(data)); console.info('Succeeded in hiding the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
}) })
...@@ -923,7 +924,7 @@ windowClass.hideWithAnimation((err, data) => { ...@@ -923,7 +924,7 @@ windowClass.hideWithAnimation((err, data) => {
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
return; return;
} }
console.info('window hidden with animation. data: ' + JSON.stringify(data)); console.info('Succeeded in hiding the window with animation. data: ' + JSON.stringify(data));
}) })
``` ```
...@@ -948,7 +949,7 @@ hideWithAnimation(): Promise&lt;void&gt; ...@@ -948,7 +949,7 @@ hideWithAnimation(): Promise&lt;void&gt;
```js ```js
let promise = windowClass.hideWithAnimation(); let promise = windowClass.hideWithAnimation();
promise.then((data)=> { promise.then((data)=> {
console.info('window hidden with animation. Data: ' + JSON.stringify(data)); console.info('Succeeded in hiding the window with animation. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
}) })
...@@ -1135,7 +1136,7 @@ windowClass.moveTo(300, 300, (err, data)=>{ ...@@ -1135,7 +1136,7 @@ windowClass.moveTo(300, 300, (err, data)=>{
console.error('Failed to move the window. Cause:' + JSON.stringify(err)); console.error('Failed to move the window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Window moved. Data: ' + JSON.stringify(data)); console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
}); });
``` ```
...@@ -1166,7 +1167,7 @@ moveTo(x: number, y: number): Promise&lt;void&gt; ...@@ -1166,7 +1167,7 @@ moveTo(x: number, y: number): Promise&lt;void&gt;
```js ```js
let promise = windowClass.moveTo(300, 300); let promise = windowClass.moveTo(300, 300);
promise.then((data)=> { promise.then((data)=> {
console.info('Window moved. Data: ' + JSON.stringify(data)); console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); console.error('Failed to move the window. Cause: ' + JSON.stringify(err));
}) })
...@@ -1196,7 +1197,7 @@ windowClass.resetSize(500, 1000, (err, data) => { ...@@ -1196,7 +1197,7 @@ windowClass.resetSize(500, 1000, (err, data) => {
console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); console.error('Failed to change the window size. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Window size changed. Data: ' + JSON.stringify(data)); console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
}); });
``` ```
...@@ -1226,7 +1227,7 @@ resetSize(width: number, height: number): Promise&lt;void&gt; ...@@ -1226,7 +1227,7 @@ resetSize(width: number, height: number): Promise&lt;void&gt;
```js ```js
let promise = windowClass.resetSize(500, 1000); let promise = windowClass.resetSize(500, 1000);
promise.then((data)=> { promise.then((data)=> {
console.info('Window size changed. Data: ' + JSON.stringify(data)); console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data));
}).catch((err)=>{ }).catch((err)=>{
console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); console.error('Failed to change the window size. Cause: ' + JSON.stringify(err));
}); });
...@@ -2583,7 +2584,7 @@ setWakeUpScreen(wakeUp: boolean): void; ...@@ -2583,7 +2584,7 @@ setWakeUpScreen(wakeUp: boolean): void;
**示例:** **示例:**
```ts ```js
var wakeUp = true; var wakeUp = true;
windowClass.setWakeUpScreen(wakeUp); windowClass.setWakeUpScreen(wakeUp);
``` ```
...@@ -3290,9 +3291,8 @@ opacity(opacity: number): void ...@@ -3290,9 +3291,8 @@ opacity(opacity: number): void
**示例:** **示例:**
```ts ```js
windowClass.opacity(0.5); windowClass.opacity(0.5);
console.log('set window opacity end');
``` ```
### scale<sup>9+</sup> ### scale<sup>9+</sup>
...@@ -3313,14 +3313,13 @@ scale(scaleOptions: ScaleOptions): void ...@@ -3313,14 +3313,13 @@ scale(scaleOptions: ScaleOptions): void
**示例:** **示例:**
```ts ```js
var obj : window.ScaleOptions; var obj : window.ScaleOptions;
obj.x = 2.0; obj.x = 2.0;
obj.y = 1.0; obj.y = 1.0;
obj.pivotX = 0.5; obj.pivotX = 0.5;
obj.pivotY = 0.5; obj.pivotY = 0.5;
windowClass.scale(obj); windowClass.scale(obj);
console.log('set window scale end');
``` ```
### rotate<sup>9+</sup> ### rotate<sup>9+</sup>
...@@ -3341,7 +3340,7 @@ rotate(rotateOptions: RotateOptions): void ...@@ -3341,7 +3340,7 @@ rotate(rotateOptions: RotateOptions): void
**示例:** **示例:**
```ts ```js
var obj : window.RotateOptions; var obj : window.RotateOptions;
obj.x = 1.0; obj.x = 1.0;
obj.y = 1.0; obj.y = 1.0;
...@@ -3349,7 +3348,6 @@ obj.z = 45.0; ...@@ -3349,7 +3348,6 @@ obj.z = 45.0;
obj.pivotX = 0.5; obj.pivotX = 0.5;
obj.pivotY = 0.5; obj.pivotY = 0.5;
windowClass.rotate(obj); windowClass.rotate(obj);
console.log('set window rotate end');
``` ```
### translate<sup>9+</sup> ### translate<sup>9+</sup>
...@@ -3370,13 +3368,12 @@ translate(translateOptions: TranslateOptions): void ...@@ -3370,13 +3368,12 @@ translate(translateOptions: TranslateOptions): void
**示例:** **示例:**
```ts ```js
var obj : window.TranslateOptions; var obj : window.TranslateOptions;
obj.x = 100.0; obj.x = 100.0;
obj.y = 0.0; obj.y = 0.0;
obj.z = 0.0; obj.z = 0.0;
windowClass.translate(obj); windowClass.translate(obj);
console.log('set window translate end');
``` ```
### getTransitionController<sup>9+</sup> ### getTransitionController<sup>9+</sup>
...@@ -3397,7 +3394,7 @@ console.log('set window translate end'); ...@@ -3397,7 +3394,7 @@ console.log('set window translate end');
**示例:** **示例:**
```ts ```js
let controller = windowClass.getTransitionController(); // 获取属性转换控制器 let controller = windowClass.getTransitionController(); // 获取属性转换控制器
controller.animationForHidden = (context : window.TransitionContext) => { controller.animationForHidden = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow
...@@ -3927,7 +3924,7 @@ completeTransition(isCompleted: boolean): void ...@@ -3927,7 +3924,7 @@ completeTransition(isCompleted: boolean): void
**示例:** **示例:**
```ts ```js
let controller = windowClass.getTransitionController(); let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => { controller.animationForShown = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow
...@@ -3974,7 +3971,7 @@ animationForShown(context: TransitionContext): void ...@@ -3974,7 +3971,7 @@ animationForShown(context: TransitionContext): void
**示例:** **示例:**
```ts ```js
let controller = windowClass.getTransitionController(); let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => { controller.animationForShown = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow
...@@ -4015,7 +4012,7 @@ animationForHidden(context: TransitionContext): void ...@@ -4015,7 +4012,7 @@ animationForHidden(context: TransitionContext): void
**示例:** **示例:**
```ts ```js
let controller = windowClass.getTransitionController(); let controller = windowClass.getTransitionController();
controller.animationForHidden = (context : window.TransitionContext) => { controller.animationForHidden = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow
...@@ -4038,5 +4035,4 @@ controller.animationForHidden = (context : window.TransitionContext) => { ...@@ -4038,5 +4035,4 @@ controller.animationForHidden = (context : window.TransitionContext) => {
context.completeTransition(true) context.completeTransition(true)
console.info('complete transition end'); console.info('complete transition end');
} }
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册