diff --git a/build.dev.sh b/build.dev.sh index 5573722..fb3382d 100644 --- a/build.dev.sh +++ b/build.dev.sh @@ -1 +1,26 @@ -flutter build apk -Penv=dev +#!/bin/bash + +#当前执行目录 +current_dir=$(pwd) +channelPath="$current_dir/build/app/outputs/apk/dev" +mkdir -p "$channelPath" +rm -rf "$channelPath"/* +#定义环境变量和 Android 设备品牌 +declare -a APP_CHANNELS=("dev") + +# 遍历每个环境配置并执行构建 +for index in "${APP_CHANNELS[@]}"; do + ENV=${APP_CHANNELS[$index]} + flutter build apk -Penv=dev -Pchannel=$ENV --dart-define=ENV=dev + # 检查构建是否成功 + if [ $? -ne 0 ]; then + echo "Build failed for ENV=$ENV" + exit 1 + fi + apkFile=$(find $(pwd)/build/app/outputs/apk/release/ -name "*.apk" -print -quit) + # 获取 .apk 文件的文件名 + apkFileName=$(basename "$apkFile") + mv $apkFile "$channelPath/$apkFileName" +done + +echo "All builds completed successfully." diff --git a/build.prod.sh b/build.prod.sh index 4501893..56261cf 100644 --- a/build.prod.sh +++ b/build.prod.sh @@ -11,7 +11,7 @@ declare -a APP_CHANNELS=("release") # 遍历每个环境配置并执行构建 for index in "${APP_CHANNELS[@]}"; do ENV=${APP_CHANNELS[$index]} - flutter build apk -Penv=prod -Pchannel=$ENV + flutter build apk -Penv=prod -Pchannel=$ENV --dart-define=ENV=prod # 检查构建是否成功 if [ $? -ne 0 ]; then echo "Build failed for ENV=$ENV" diff --git a/cert.cer b/cert.cer new file mode 100644 index 0000000..4bf8254 Binary files /dev/null and b/cert.cer differ diff --git a/lib/global/config.dart b/lib/global/config.dart index 5cc6c0b..6bdc35d 100644 --- a/lib/global/config.dart +++ b/lib/global/config.dart @@ -8,19 +8,24 @@ class Config { ///获取接口地址 static String baseUrl() { if (getEnv() == 'dev') { - return 'https://xueguang.test.tuzuu.com/api'; + return 'https://xg.test.lifebanktech.com/api'; } else { - return 'https://xueguang.test.tuzuu.com/api'; + return 'https://xg.lifebanktech.com/api'; } } /// 获取websocket地址 static String wsUrl() { - return "wss://xueguang.test.tuzuu.com/ws"; + final url = webUrl(); + final wsBase = url.replaceAll('https', 'wss'); // 替换协议 + return '$wsBase/ws'; } ///网页域名地址 - static String get webUrl => "http://xueguang.test.tuzuu.com"; + static String webUrl() { + String url = baseUrl(); + return url.replaceAll("/api", ""); + } ///声网APPid static String get swAppId => "011c2fd2e1854511a80c1aebded4eee7"; diff --git a/lib/main.dart b/lib/main.dart index 7f00c5e..b8d03c2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,8 @@ -import 'dart:async'; import 'package:app/global/event_bus.dart'; import 'package:app/providers/user_store.dart'; import 'package:app/router/route_paths.dart'; +import 'package:app/widgets/version/version_dialog.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -12,7 +12,6 @@ import 'package:go_router/go_router.dart'; import 'package:provider/provider.dart'; import 'global/theme/theme.dart'; -import 'global/theme/themes/light_theme.dart'; void main() { runApp( @@ -43,6 +42,13 @@ class _MyAppState extends State { ctx?.go(RoutePaths.login); } }); + + ///延迟 + WidgetsBinding.instance.addPostFrameCallback((_) { + final ctx = navigatorKey.currentState?.context; + showUpdateDialog(ctx!); + }); + } @override diff --git a/lib/pages/common/auth/login_page.dart b/lib/pages/common/auth/login_page.dart index 791d694..dd0928f 100644 --- a/lib/pages/common/auth/login_page.dart +++ b/lib/pages/common/auth/login_page.dart @@ -37,7 +37,7 @@ class _LoginPageState extends State { @override void initState() { - super.initState(); + super.initState(); } ///点击发送验证码 diff --git a/lib/pages/student/home/s_home_page.dart b/lib/pages/student/home/s_home_page.dart index 864037d..0c10241 100644 --- a/lib/pages/student/home/s_home_page.dart +++ b/lib/pages/student/home/s_home_page.dart @@ -1,6 +1,5 @@ import 'package:app/global/theme/base/app_theme_ext.dart'; import 'package:app/pages/student/home/viewmodel/s_home_vm.dart'; -import 'package:app/widgets/version/version_dialog.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'widgets/tip_card.dart'; @@ -13,7 +12,6 @@ class SHomePage extends StatelessWidget { @override Widget build(BuildContext context) { - showUpdateDialog(context); return ChangeNotifierProvider( create: (_) => SHomeVm(), child: _HomeView(), diff --git a/lib/pages/student/room/video/teacher_video.dart b/lib/pages/student/room/video/teacher_video.dart index d9a32de..06c6491 100644 --- a/lib/pages/student/room/video/teacher_video.dart +++ b/lib/pages/student/room/video/teacher_video.dart @@ -54,15 +54,18 @@ class TeacherVideo extends StatelessWidget { Positioned( top: 30, left: 10, - child: Container( - width: 200, - color: Colors.black, - child: AspectRatio( - aspectRatio: 16 / 9, - child: AgoraVideoView( - controller: VideoViewController( - rtcEngine: vm.engine!, - canvas: const VideoCanvas(uid: 0), + child: Visibility( + visible: !vm.cameraClose, + child: Container( + width: 200, + color: Colors.black, + child: AspectRatio( + aspectRatio: 16 / 9, + child: AgoraVideoView( + controller: VideoViewController( + rtcEngine: vm.engine!, + canvas: const VideoCanvas(uid: 0), + ), ), ), ), diff --git a/lib/pages/student/room/viewmodel/stu_room_vm.dart b/lib/pages/student/room/viewmodel/stu_room_vm.dart index c5a08da..5034b74 100644 --- a/lib/pages/student/room/viewmodel/stu_room_vm.dart +++ b/lib/pages/student/room/viewmodel/stu_room_vm.dart @@ -103,6 +103,7 @@ class StuRoomVM extends ChangeNotifier { //启动连接 await _ws.connect(); // + _sub?.cancel(); _sub = _ws.stream.listen((msg) { //自习室人员变化,同时也设置房间是否开了 if (msg.event == RoomEvent.changeUser) { diff --git a/lib/pages/teacher/home/t_home_page.dart b/lib/pages/teacher/home/t_home_page.dart index bf4d892..a654d31 100644 --- a/lib/pages/teacher/home/t_home_page.dart +++ b/lib/pages/teacher/home/t_home_page.dart @@ -13,7 +13,6 @@ class THomePage extends StatelessWidget { @override Widget build(BuildContext context) { - // showUpdateDialog(context); return ChangeNotifierProvider( create: (_) => HomeViewModel(), child: const _HomeView(), diff --git a/lib/request/websocket/room_websocket.dart b/lib/request/websocket/room_websocket.dart index 6e2f4bd..66d30a3 100644 --- a/lib/request/websocket/room_websocket.dart +++ b/lib/request/websocket/room_websocket.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:app/global/config.dart'; import 'package:app/request/api/room_api.dart'; import 'package:app/request/websocket/room_protocol.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:logger/logger.dart'; import '../dto/room/rtc_token_dto.dart'; @@ -51,7 +52,6 @@ class RoomWebSocket { _socket = await WebSocket.connect( "${Config.wsUrl()}?token=$wsToken&study_room_id=$roomId", ); - logger.i("连接成功"); _reconnectTimer?.cancel(); _reconnectTimer = null; @@ -76,7 +76,7 @@ class RoomWebSocket { }, onDone: () {}, onError: (_) { - logger.e("连接异常断开"); + EasyLoading.showError("连接断开"); }, ); //自动加入房间 @@ -88,7 +88,6 @@ class RoomWebSocket { send(RoomCommand.ping); }); } catch (e) { - logger.e("连接失败"); _reconnect(); } } @@ -110,7 +109,7 @@ class RoomWebSocket { void _reconnect() { _reconnectTimer?.cancel(); _reconnectTimer = Timer.periodic(Duration(seconds: 3), (timer) { - logger.e("正在重连"); + EasyLoading.showToast("正在重连中"); connect(); }); } @@ -121,11 +120,10 @@ class RoomWebSocket { _heartbeatTimer = null; //socket取消 _socket?.close(); - // 销毁事件流 - // _msgController.close(); // 错误重连取消 _reconnectTimer?.cancel(); _reconnectTimer = null; + logger.i("websocket销毁成功"); } } diff --git a/lib/widgets/room/board/board_dialog.dart b/lib/widgets/room/board/board_dialog.dart index 7027bfe..c11b086 100644 --- a/lib/widgets/room/board/board_dialog.dart +++ b/lib/widgets/room/board/board_dialog.dart @@ -13,7 +13,7 @@ class BoardDialog extends StatefulWidget { } class _BoardDialogState extends State { - bool _loading = true; + bool _loading = false; @override void initState() { diff --git a/lib/widgets/room/board/board_manager.dart b/lib/widgets/room/board/board_manager.dart index 57a7d87..658ee45 100644 --- a/lib/widgets/room/board/board_manager.dart +++ b/lib/widgets/room/board/board_manager.dart @@ -55,12 +55,12 @@ class BoardManager { "write": isTeacher ? 1 : 0, }; String paramStr = params.entries.map((e) => "${e.key}=${e.value}").join("&"); - - return "${Config.webUrl}/board?$paramStr"; + return "${Config.webUrl()}/board?$paramStr"; } /// 获取全局唯一 WebViewController Future getController(String url) async { + print(url); if (_webViewController != null) return _webViewController!; _webViewController = WebViewController() diff --git a/pubspec.yaml b/pubspec.yaml index 825cf5f..0546ac7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: app description: "A new Flutter project." publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 1.1.1 +version: 1.1.3 environment: sdk: ^3.8.1