Эх сурвалжийг харах

分享app的时候 有缩略图 必须小于32k

onecold 10 сар өмнө
parent
commit
2aced08eb1

+ 6 - 3
entry/src/main/ets/pages/NewIndex.ets

@@ -39,6 +39,7 @@ import OnlineUpdateLogDialog from '../dialog/OnlineUpdateLog';
 import OnlineUpdateLog from '../dialog/OnlineUpdateLog';
 import { LocalMusic } from '../view/LocalMusic';
 import { ChartsCount } from './ChartsCount';
+import { image } from '@kit.ImageKit';
 
 // import { FFmpeg, FFProgressMessageParser } from '@sj/ffmpeg';
 
@@ -735,7 +736,7 @@ struct NewIndex {
                   break
 
                 case MainViewModel.MENU_SHARE:
-                  this.gotoShare()
+                  this.gotoShare(this.context)
                   break
               }
             })
@@ -784,13 +785,15 @@ struct NewIndex {
     }
   }
 
-  gotoShare() {
+  async gotoShare(mContext: common.UIAbilityContext) {
+
     let shareData: systemShare.SharedData = new systemShare.SharedData({
       utd: uniformTypeDescriptor.UniformDataType.TEXT,
       content: 'https://appgallery.huawei.com/app/detail?id=' + this.bundleName,
       title: this.appName, // 不传title字段时,显示content
       description: '精心雕琢的无损音乐播放器',
-      // thumbnail: new Uint8Array() // 推荐传入适合的缩略图 不传则显示默认text图标
+      // thumbnail: new Uint8Array(buffer) // 推荐传入适合的缩略图 不传则显示默认text图标
+      thumbnail: mContext.resourceManager.getMediaContentSync($r("app.media.icon_32"))// 获取小于32k大小的图标才可以
     });
 
     // 进行分享面板显示