From 40d15201108ddf27c742efc04bbd0326e9c36386 Mon Sep 17 00:00:00 2001
From: "1362134550@qq.com" <1362134550@qq.com>
Date: Thu, 31 Jul 2025 10:27:21 +0800
Subject: [PATCH 1/9] =?UTF-8?q?=E7=A2=B0=E4=B8=80=E7=A2=B0=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=88=86=E4=BA=AB=20=20=E5=9B=BE=E7=89=87=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 8121507..7c5d445 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,9 @@
### 效果图预览
-| 首页 |
-|-----------------------------------|
-|  |
+| 首页 |
+|----------------------------------------------------------------|
+|
|
**使用说明**
--
Gitee
From 64ea2e04c4d6908c0bd261db9afbb323b95381ae Mon Sep 17 00:00:00 2001
From: "1362134550@qq.com" <1362134550@qq.com>
Date: Thu, 31 Jul 2025 10:33:29 +0800
Subject: [PATCH 2/9] =?UTF-8?q?=E7=A2=B0=E4=B8=80=E7=A2=B0=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=88=86=E4=BA=AB=20=20=E5=9B=BE=E7=89=87=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7c5d445..33cc7c8 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
| 首页 |
|----------------------------------------------------------------|
-|
|
+|
|
**使用说明**
--
Gitee
From 92ffb9cb1abd33fa0afed0c14ebf6e36fa39cc58 Mon Sep 17 00:00:00 2001
From: "1362134550@qq.com" <1362134550@qq.com>
Date: Thu, 31 Jul 2025 10:40:01 +0800
Subject: [PATCH 3/9] =?UTF-8?q?=E7=A2=B0=E4=B8=80=E7=A2=B0=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=88=86=E4=BA=AB=20=20=E5=9B=BE=E7=89=87=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 33cc7c8..b2cbb19 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
| 首页 |
|----------------------------------------------------------------|
-|
|
+|
|
**使用说明**
--
Gitee
From d160d0bcb4d1aba98fa49ef79b0c4c12ffb74a55 Mon Sep 17 00:00:00 2001
From: "1362134550@qq.com" <1362134550@qq.com>
Date: Thu, 31 Jul 2025 10:50:27 +0800
Subject: [PATCH 4/9] =?UTF-8?q?=E7=A2=B0=E4=B8=80=E7=A2=B0=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=88=86=E4=BA=AB=20=20=E5=9B=BE=E7=89=87=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index b2cbb19..95b6222 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,9 @@
### 效果图预览
-| 首页 |
-|----------------------------------------------------------------|
-|
|
+| 首页 |
+|----------------------------------------------------|
+|
|
**使用说明**
--
Gitee
From aaeb56e288c6a0115537213b7d8f6a996c47f210 Mon Sep 17 00:00:00 2001
From: "1362134550@qq.com" <1362134550@qq.com>
Date: Tue, 12 Aug 2025 11:19:14 +0800
Subject: [PATCH 5/9] =?UTF-8?q?=E7=A2=B0=E4=B8=80=E7=A2=B0=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=88=86=E4=BA=AB=20=20=E8=AF=AD=E6=B3=95=E8=A1=A5?=
=?UTF-8?q?=E5=85=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
entry/src/main/ets/controller/KnockController.ets | 2 ++
1 file changed, 2 insertions(+)
diff --git a/entry/src/main/ets/controller/KnockController.ets b/entry/src/main/ets/controller/KnockController.ets
index b3dbcd8..f3fa384 100644
--- a/entry/src/main/ets/controller/KnockController.ets
+++ b/entry/src/main/ets/controller/KnockController.ets
@@ -177,6 +177,8 @@ export class KnockController {
}
} else if (record.uri.endsWith('png') || record.uri.endsWith('jpg') || record.uri.endsWith('jpeg')) {
thumbPath = record.uri;
+ } else {
+ thumbPath = videoDataList[0].thumbnail;
}
videoDataList.push({
--
Gitee
From 11b2bd3779fbed0bf51a550205eccacc05998e12 Mon Sep 17 00:00:00 2001
From: "1362134550@qq.com" <1362134550@qq.com>
Date: Tue, 9 Sep 2025 15:54:46 +0800
Subject: [PATCH 6/9] =?UTF-8?q?=E7=A2=B0=E4=B8=80=E7=A2=B0=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=88=86=E4=BA=AB=20=20=E5=BC=82=E5=B8=B8=E5=A4=84?=
=?UTF-8?q?=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../main/ets/controller/KnockController.ets | 18 ++++--
.../main/ets/entryability/EntryAbility.ets | 62 +++++++++++--------
entry/src/main/ets/pages/Index.ets | 24 +++++--
entry/src/main/ets/utils/FileUtil.ets | 16 ++---
4 files changed, 74 insertions(+), 46 deletions(-)
diff --git a/entry/src/main/ets/controller/KnockController.ets b/entry/src/main/ets/controller/KnockController.ets
index f3fa384..d0c6ac1 100644
--- a/entry/src/main/ets/controller/KnockController.ets
+++ b/entry/src/main/ets/controller/KnockController.ets
@@ -59,7 +59,11 @@ export class KnockController {
}
let shareData: systemShare.SharedData = new systemShare.SharedData(this.getShareRecord(videoDataList[fileShare[0]]));
for (let i = 1; i < fileShare.length; i++) {
- shareData.addRecord(this.getShareRecord(videoDataList[fileShare[i]]));
+ try {
+ shareData.addRecord(this.getShareRecord(videoDataList[fileShare[i]]));
+ } catch (e) {
+ hilog.error(0x0000, 'KnockFileShare', `addRecord failed ${JSON.stringify(e)}`);
+ }
}
target.share(shareData);
}
@@ -107,7 +111,9 @@ export class KnockController {
harmonyShare.on('knockShare', { windowId: mainWindowID }, (target: harmonyShare.SharableTarget) => {
this.immersiveCallback(target);
});
- })
+ }).catch((error: BusinessError) => {
+ hilog.error(0x0000, 'KnockFileShare', `getLastWindow failed ${JSON.stringify(error)}`);
+ });
}
}
@@ -128,7 +134,9 @@ export class KnockController {
window.getLastWindow(this.context).then((data) => {
let mainWindowID: number = data.getWindowProperties().id;
harmonyShare.off('knockShare', { windowId: mainWindowID });
- })
+ }).catch((error: BusinessError) => {
+ hilog.error(0x0000, 'KnockFileShare', `getLastWindow failed ${JSON.stringify(error)}`);
+ });
}
}
// [End FileShareListening]
@@ -201,7 +209,7 @@ export class KnockController {
});
})).catch((error: BusinessError) => {
hilog.error(0x0000, 'KnockFileShare', `failed to obtain the window. cause ${error.code} ${error.message}`);
- })
+ });
}
// [End dataReceive]
@@ -226,6 +234,6 @@ export class KnockController {
] });
})).catch((error: BusinessError) => {
hilog.error(0x0000, 'KnockFileShare', `failed to obtain the window. cause ${error.code} ${error.message}`);
- })
+ });
}
}
diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets
index bcc67d1..a9b9865 100644
--- a/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/entry/src/main/ets/entryability/EntryAbility.ets
@@ -26,21 +26,25 @@ export default class EntryAbility extends UIAbility {
private uiContext?: UIContext;
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
- this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
+ try {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ } catch (e) {
+ hilog.error(DOMAIN, 'KnockFileShare', '%{public}s', `setColorMode error ${JSON.stringify(e)}`);
+ }
+ hilog.info(DOMAIN, 'KnockFileShare', '%{public}s', 'Ability onCreate');
}
onDestroy(): void {
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
+ hilog.info(DOMAIN, 'KnockFileShare', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage): void {
// Main window is created, set main page for this ability
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+ hilog.info(DOMAIN, 'KnockFileShare', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err) => {
if (err.code) {
- hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
+ hilog.error(DOMAIN, 'KnockFileShare', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
}
windowStage.getMainWindow().then((data: window.Window) => {
@@ -52,7 +56,7 @@ export default class EntryAbility extends UIAbility {
hilog.error(0x0000, 'WebAbility',
`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
});
- hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
+ hilog.info(DOMAIN, 'KnockFileShare', 'Succeeded in loading the content.');
});
}
@@ -64,39 +68,43 @@ export default class EntryAbility extends UIAbility {
if (!this.uiContext) {
return;
}
- let mainWindow: window.WindowProperties = this.mainWindowClass!.getWindowProperties();
- let windowWidth: number = mainWindow.windowRect.width;
- let windowWidthVp = this.uiContext.px2vp(windowWidth);
- let widthBp: string = '';
- if (windowWidthVp < 320) {
- widthBp = BreakpointConstants.BREAKPOINT_XS;
- } else if (windowWidthVp >= 320 && windowWidthVp < 600) {
- widthBp = BreakpointConstants.BREAKPOINT_SM;
- } else if (windowWidthVp >= 600 && windowWidthVp < 840) {
- widthBp = BreakpointConstants.BREAKPOINT_MD;
- } else if (windowWidthVp >= 840 && windowWidthVp < 1440) {
- widthBp = BreakpointConstants.BREAKPOINT_LG;
- } else {
- widthBp = BreakpointConstants.BREAKPOINT_XL;
+ try {
+ let mainWindow: window.WindowProperties = this.mainWindowClass!.getWindowProperties();
+ let windowWidth: number = mainWindow.windowRect.width;
+ let windowWidthVp = this.uiContext.px2vp(windowWidth);
+ let widthBp: string = '';
+ if (windowWidthVp < 320) {
+ widthBp = BreakpointConstants.BREAKPOINT_XS;
+ } else if (windowWidthVp >= 320 && windowWidthVp < 600) {
+ widthBp = BreakpointConstants.BREAKPOINT_SM;
+ } else if (windowWidthVp >= 600 && windowWidthVp < 840) {
+ widthBp = BreakpointConstants.BREAKPOINT_MD;
+ } else if (windowWidthVp >= 840 && windowWidthVp < 1440) {
+ widthBp = BreakpointConstants.BREAKPOINT_LG;
+ } else {
+ widthBp = BreakpointConstants.BREAKPOINT_XL;
+ }
+ AppStorage.setOrCreate(BreakpointConstants.BREAKPOINT_NAME, widthBp);
+ AppStorage.setOrCreate('windowWidth', windowWidth);
+ let windowHeight: number = mainWindow.windowRect.height;
+ AppStorage.setOrCreate('windowHeight', windowHeight);
+ } catch (e) {
+ hilog.error(DOMAIN, 'KnockFileShare', '%{public}s', `updateWidthBp error ${JSON.stringify(e)}`);
}
- AppStorage.setOrCreate(BreakpointConstants.BREAKPOINT_NAME, widthBp);
- AppStorage.setOrCreate('windowWidth', windowWidth);
- let windowHeight: number = mainWindow.windowRect.height;
- AppStorage.setOrCreate('windowHeight', windowHeight);
}
onWindowStageDestroy(): void {
// Main window is destroyed, release UI related resources
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ hilog.info(DOMAIN, 'KnockFileShare', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground(): void {
// Ability has brought to foreground
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
+ hilog.info(DOMAIN, 'KnockFileShare', '%{public}s', 'Ability onForeground');
}
onBackground(): void {
// Ability has back to background
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
+ hilog.info(DOMAIN, 'KnockFileShare', '%{public}s', 'Ability onBackground');
}
}
\ No newline at end of file
diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets
index e2e87d3..f9562a8 100644
--- a/entry/src/main/ets/pages/Index.ets
+++ b/entry/src/main/ets/pages/Index.ets
@@ -141,10 +141,14 @@ struct Index {
*/
handleFileInit() {
let filesDir = this.context.filesDir;
- let fileList = fileIo.listFileSync(filesDir);
- for (let index = 0; index < fileList.length; index++) {
- const fileName = fileList[index];
- fileIo.unlinkSync(filesDir + '/' + fileName);
+ try {
+ let fileList = fileIo.listFileSync(filesDir);
+ for (let index = 0; index < fileList.length; index++) {
+ const fileName = fileList[index];
+ fileIo.unlinkSync(filesDir + '/' + fileName);
+ }
+ } catch (e) {
+ hilog.error(0x0000, 'KnockFileShare', `unlinkSync error ${JSON.stringify(e)}`);
}
for (const item of this.dataList) {
let file: fileIo.File | undefined = undefined;
@@ -158,7 +162,11 @@ struct Index {
} catch (err) {
hilog.error(0x0000, 'KnockFileShare', `Failed to save image. ${JSON.stringify(err)}`);
} finally {
- fileIo.close(file);
+ try {
+ fileIo.close(file);
+ } catch (e) {
+ hilog.error(0x0000, 'KnockFileShare', `close error ${JSON.stringify(e)}`);
+ }
}
try {
let url = this.context.filesDir + '/' + item.thumbnail;
@@ -170,7 +178,11 @@ struct Index {
} catch (err) {
hilog.error(0x0000, 'KnockFileShare', `Failed to save image. ${JSON.stringify(err)}`);
} finally {
- fileIo.close(file);
+ try {
+ fileIo.close(file);
+ } catch (e) {
+ hilog.error(0x0000, 'KnockFileShare', `close error ${JSON.stringify(e)}`);
+ }
}
}
}
diff --git a/entry/src/main/ets/utils/FileUtil.ets b/entry/src/main/ets/utils/FileUtil.ets
index 1fb3400..a4471f1 100644
--- a/entry/src/main/ets/utils/FileUtil.ets
+++ b/entry/src/main/ets/utils/FileUtil.ets
@@ -29,15 +29,15 @@ export class FileUtil {
if (!canIUse('SystemCapability.Multimedia.Media.AVImageGenerator')) {
return false;
}
- let avImageGenerator: media.AVImageGenerator = await media.createAVImageGenerator();
- avImageGenerator.fdSrc = fileIo.openSync(path, fileIo.OpenMode.READ_ONLY);
- let timeUs = 0;
- let queryOption = media.AVImageQueryOptions.AV_IMAGE_QUERY_NEXT_SYNC;
- let param: media.PixelMapParams = {
- width: 300,
- height: 300
- };
try {
+ let avImageGenerator: media.AVImageGenerator = await media.createAVImageGenerator();
+ avImageGenerator.fdSrc = fileIo.openSync(path, fileIo.OpenMode.READ_ONLY);
+ let timeUs = 0;
+ let queryOption = media.AVImageQueryOptions.AV_IMAGE_QUERY_NEXT_SYNC;
+ let param: media.PixelMapParams = {
+ width: 300,
+ height: 300
+ };
let pixmap: image.PixelMap = await avImageGenerator.fetchFrameByTime(timeUs, queryOption, param);
let packOpts: image.PackingOption = { format: 'image/jpeg', quality: 98 };
const imagePackerApi = image.createImagePacker();
--
Gitee
From 1b027b4c8c1394a79d6f3891de61c6d24cc2ff76 Mon Sep 17 00:00:00 2001
From: "1362134550@qq.com" <1362134550@qq.com>
Date: Tue, 9 Sep 2025 15:56:35 +0800
Subject: [PATCH 7/9] =?UTF-8?q?=E7=A2=B0=E4=B8=80=E7=A2=B0=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=88=86=E4=BA=AB=20=20=E5=BC=82=E5=B8=B8=E5=A4=84?=
=?UTF-8?q?=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
entry/src/main/ets/pages/Index.ets | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets
index f9562a8..3726de4 100644
--- a/entry/src/main/ets/pages/Index.ets
+++ b/entry/src/main/ets/pages/Index.ets
@@ -172,7 +172,7 @@ struct Index {
let url = this.context.filesDir + '/' + item.thumbnail;
file = fileIo.openSync(url, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
let writeLen = fileIo.writeSync(file.fd,
- (this.context.resourceManager.getMediaContentSync(IMAGE_DATA[item.index]) as Uint8Array).buffer);
+ (this.context.resourceManager.getMediaContentSync(IMAGE_DATA[item.index].id) as Uint8Array).buffer);
hilog.info(0x0000, 'KnockFileShare', `write data to file success and size is : ${writeLen}`);
item.thumbnail = fileUri.getUriFromPath(url);
} catch (err) {
--
Gitee
From 09ac7198cbf2abe37202da0f75d049714b6e6639 Mon Sep 17 00:00:00 2001
From: "1362134550@qq.com" <1362134550@qq.com>
Date: Sat, 13 Sep 2025 17:55:36 +0800
Subject: [PATCH 8/9] =?UTF-8?q?=E7=A2=B0=E4=B8=80=E7=A2=B0=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=88=86=E4=BA=AB=20=20=E5=90=8C=E6=BA=90=E5=A4=84?=
=?UTF-8?q?=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
entry/src/main/ets/controller/KnockController.ets | 2 ++
1 file changed, 2 insertions(+)
diff --git a/entry/src/main/ets/controller/KnockController.ets b/entry/src/main/ets/controller/KnockController.ets
index d0c6ac1..6b6ab44 100644
--- a/entry/src/main/ets/controller/KnockController.ets
+++ b/entry/src/main/ets/controller/KnockController.ets
@@ -68,6 +68,7 @@ export class KnockController {
target.share(shareData);
}
+ // [Start FileShareData]
/**
* Get shared data.
*
@@ -87,6 +88,7 @@ export class KnockController {
description: data.description
};
}
+ // [End FileShareData]
// [End FileShare]
// [Start FileShareListening]
--
Gitee
From 4c0785a99ef6d8bbad6d6ceb39c1ba893180a501 Mon Sep 17 00:00:00 2001
From: "1362134550@qq.com" <1362134550@qq.com>
Date: Sat, 13 Sep 2025 18:02:03 +0800
Subject: [PATCH 9/9] =?UTF-8?q?=E7=A2=B0=E4=B8=80=E7=A2=B0=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E5=88=86=E4=BA=AB=20=20=E5=90=8C=E6=BA=90=E5=A4=84?=
=?UTF-8?q?=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
entry/src/main/ets/controller/KnockController.ets | 2 --
1 file changed, 2 deletions(-)
diff --git a/entry/src/main/ets/controller/KnockController.ets b/entry/src/main/ets/controller/KnockController.ets
index 6b6ab44..d0c6ac1 100644
--- a/entry/src/main/ets/controller/KnockController.ets
+++ b/entry/src/main/ets/controller/KnockController.ets
@@ -68,7 +68,6 @@ export class KnockController {
target.share(shareData);
}
- // [Start FileShareData]
/**
* Get shared data.
*
@@ -88,7 +87,6 @@ export class KnockController {
description: data.description
};
}
- // [End FileShareData]
// [End FileShare]
// [Start FileShareListening]
--
Gitee