Просмотр исходного кода

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

onecold 10 месяцев назад
Родитель
Сommit
2aced08eb1
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      entry/src/main/ets/pages/NewIndex.ets

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

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