diff --git a/.vscode/launch.json b/.vscode/launch.json index 7d1dc8f..d124970 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -21,5 +21,10 @@ "type": "dart", "flutterMode": "release" } + { + "name": "Flutter: Attach to Device", + "type": "dart", + "request": "attach" + } ] } \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties index 5e81c9c..6613b6f 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,4 +1,4 @@ org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true -#base-application-name=????? \ No newline at end of file +android.suppressUnsupportedCompileSdk=34 \ No newline at end of file diff --git a/contrbuite.md b/contrbuite.md new file mode 100644 index 0000000..511b82c --- /dev/null +++ b/contrbuite.md @@ -0,0 +1,7 @@ +# Android 运行错误修复 + +直接在android studio设置jdk版本是可以的,但是flutter运行并不会生效,需要在终端设置jdk版本 + +```bash +flutter config --jdk-dir /Users/yw.hao/Library/Java/JavaVirtualMachines/corretto-17.0.9/Contents/Home +``` \ No newline at end of file diff --git a/lib/common/constants/url.dart b/lib/common/constants/url.dart index a808cdb..1f7bdc1 100644 --- a/lib/common/constants/url.dart +++ b/lib/common/constants/url.dart @@ -1,8 +1,8 @@ final NETEASE_INFO_LIST = "https://fn.music.163.com/g/xrn/12cdffe6499557a8b53a8c5c0cca4b01?userid=265031418&dlt=0846&app_version=9.1.50"; -final BASE_URL = 'http://192.168.1.8:3000'; -// final BASE_URL = 'http://39.105.115.83:1231/'; +// final BASE_URL = 'http://192.168.0.102:3000'; // final BASE_URL = 'http://39.105.115.83:3000/'; +final BASE_URL = 'http://127.0.0.1:3000/'; final PLACE_IMAGE_HOLDER = 'https://picsum.photos/100/100'; diff --git a/lib/http/api/message/message_api.dart b/lib/http/api/message/message_api.dart index 8ca4cd3..0eda0c8 100644 --- a/lib/http/api/message/message_api.dart +++ b/lib/http/api/message/message_api.dart @@ -7,4 +7,4 @@ class MessageApi { final res = await HttpUtils.get("/msg/private"); return PrivateMessage.fromJson(res); } -} \ No newline at end of file +} diff --git a/lib/http/http.dart b/lib/http/http.dart index 151498f..d9ff04c 100644 --- a/lib/http/http.dart +++ b/lib/http/http.dart @@ -141,10 +141,15 @@ class Http { requestOptions = requestOptions.copyWith(extra: { "refresh": refresh, }); + Map queryParams = { + ...?params, + // "realIP": "116.25.146.177", + }; Response response; + // 拼接 &realIP=116.25.146.177 response = await _dio.get( path, - queryParameters: params, + queryParameters: queryParams, options: requestOptions, ); return response.data; diff --git a/lib/pages/found/found_controller.dart b/lib/pages/found/found_controller.dart index 23f26da..9fa40dc 100644 --- a/lib/pages/found/found_controller.dart +++ b/lib/pages/found/found_controller.dart @@ -35,9 +35,21 @@ class FoundController extends GetxController { @override void onInit() { super.onInit(); - _getBanner(); - _getHomeBlock(); - _getMvList(); + } + + initData() async { + try { + loading.value = true; + await Future.wait([ + _getBanner(), + _getHomeBlock(), + _getMvList(), + ] as Iterable); + } catch (e) { + LogBox.error(e); + } finally { + loading.value = false; + } } refreshHome() { @@ -50,7 +62,6 @@ class FoundController extends GetxController { _getBanner() async { try { - loading.value = true; if (Platform.isIOS) { banner.value = await FoundApi.getBanner(BannerType.IPHONE.value); } else { @@ -58,19 +69,14 @@ class FoundController extends GetxController { } } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } Future _getMvList() async { try { - loading.value = true; mvList.value = await FoundApi.getAllMvList(); } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } @@ -78,7 +84,6 @@ class FoundController extends GetxController { _getHomeBlock({bool isRefresh = false}) async { try { - loading.value = true; homeBlock.value = await FoundApi.getHomeBlock(isRefresh: isRefresh); // HOMEPAGE_SLIDE_SONGLIST_ALIGN获取mediaItem列表 @@ -88,8 +93,6 @@ class FoundController extends GetxController { await _buildNewSongNewAlbum(); } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } diff --git a/lib/pages/main/main_controller.dart b/lib/pages/main/main_controller.dart index 94a37e8..ad75dee 100644 --- a/lib/pages/main/main_controller.dart +++ b/lib/pages/main/main_controller.dart @@ -77,28 +77,37 @@ class MainController extends GetxController { super.onReady(); } - refreshMainPage() { - // 获取私人雷达 - _getPrivateRadar(); - // 获取推荐歌曲 - _getRecommandSongs(); - // 从喜欢的音乐中选择多首音乐,然后生成相似音乐 从相似音乐分别选择6首音译额,共计需要18首音乐 - _getSameSongsFromSomeRadomMusic(); - // 获取私人fm音乐 - _getPersonalFm(); - // 获取网友推荐顶级歌单 - _getRandomTopPlayList(); - // 获取推荐歌单 - _getPersonalizedPlayLists(); - // 获取个人歌单 - _getOwnPlayList(); - // 获取推荐播客 - getPersonalizedDjProgram(); + refreshMainPage() async { + try { + loading.value = true; + + await Future.wait([ + // 获取私人雷达 + _getPrivateRadar(), + // 获取推荐歌曲 + _getRecommandSongs(), + // 从喜欢的音乐中选择多首音乐,然后生成相似音乐 从相似音乐分别选择6首音译额,共计需要18首音乐 + _getSameSongsFromSomeRadomMusic(), + // 获取私人fm音乐 + _getPersonalFm(), + // 获取网友推荐顶级歌单 + _getRandomTopPlayList(), + // 获取推荐歌单 + _getPersonalizedPlayLists(), + // 获取个人歌单 + _getOwnPlayList(), + // 获取推荐播客 + getPersonalizedDjProgram(), + ] as Iterable); + } catch (e) { + LogBox.error(e); + } finally { + loading.value = false; + } } _getRecommandSongs() async { try { - loading.value = true; recommendSongsDto?.value = await MainApi.getRecommendSongs(); if (recommendSongsDto.value.dailySongs?.isNotEmpty ?? false) { dailySongs.value = RoamingController.to @@ -106,14 +115,11 @@ class MainController extends GetxController { } } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } _getPrivateRadar() async { try { - loading.value = true; // 首先先从推荐资源拿到私人雷达的歌单id recommendResourceDto.value = await MainApi.getRecommendResource(); int privateRadarId = recommendResourceDto.value.recommend?[0]?.id ?? 0; @@ -127,8 +133,6 @@ class MainController extends GetxController { } } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } @@ -158,7 +162,6 @@ class MainController extends GetxController { */ _getSameSongsFromSomeRadomMusic() async { try { - loading.value = true; // 获取喜欢的音乐 await _getLikeSongs(); // 从喜欢的音乐中选择多首音乐 @@ -204,8 +207,6 @@ class MainController extends GetxController { } } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } @@ -235,7 +236,6 @@ class MainController extends GetxController { _getRandomTopPlayList() async { try { - loading.value = true; // 获取网友推荐顶级歌单 TopPlaylistsDto topPlaylistsDto = await MainApi.getTopPlayList(); if (topPlaylistsDto != null && topPlaylistsDto.playlists != null) { @@ -258,14 +258,11 @@ class MainController extends GetxController { } } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } _getPersonalizedPlayLists() async { try { - loading.value = true; PersonalizedPlayLists personalizedPlayLists = await MainApi.getPersonalizedPlaylists(); if (personalizedPlayLists != null && @@ -274,14 +271,11 @@ class MainController extends GetxController { } } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } _getOwnPlayList() async { try { - loading.value = true; if (HomeController.to.userData.value.profile != null) { UserPlaylists userPlaylists = await MainApi.getUserPlaylists( HomeController.to.userData.value.profile!.userId!); @@ -291,19 +285,14 @@ class MainController extends GetxController { } } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } getPersonalizedDjProgram() async { try { - loading.value = true; personalizedDjprogramDto.value = await MainApi.getDjProgramRecommend(); } catch (e) { LogBox.error(e); - } finally { - loading.value = false; } } }