已合并
生命周期sample修改 #11007
生命周期sample修改 #11007
已合并
nicholaszc创建于 8 天前
2 个文件变更+27-27
@@ -27,11 +27,11 @@ struct DialogWindow {
27 return;27 return;
28 }28 }
29 // [Start destroy_dialog_window]29 // [Start destroy_dialog_window]
30- // 4.销毁窗口。当不再需要窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。30+ // 4.销毁模态窗口。当不再需要模态窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。
31 dialogWindowClass.destroyWindow((err: BusinessError) => {31 dialogWindowClass.destroyWindow((err: BusinessError) => {
32 let errCode: number = err.code;32 let errCode: number = err.code;
33 if (errCode) {33 if (errCode) {
34- console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));34+ console.error(`Failed to destroy the window. Cause code: ${err.code}, message: ${err.message}`);
35 return;35 return;
36 }36 }
37 console.info('Succeeded in destroying the window.');37 console.info('Succeeded in destroying the window.');
@@ -49,7 +49,7 @@ struct Index {
49 // 1.使用createSubWindow接口创建子窗49 // 1.使用createSubWindow接口创建子窗
50 windowStage_.createSubWindow('SubWindow', (err, data) => {50 windowStage_.createSubWindow('SubWindow', (err, data) => {
51 if (err?.code) {51 if (err?.code) {
52- console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err));52+ console.error(`Failed to create the subwindow. Cause code: ${err.code}, message: ${err.message}`);
53 }53 }
54 subWindowClass = data;54 subWindowClass = data;
55 if (!subWindowClass) {55 if (!subWindowClass) {
@@ -62,7 +62,7 @@ struct Index {
62 // 2.子窗口创建成功后,设置子窗口的位置、大小及相关属性等。62 // 2.子窗口创建成功后,设置子窗口的位置、大小及相关属性等。
63 subWindowClass.moveWindowTo(100, 100, (err) => {63 subWindowClass.moveWindowTo(100, 100, (err) => {
64 if (err?.code) {64 if (err?.code) {
65- console.error('Failed to move the window. Cause:' + JSON.stringify(err));65+ console.error(`Failed to move the window. Cause code: ${err.code}, message: ${err.message}`);
66 return;66 return;
67 }67 }
68 console.info('Succeeded in moving the window.');68 console.info('Succeeded in moving the window.');
@@ -72,7 +72,7 @@ struct Index {
72 }72 }
73 subWindowClass.resize(600, 600, (err) => {73 subWindowClass.resize(600, 600, (err) => {
74 if (err?.code) {74 if (err?.code) {
75- console.error('Failed to change the window size. Cause:' + JSON.stringify(err));75+ console.error(`Failed to change the window size. Cause code: ${err.code}, message: ${err.message}`);
76 return;76 return;
77 }77 }
78 console.info('Succeeded in changing the window size.');78 console.info('Succeeded in changing the window size.');
@@ -81,7 +81,7 @@ struct Index {
81 // 3.为子窗口加载对应的目标页面。81 // 3.为子窗口加载对应的目标页面。
82 subWindowClass.setUIContent('pages/SubWindow', (err) => {82 subWindowClass.setUIContent('pages/SubWindow', (err) => {
83 if (err?.code) {83 if (err?.code) {
84- console.error('Failed to load the content. Cause:' + JSON.stringify(err));84+ console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`);
85 return;85 return;
86 }86 }
87 console.info('Succeeded in loading the content.');87 console.info('Succeeded in loading the content.');
@@ -92,7 +92,7 @@ struct Index {
92 // 显示子窗口。92 // 显示子窗口。
93 subWindowClass.showWindow((err) => {93 subWindowClass.showWindow((err) => {
94 if (err?.code) {94 if (err?.code) {
95- console.error('Failed to show the window. Cause: ' + JSON.stringify(err));95+ console.error(`Failed to show the window. Cause code: ${err.code}, message: ${err.message}`);
96 return;96 return;
97 }97 }
98 console.info('Succeeded in showing the window.');98 console.info('Succeeded in showing the window.');
@@ -101,8 +101,8 @@ struct Index {
101 // [End subWindow_uiContent]101 // [End subWindow_uiContent]
102 // [EndExclude create_subWindow]102 // [EndExclude create_subWindow]
103 })103 })
104- // [End create_subWindow]
105 }104 }
105+ // [End create_subWindow]
106 } catch(e) {106 } catch(e) {
107 console.error('TAG', `OnCreateSubWindowWithOptions failed ${JSON.stringify(e)}`);107 console.error('TAG', `OnCreateSubWindowWithOptions failed ${JSON.stringify(e)}`);
108 }108 }
@@ -116,7 +116,7 @@ struct Index {
116 // 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。116 // 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。
117 subWindowClass.destroyWindow((err) => {117 subWindowClass.destroyWindow((err) => {
118 if (err?.code) {118 if (err?.code) {
119- console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));119+ console.error(`Failed to destroy the window. Cause code: ${err.code}, message: ${err.message}`);
120 return;120 return;
121 }121 }
122 console.info('Succeeded in destroying the window.');122 console.info('Succeeded in destroying the window.');
@@ -153,7 +153,7 @@ struct Index {
153 // 2.子窗口创建成功后,设置子窗口的位置、大小及相关属性等。153 // 2.子窗口创建成功后,设置子窗口的位置、大小及相关属性等。
154 independentWindowClass.moveWindowTo(100, 100, (err) => {154 independentWindowClass.moveWindowTo(100, 100, (err) => {
155 if (err?.code) {155 if (err?.code) {
156- console.error('Failed to move the window. Cause:' + JSON.stringify(err));156+ console.error(`Failed to move the window. Cause code: ${err.code}, message: ${err.message}`);
157 return;157 return;
158 }158 }
159 console.info('Succeeded in moving the window.');159 console.info('Succeeded in moving the window.');
@@ -163,7 +163,7 @@ struct Index {
163 }163 }
164 independentWindowClass.resize(1000, 500, (err) => {164 independentWindowClass.resize(1000, 500, (err) => {
165 if (err?.code) {165 if (err?.code) {
166- console.error('Failed to change the window size. Cause:' + JSON.stringify(err));166+ console.error(`Failed to change the window size. Cause code: ${err.code}, message: ${err.message}`);
167 return;167 return;
168 }168 }
169 console.info('Succeeded in changing the window size.');169 console.info('Succeeded in changing the window size.');
@@ -174,7 +174,7 @@ struct Index {
174 // 3.为子窗口加载对应的目标页面。174 // 3.为子窗口加载对应的目标页面。
175 independentWindowClass.setUIContent('pages/IndependentSubWindow', (err) => {175 independentWindowClass.setUIContent('pages/IndependentSubWindow', (err) => {
176 if (err?.code) {176 if (err?.code) {
177- console.error('Failed to load the content. Cause:' + JSON.stringify(err));177+ console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`);
178 return;178 return;
179 }179 }
180 console.info('Succeeded in loading the content.');180 console.info('Succeeded in loading the content.');
@@ -185,14 +185,14 @@ struct Index {
185 // 显示子窗口。185 // 显示子窗口。
186 independentWindowClass.showWindow((err) => {186 independentWindowClass.showWindow((err) => {
187 if (err?.code) {187 if (err?.code) {
188- console.error('Failed to show the window. Cause: ' + JSON.stringify(err));188+ console.error(`Failed to show the window. Cause code: ${err.code}, message: ${err.message}`);
189 return;189 return;
190 }190 }
191 console.info('Succeeded in showing the window.');191 console.info('Succeeded in showing the window.');
192 });192 });
193- // [End independent_subWindow_uiContent]
194 // [EndExclude create_independent_subWindow]193 // [EndExclude create_independent_subWindow]
195 });194 });
195+ // [End independent_subWindow_uiContent]
196 // [End create_independent_subWindow]196 // [End create_independent_subWindow]
197 }).catch((err: Error) => {197 }).catch((err: Error) => {
198 let businessError = err as BusinessError;198 let businessError = err as BusinessError;
@@ -213,7 +213,7 @@ struct Index {
213 // 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。213 // 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。
214 independentWindowClass.destroyWindow((err) => {214 independentWindowClass.destroyWindow((err) => {
215 if (err?.code) {215 if (err?.code) {
216- console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));216+ console.error(`Failed to destroy the window. Cause code: ${err.code}, message: ${err.message}`);
217 return;217 return;
218 }218 }
219 console.info('Succeeded in destroying the window.');219 console.info('Succeeded in destroying the window.');
@@ -231,7 +231,7 @@ struct Index {
231 };231 };
232 window.createWindow(config, (err, data) => {232 window.createWindow(config, (err, data) => {
233 if (err?.code) {233 if (err?.code) {
234- console.error('Failed to create the floatWindow. Cause: ' + JSON.stringify(err));234+ console.error(`Failed to create the floatWindow. Cause code: ${err.code}, message: ${err.message}`);
235 return;235 return;
236 }236 }
237 floatWindowClass = data;237 floatWindowClass = data;
@@ -241,7 +241,7 @@ struct Index {
241 // 2.全局悬浮窗窗口创建成功后,设置全局悬浮窗的位置、大小及相关属性等。241 // 2.全局悬浮窗窗口创建成功后,设置全局悬浮窗的位置、大小及相关属性等。
242 floatWindowClass.moveWindowTo(100, 100, (err) => {242 floatWindowClass.moveWindowTo(100, 100, (err) => {
243 if (err?.code) {243 if (err?.code) {
244- console.error('Failed to move the window. Cause:' + JSON.stringify(err));244+ console.error(`Failed to move the window. Cause code: ${err.code}, message: ${err.message}`);
245 return;245 return;
246 }246 }
247 console.info('Succeeded in moving the window.');247 console.info('Succeeded in moving the window.');
@@ -251,7 +251,7 @@ struct Index {
251 }251 }
252 floatWindowClass.resize(600, 900, (err) => {252 floatWindowClass.resize(600, 900, (err) => {
253 if (err?.code) {253 if (err?.code) {
254- console.error('Failed to change the window size. Cause:' + JSON.stringify(err));254+ console.error(`Failed to change the window size. Cause code: ${err.code}, message: ${err.message}`);
255 return;255 return;
256 }256 }
257 console.info('Succeeded in changing the window size.');257 console.info('Succeeded in changing the window size.');
@@ -262,14 +262,14 @@ struct Index {
262 // 3.为全局悬浮窗加载对应的目标页面。262 // 3.为全局悬浮窗加载对应的目标页面。
263 floatWindowClass.setUIContent('pages/FloatWindow', (err) => {263 floatWindowClass.setUIContent('pages/FloatWindow', (err) => {
264 if (err?.code) {264 if (err?.code) {
265- console.error('Failed to load the content. Cause:' + JSON.stringify(err));265+ console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`);
266 return;266 return;
267 }267 }
268 console.info('Succeeded in loading the content.');268 console.info('Succeeded in loading the content.');
269 // 显示全局悬浮窗。269 // 显示全局悬浮窗。
270 (floatWindowClass as window.Window).showWindow((err) => {270 (floatWindowClass as window.Window).showWindow((err) => {
271 if (err?.code) {271 if (err?.code) {
272- console.error('Failed to show the window. Cause: ' + JSON.stringify(err));272+ console.error(`Failed to show the window. Cause code: ${err.code}, message: ${err.message}`);
273 return;273 return;
274 }274 }
275 console.info('Succeeded in showing the window.');275 console.info('Succeeded in showing the window.');
@@ -290,10 +290,10 @@ struct Index {
290 return;290 return;
291 }291 }
292 // [Start destroy_floating_window]292 // [Start destroy_floating_window]
293- // 4.销毁。当不再需要时,可根据具体实现逻辑,使用destroy对其进行销毁。293+ // 4.销毁全局悬浮窗。当不再需要全局悬浮窗时,可根据具体实现逻辑,使用destroy对其进行销毁。
294 floatWindowClass.destroyWindow((err) => {294 floatWindowClass.destroyWindow((err) => {
295 if (err?.code) {295 if (err?.code) {
296- console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err));296+ console.error(`Failed to destroy the window. Cause code: ${err.code}, message: ${err.message}`);
297 return;297 return;
298 }298 }
299 console.info('Succeeded in destroying the window.');299 console.info('Succeeded in destroying the window.');
@@ -311,7 +311,7 @@ struct Index {
311 };311 };
312 window.createWindow(config, (err, data) => {312 window.createWindow(config, (err, data) => {
313 if (err?.code) {313 if (err?.code) {
314- console.error('Failed to create the dialogWindow. Cause: ' + JSON.stringify(err));314+ console.error(`Failed to create the dialogWindow. Cause code: ${err.code}, message: ${err.message}`);
315 return;315 return;
316 }316 }
317 console.info('Succeeded in creating the dialogWindow. Data: ' + JSON.stringify(data));317 console.info('Succeeded in creating the dialogWindow. Data: ' + JSON.stringify(data));
@@ -321,7 +321,7 @@ struct Index {
321 // 2.模态窗口创建成功后,设置模态窗口的位置、大小及相关属性等。321 // 2.模态窗口创建成功后,设置模态窗口的位置、大小及相关属性等。
322 dialogWindowClass.moveWindowTo(100, 100, (err) => {322 dialogWindowClass.moveWindowTo(100, 100, (err) => {
323 if (err?.code) {323 if (err?.code) {
324- console.error('Failed to move the window. Cause:' + JSON.stringify(err));324+ console.error(`Failed to move the window. Cause code: ${err.code}, message: ${err.message}`);
325 return;325 return;
326 }326 }
327 console.info('Succeeded in moving the window.');327 console.info('Succeeded in moving the window.');
@@ -331,7 +331,7 @@ struct Index {
331 }331 }
332 dialogWindowClass.resize(500, 500, (err) => {332 dialogWindowClass.resize(500, 500, (err) => {
333 if (err?.code) {333 if (err?.code) {
334- console.error('Failed to change the window size. Cause:' + JSON.stringify(err));334+ console.error(`Failed to change the window size. Cause code: ${err.code}, message: ${err.message}`);
335 return;335 return;
336 }336 }
337 console.info('Succeeded in changing the window size.');337 console.info('Succeeded in changing the window size.');
@@ -342,14 +342,14 @@ struct Index {
342 // 3.为模态窗口加载对应的目标页面。342 // 3.为模态窗口加载对应的目标页面。
343 dialogWindowClass.setUIContent('pages/DialogWindow', (err) => {343 dialogWindowClass.setUIContent('pages/DialogWindow', (err) => {
344 if (err?.code) {344 if (err?.code) {
345- console.error('Failed to load the content. Cause:' + JSON.stringify(err));345+ console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`);
346 return;346 return;
347 }347 }
348 console.info('Succeeded in loading the content.');348 console.info('Succeeded in loading the content.');
349 // 显示模态窗口。349 // 显示模态窗口。
350 (dialogWindowClass as window.Window).showWindow((err) => {350 (dialogWindowClass as window.Window).showWindow((err) => {
351 if (err?.code) {351 if (err?.code) {
352- console.error('Failed to show the window. Cause: ' + JSON.stringify(err));352+ console.error(`Failed to show the window. Cause code: ${err.code}, message: ${err.message}`);
353 return;353 return;
354 }354 }
355 console.info('Succeeded in showing the window.');355 console.info('Succeeded in showing the window.');