onecold пре 1 година
родитељ
комит
2bc47cc056

+ 2 - 2
entry/src/main/ets/common/util/NetAxiosUtil.ets

@@ -28,7 +28,7 @@ class NetAxiosUtil{
       let requestUrl = baseUrl
         + '?title=' + encodeURIComponent(title.trim()) + '&artist=' + encodeURIComponent(artist.trim());
 
-      LogUtil.debug("Heanup requestUrl =" + requestUrl + '; title = '+title+'; artist = '+artist)
+      // LogUtil.debug("Heanup requestUrl =" + requestUrl + '; title = '+title+'; artist = '+artist)
 
       const httpRequest = http.createHttp();
       const options: http.HttpRequestOptions = {
@@ -90,7 +90,7 @@ class NetAxiosUtil{
         readTimeout: 3000,
         connectTimeout: 3000,
       };
-      LogUtil.debug("onecold Heanup 请求封面URL: " + cover_url);
+      // LogUtil.debug("onecold Heanup 请求封面URL: " + cover_url);
       const response: http.HttpResponse = await httpRequest.request(cover_url, options);
       if (response.responseCode === 200) {
         const res = response.result as string;

+ 33 - 2
entry/src/main/ets/pages/NewIndex.ets

@@ -7,7 +7,7 @@ import { CommonConstants } from '../common/constants/CommonConstants';
 import { VideoItem } from '../viewmodel/VideoItem';
 import ScreenUtil from '../common/util/ScreenUtil';
 import { Utility } from '../common/util/Utility';
-import { emitter } from '@kit.BasicServicesKit';
+import { BusinessError, emitter } from '@kit.BasicServicesKit';
 import { common } from '@kit.AbilityKit';
 import { AdSlot, AdSlotBuilder,
   CSJAdCreator,
@@ -25,6 +25,8 @@ import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
 import { SettingPage } from './SettingPage';
 import { deviceInfo } from '@kit.BasicServicesKit';
 import { resourceManager } from '@kit.LocalizationKit';
+import { systemShare } from '@kit.ShareKit';
+import { uniformTypeDescriptor } from '@kit.ArkData';
 
 const TAG = 'NewIndex'; // 日志标签
 
@@ -41,7 +43,7 @@ struct NewIndex{
 
   /** 应用包名 */
   @State bundleName:string = ''
-
+  @State appName:string = ''
   /** 是否显示侧边抽屉菜单 */
   @Provide isShowDrawer:boolean = false;
   /** 抽屉菜单 X 轴偏移量,用于手势滑动动画 */
@@ -161,6 +163,9 @@ struct NewIndex{
 
 async aboutToAppear() {
   Utility.enableFullScreen()
+  Utility.getAppName(getContext(this)).then((appName:string)=>{
+    this.appName = appName
+  })
   this.breakpointSystem.register();
   let params = router.getParams() as Record<string, Object>;
   this.videoLocalList = params.videoList as VideoItem[];
@@ -413,6 +418,10 @@ async aboutToAppear() {
                   params: { titleName: '隐私政策', webUrl: CommonConstants.NEW_YS_HW }
                 });
                 break
+
+              case MainViewModel.MENU_SHARE:
+                 this.gotoShare()
+                break
             }
           })
         }
@@ -429,6 +438,28 @@ async aboutToAppear() {
     .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
   }
 
+  gotoShare(){
+    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图标
+    });
+
+    // 进行分享面板显示
+    let controller: systemShare.ShareController = new systemShare.ShareController(shareData);
+    let context = getContext(this) as common.UIAbilityContext;
+    controller.show(context, {
+      selectionMode: systemShare.SelectionMode.SINGLE,
+      previewMode: systemShare.SharePreviewMode.DETAIL,
+    }).then(() => {
+      console.info('ShareController show success.');
+    }).catch((error: BusinessError) => {
+      console.error(`ShareController show error. code: ${error.code}, message: ${error.message}`);
+    });
+  }
+
   /**
    * ================== 穿山甲广告相关 ==================
    */

+ 2 - 2
entry/src/main/ets/pages/SettingPage.ets

@@ -92,7 +92,7 @@ export struct SettingPage {
           value: '保存',
           action: () => {
             if (this.apiDialogType === 'lyric') {
-              this.lyricApiUrl = this.tempApiUrl
+              this.lyricApiUrl = this.tempApiUrl.trim()
               PreferencesUtil.put('LRC_API', this.lyricApiUrl)
               this.getUIContext().getPromptAction().showToast({
                 message: '保存成功,当前LRC_API:' + this.lyricApiUrl,
@@ -101,7 +101,7 @@ export struct SettingPage {
                 bottom: 85
               })
             } else {
-              this.coverApiUrl = this.tempApiUrl
+              this.coverApiUrl = this.tempApiUrl.trim()
               PreferencesUtil.put('COVER_API', this.coverApiUrl)
               this.getUIContext().getPromptAction().showToast({
                 message: '保存成功,当前COVER_API:' + this.coverApiUrl,

+ 3 - 0
entry/src/main/ets/viewmodel/MainViewModel.ets

@@ -41,6 +41,7 @@ export  class  MainViewModel{
   static readonly MENU_MIEDIA_ARTIST: number = 229;
   static readonly MENU_MIEDIA_ALBUM: number = 230;
   static readonly MENU_FILE_SCAN: number = 231;
+  static readonly MENU_SHARE: number = 232;
   //测滑菜单的数据
   getDrawerData(): Array<ItemData> {
     let drawerGridData: ItemData[] = [
@@ -57,6 +58,7 @@ export  class  MainViewModel{
       new ItemData($r('app.string.yszc'), $r('app.media.oh_pri'),MainViewModel.MENU_YSZC,false),
       new ItemData($r('app.string.about_me'), $r('app.media.oh_about'),MainViewModel.MENU_ABOUT,false),
       new ItemData($r('app.string.setting'), $r('app.media.setting_red'),MainViewModel.MENU_SETTING,false),
+      new ItemData($r('app.string.share_tt'), $r('app.media.oh_share'),MainViewModel.MENU_SHARE,false),
       // new ItemData($r('app.string.nor_setting'), $r('app.media.hm_gps'),MainViewModel.MENU_SETTING,false),
     ];
     return drawerGridData;
@@ -77,6 +79,7 @@ export  class  MainViewModel{
       new ItemData($r('app.string.yszc'), $r('app.media.oh_pri'),MainViewModel.MENU_YSZC,false),
       new ItemData($r('app.string.about_me'), $r('app.media.oh_about'),MainViewModel.MENU_ABOUT,false),
       new ItemData($r('app.string.setting'), $r('app.media.setting_red'),MainViewModel.MENU_SETTING,false),
+      new ItemData($r('app.string.share_tt'), $r('app.media.oh_share'),MainViewModel.MENU_SHARE,false),
       // new ItemData($r('app.string.nor_setting'), $r('app.media.hm_gps'),MainViewModel.MENU_SETTING,false),
     ];
     return drawerGridData;

+ 4 - 0
entry/src/main/resources/base/element/string.json

@@ -399,6 +399,10 @@
     {
       "name": "scaning",
       "value": "扫描中..."
+    },
+    {
+      "name": "share_tt",
+      "value": "分享应用"
     }
   ]
 }

BIN
entry/src/main/resources/base/media/oh_share.png