1.7下午

This commit is contained in:
fuenmao 2025-01-07 15:45:20 +08:00
parent 976b76adae
commit 44180f9924
9 changed files with 237 additions and 184 deletions

View File

@ -5,7 +5,7 @@ class RequestConfig {
// static const _devBaseUrl = "https://zyapitest.23544.com:16440"; //
static const _devBaseUrl = "http://192.168.2.9:5192"; //
// static const _proBaseUrl = "http://192.168.2.119:1091"; //
static const _proBaseUrl = "https://zyapi.23544.com/ipadapi"; //
static const _proBaseUrl = "http://192.168.2.9:5192"; //
static const imgUrl = 'https://dpc-job-oss.23544.com/';
static RequestConfig? _instance;

View File

@ -6,6 +6,8 @@ import 'package:dio/dio.dart';
import 'package:wgshare/common/api/retrofit_client.dart';
import 'package:wgshare/common/config/request_config.dart';
import 'package:wgshare/common/store/user_store.dart';
import 'package:wgshare/utils/anti_shake_throttling.dart';
import 'package:wgshare/utils/routeUtil.dart';
import 'package:wgshare/utils/storage.dart';
import 'package:wgshare/utils/toast_utils.dart';
import 'package:wgshare/routes/app_routes.dart';
@ -111,9 +113,9 @@ class ResponseHandle extends Interceptor {
((data['code'] != null && (data['code'] == 401 || data['code'] == '401')) ||
(data['Code'] != null && (data['Code'] == 401 || data['Code'] == '401')));
if (statusCode == 401 || flag) {
Future.delayed(const Duration(seconds: 2), () {
StorageService.to.erase();
if ((statusCode == 401 || flag) && RouteUtil.getRoute() != Routes.loginPage) {
easyThrottle("toLogin",(){
UserStore.to.erase();
getx.Get.offAllNamed(Routes.loginPage);
});
}
@ -163,12 +165,12 @@ class TheError extends Interceptor {
switch (statusCode) {
case 401:
message = '用户登录失效,请重新登录';
Future.delayed(const Duration(seconds: 2), () {
// UserStore.to.erase();
StorageService.to.erase();
if(RouteUtil.getRoute() != Routes.loginPage){
easyThrottle("toLogin",(){
UserStore.to.erase();
getx.Get.offAllNamed(Routes.loginPage);
});
}
break;
case 404:
message = '无效地址';

View File

@ -134,6 +134,7 @@ class HomeLogic extends GetxController with RequestToolMixin {
leftBtnStr: '拒绝',
rightBtnStr: '同意',
leftBtnCallback: () {
Get.back();
Get.toNamed(Routes.meetingMainPage,
arguments: {
"roomNumber": state.meetingRooms.value[index].roomNum
@ -142,6 +143,7 @@ class HomeLogic extends GetxController with RequestToolMixin {
rightBtnCallback: () {
PermissionService.requestPermissions().then((value) {
if (value == true) {
Get.back();
Get.toNamed(Routes.meetingMainPage,
arguments: {
"roomNumber": state.meetingRooms.value[index].roomNum

View File

@ -20,22 +20,22 @@ import '../../view/upgrade/loadJson/load_network_json.dart';
import 'login_state.dart';
class LoginLogic extends GetxController with RequestToolMixin {
final LoginState state = LoginState();
late LoginState state;
@override
void onInit() {
super.onInit();
print("初始化登录init................");
state = LoginState();
HideCheckVersion hideCheckVersion = HideCheckVersion();
hideCheckVersion.doHttpHideCheckVersion();
super.onInit();
}
@override
void onClose() {
print("销毁onClose................");
super.onClose();
state.passwordController.dispose();
state.userNameController.dispose();
state.meetingCodeController.dispose();
state.nickNameCodeController.dispose();
}
///
@ -50,24 +50,24 @@ class LoginLogic extends GetxController with RequestToolMixin {
///
Future<void> doHttpLogin() async {
if(state.userNameController.text.isEmpty){
if(state.userNameController!.text.isEmpty){
ToastUtils.showError("请输入账号");
}else if(state.passwordController.text.isEmpty){
}else if(state.passwordController!.text.isEmpty){
ToastUtils.showError("请输入密码");
}else if(state.checkAgreementBool.value != true){
ToastUtils.showError("请阅读并勾选相关协议");
}else{
BaseStructureResult<UserInfoEntity> res = await getClient().login(state.userNameController.text, md5.convert(utf8.encode(state.passwordController.text)).toString());
BaseStructureResult<UserInfoEntity> res = await getClient().login(state.userNameController!.text, md5.convert(utf8.encode(state.passwordController!.text)).toString());
if (null != res.data) {
UserStore.to.setToken(res.data!.token);
UserStore.to.setRefreshToken(res.data!.refreshToken);
UserStore.to.setUserDetailInfo(res.data!);
UserStore.to.setLoginType(AppConfig.NORMAL_LOGIN);
Get.offAllNamed(Routes.startPage);
state.userNameController.text = "";
state.passwordController.text = "";
state.meetingCodeController.text = "";
state.nickNameCodeController.text = "";
state.userNameController!.text = "";
state.passwordController!.text = "";
state.meetingCodeController!.text = "";
state.nickNameCodeController!.text = "";
state.checkAgreementBool.value = false;
}
}
@ -75,26 +75,26 @@ class LoginLogic extends GetxController with RequestToolMixin {
///
Future<void> doHttpAnonymousLogin() async {
if(state.meetingCodeController.text.isEmpty){
if(state.meetingCodeController!.text.isEmpty){
ToastUtils.showError("请输入会议号");
}else if(state.meetingCodeController.text.length != 8){
}else if(state.meetingCodeController!.text.length != 8){
ToastUtils.showError("请输入正确的会议号");
}else if(state.nickNameCodeController.text.isEmpty){
}else if(state.nickNameCodeController!.text.isEmpty){
ToastUtils.showError("请输入昵称");
}else if(state.checkAgreementBool != true){
ToastUtils.showError("请阅读并勾选相关协议");
}else{
BaseStructureResult<UserInfoEntity> res = await getClient().anonLogin(await DeviceInfo.getDeviceId(),state.nickNameCodeController.text, state.meetingCodeController.text);
BaseStructureResult<UserInfoEntity> res = await getClient().anonLogin(await DeviceInfo.getDeviceId(),state.nickNameCodeController!.text, state.meetingCodeController!.text);
if (null != res.data) {
UserStore.to.setToken(res.data!.token);
UserStore.to.setRefreshToken(res.data!.refreshToken);
UserStore.to.setUserDetailInfo(res.data!);
UserStore.to.setLoginType(AppConfig.ANONYMOUS_LOGIN);
Get.toNamed(Routes.meetingMainPage, arguments: {"roomNumber": state.meetingCodeController.text});
state.userNameController.text = "";
state.passwordController.text = "";
state.meetingCodeController.text = "";
state.nickNameCodeController.text = "";
Get.toNamed(Routes.meetingMainPage, arguments: {"roomNumber": state.meetingCodeController!.text});
state.userNameController!.text = "";
state.passwordController!.text = "";
state.meetingCodeController!.text = "";
state.nickNameCodeController!.text = "";
state.checkAgreementBool.value = false;
}
}
@ -102,16 +102,16 @@ class LoginLogic extends GetxController with RequestToolMixin {
///
Future<void> doHttpCheckMeetingRoom() async {
if(state.meetingCodeController.text.isEmpty){
if(state.meetingCodeController!.text.isEmpty){
ToastUtils.showError("请输入会议号");
}else if(state.meetingCodeController.text.length != 8){
}else if(state.meetingCodeController!.text.length != 8){
ToastUtils.showError("请输入正确的会议号");
}else if(state.nickNameCodeController.text.isEmpty){
}else if(state.nickNameCodeController!.text.isEmpty){
ToastUtils.showError("请输入昵称");
}else if(state.checkAgreementBool != true){
ToastUtils.showError("请阅读并勾选相关协议");
}else{
BaseStructureResult<bool> res = await getClient().checkout(state.meetingCodeController.text);
BaseStructureResult<bool> res = await getClient().checkout(state.meetingCodeController!.text);
if (null != res.data) {
if(res.data == true){
doHttpAnonymousLogin();

View File

@ -3,12 +3,14 @@ import 'package:get/get.dart';
class LoginState {
LoginState() {}
TextEditingController? userNameController;
TextEditingController? passwordController;
TextEditingController? meetingCodeController;
TextEditingController? nickNameCodeController;
LoginState() {
}
late TextEditingController userNameController = TextEditingController();
late TextEditingController passwordController = TextEditingController();
late TextEditingController meetingCodeController = TextEditingController();
late TextEditingController nickNameCodeController = TextEditingController();
/// 01
late RxInt pageState = 0.obs;

View File

@ -23,6 +23,10 @@ class _LoginPageState extends State<LoginPage> {
@override
void initState() {
Utils.hideKeyboard();
state.userNameController = TextEditingController();
state.passwordController = TextEditingController();
state.meetingCodeController = TextEditingController();
state.nickNameCodeController = TextEditingController();
super.initState();
}
@ -394,4 +398,13 @@ class _LoginPageState extends State<LoginPage> {
),
);
}
@override
void dispose() {
state.passwordController?.dispose();
state.userNameController?.dispose();
state.meetingCodeController?.dispose();
state.nickNameCodeController?.dispose();
super.dispose();
}
}

View File

@ -64,9 +64,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
await getClient().getMeetingToken(state.roomNumber.value);
state.meetingToken.value = res.data!;
if (isInit == true) {
if (isInit) {
signalRSocket();
}else{
} else {
initRtc();
}
}
@ -89,6 +89,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
getMeetingRoomAllUser(results[1].data as List<MeetingRoomUser>);
} finally {
ToastUtils.dismiss();
ToastUtils.showSuccess("${state.isJoinSuccess}--${state.rctEngine.value}--${state.users.isNotEmpty}");
}
}
@ -162,15 +163,17 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}
/// grid切换大屏
void checkLargeScreen(String uid){
void checkLargeScreen(String uid) {
ToastUtils.showSuccess("切换用户成功");
if(uid == UserStore.to.userInfoEntity.value!.uid) {
if (uid == UserStore.to.userInfoEntity.value!.uid) {
state.remoteUid.value = "0";
}else{
if(state.isSpeak.value == true && state.isOpenCamera.value == true){
state.remoteAssistantUid.value = "0";
} else {
if (state.isSpeak.value == true && state.isOpenCamera.value == true) {
state.floating.value?.open(Get.context!);
}
state.remoteUid.value = uid;
state.remoteAssistantUid.value = uid;
}
changePageState(0);
Future.delayed(const Duration(milliseconds: 200), () {
@ -208,7 +211,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
/// ------------------------------------------------------------------------------
///
Future<void> doHttpSetMicr(bool isOpenMicrophone) async {
if(isOpenMicrophone == false){
if (isOpenMicrophone == false) {
state.spokesman.value = "";
state.spokesmanVolume.value = 0;
}
@ -257,9 +260,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
isOtherOpenCamera = true;
}
}
if(isOtherOpenCamera == false){
if (isOtherOpenCamera == false) {
changePageState(0);
}else{
} else {
state.remoteUid.value = "";
changePageState(1);
}
@ -270,7 +273,8 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
//
var isCurrentUserIsCamera = false;
for (var i = 0; i < state.cacheUsers.value.length; i++) {
if (state.remoteUid.value == state.cacheUsers.value[i].uid && state.cacheUsers.value[i].enableCamera == true) {
if (state.remoteUid.value == state.cacheUsers.value[i].uid &&
state.cacheUsers.value[i].enableCamera == true) {
isCurrentUserIsCamera = true;
}
}
@ -398,11 +402,21 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
debugPrint("wgs输出===SignalR Socket-重连失败$error");
ToastUtils.dismiss();
if ((state.isNormaExit.value == false && state.isShowOkAlertDialog.value == false) || null == UserStore.to.userInfoEntity.value) {
debugPrint(
"wgs输出===SignalR Socket-重连打印1${state.isNormaExit.value == false && state.isShowOkAlertDialog.value == false}");
debugPrint("wgs输出===SignalR Socket-重连打印2${null != UserStore.to.token}");
debugPrint(
"wgs输出===SignalR Socket-重连打印3${UserStore.to.token!.isNotEmpty}");
debugPrint(
"wgs输出===SignalR Socket-重连打印4${(state.isNormaExit.value == false && state.isShowOkAlertDialog.value == false) || null != UserStore.to.token || UserStore.to.token!.isNotEmpty}");
if ((state.isNormaExit.value == false &&
state.isShowOkAlertDialog.value == false) ||
(state.isNormaExit.value == false && null != UserStore.to.token)) {
showOkAlertDialog(
context: Get.context!,
title: "提示",
message: "网络错误,请重新加入会议室",
message: "网络错误,请重新加入会议室1",
okLabel: "确定",
barrierDismissible: false,
).then((OkCancelResult value) {
@ -426,7 +440,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
for (MeetingRoomUser mru in state.cacheUsers.value) {
if (mru.uid == meetingRoomUser.uid) {
mru.roleId = meetingRoomUser.roleId;
if(state.defaulOpenState.value == 1){
if (state.defaulOpenState.value == 1) {
mru.enableMicr = true;
}
mru.isRoomManager = meetingRoomUser.isRoomManager;
@ -571,7 +585,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}
state.users.value = state.cacheUsers.value;
update();
if(listDynamic[0] != UserStore.to.userInfoEntity.value!.uid){
if (listDynamic[0] != UserStore.to.userInfoEntity.value!.uid) {
doHttpGetTvAnchor();
}
debugPrint("wgs输出===Socket-远端用户或主播离开会议室:$jsonStr");
@ -648,8 +662,9 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
if (mru.uid == meetingRoomUser.uid) {
mru.enableCamera = true;
}
debugPrint("wgs输出===Socket-用户单独开摄像头---${state.remoteUid.value}--${meetingRoomUser.uid}");
if(state.remoteUid.value == meetingRoomUser.uid){
debugPrint(
"wgs输出===Socket-用户单独开摄像头---${state.remoteUid.value}--${meetingRoomUser.uid}");
if (state.remoteUid.value == meetingRoomUser.uid) {
doHttpGetTvAnchor();
}
}
@ -687,14 +702,15 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
muteLocalVideoStream(true);
//
stopPreview();
//
if (state.remoteUid.value == "0") {
state.remoteUid.value = "";
}
//
if (state.floating.value?.isShowing == true) {
state.floating.value?.close();
}
//
if (state.remoteUid.value == "0") {
state.remoteUid.value = "";
doHttpGetTvAnchor();
}
}
}
update();
@ -713,8 +729,12 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
///
/// isAgain
Future<void> joinMeetingToSocket(bool isAgain) async {
await state.hubConnection.value?.invoke("joinChannel",
args: [state.roomNumber.value, state.isOpenMicrophone.value, state.isOpenCamera.value, state.isSpeak.value]);
await state.hubConnection.value?.invoke("joinChannel", args: [
state.roomNumber.value,
state.isOpenMicrophone.value,
state.isOpenCamera.value,
state.isSpeak.value
]);
mergeFetch(isAgain);
/*if(isAgain == false){
mergeFetch(isAgain);
@ -765,7 +785,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
//
//
enableVideo();
await enableVideo();
//
await state.rctEngine.value?.setDefaultAudioRouteToSpeakerphone(false);
//
@ -775,8 +795,6 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
await state.rctEngine.value
?.setDualStreamMode(mode: SimulcastStreamMode.enableSimulcastStream);
joinMeetingToRtc();
//
state.rctEngine.value?.registerEventHandler(
RtcEngineEventHandler(
@ -860,20 +878,19 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
int speakerNumber,
int totalVolume) {
if (speakers.isNotEmpty) {
for (AudioVolumeInfo avi in speakers) {
if(avi.uid == 0){
debugPrint("wgs输出===RTC-本地用户音量提示:${avi.uid}--${avi.volume}");
for(MeetingRoomUser mru in state.cacheUsers.value){
if(UserStore.to.userInfoEntity.value!.uid == mru.uid){
if (avi.uid == 0) {
// debugPrint("wgs输出===RTC-本地用户音量提示:${avi.uid}--${avi.volume}");
for (MeetingRoomUser mru in state.cacheUsers.value) {
if (UserStore.to.userInfoEntity.value!.uid == mru.uid) {
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
state.microphoneVolume.value =
CountMicrophoneVolume.getVolume(avi.volume!);
}
}
}else{
debugPrint("wgs输出===RTC-远端用户音量提示:${avi.uid}--${avi.volume}");
for(MeetingRoomUser mru in state.cacheUsers.value){
} else {
// debugPrint("wgs输出===RTC-远端用户音量提示:${avi.uid}--${avi.volume}");
for (MeetingRoomUser mru in state.cacheUsers.value) {
mru.volume = CountMicrophoneVolume.getVolume(avi.volume!);
if (avi.volume != 0) {
@ -947,12 +964,15 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
ToastUtils.showLoadingToMask(
"网络故障,正在重连...", EasyLoadingMaskType.black);
}
} else if (stateType == ConnectionStateType.connectionStateConnected &&
} else if (stateType ==
ConnectionStateType.connectionStateConnected &&
reason ==
ConnectionChangedReasonType.connectionChangedRejoinSuccess) {
ConnectionChangedReasonType
.connectionChangedRejoinSuccess) {
ToastUtils.dismiss();
if (EasyLoading.isShow == false) {
ToastUtils.showSuccessToMask("重连成功!", EasyLoadingMaskType.black);
ToastUtils.showSuccessToMask(
"重连成功!", EasyLoadingMaskType.black);
}
} else if (reason ==
ConnectionChangedReasonType.connectionChangedLost) {
@ -973,6 +993,20 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}
});
}
},
//
onFirstRemoteVideoFrame: (RtcConnection connection, int remoteUid,
int width, int height, int elapsed) async {
debugPrint("wgs输出===RTC-渲染器已接收首帧远端视频回调:${remoteUid}--${width}--${height}--${elapsed}");
},
//
onFirstRemoteVideoDecoded: (RtcConnection connection, int remoteUid,
int width, int height, int elapsed) {
debugPrint("wgs输出===RTC-已接收到远端视频并完成解码回调:${remoteUid}--${width}--${height}--${elapsed}");
}
//
@ -986,6 +1020,7 @@ class MeetingMainLogic extends GetxController with RequestToolMixin {
}*/
),
);
await joinMeetingToRtc();
}
///

View File

@ -101,7 +101,7 @@ class MeetingMainState {
///
final String appId = "4a4f7be64fa1404ebda74784fe9ac381";
late Rx<RtcEngineEx?> rctEngine = Rx(null);
Rx<RtcEngineEx?> rctEngine = Rx<RtcEngineEx?>(null);
///
late RxBool isAutoSubscribeVideo = false.obs;
///

View File

@ -222,8 +222,7 @@ class MeetingMainPageState extends State<MeetingMainPage> {
visible: state.pageState.value == 1,
child: state.isJoinSuccess.value == true &&
null != state.rctEngine.value &&
null != state.users.value &&
state.users.value.isNotEmpty
state.users.isNotEmpty
? Stack(
alignment: Alignment.center,
children: [
@ -305,7 +304,7 @@ class MeetingMainPageState extends State<MeetingMainPage> {
],
)
: Container(
color: ColorUtil.Color_57_57_57,
color: Colors.red,
/*child: Text('加载反馈:是否成功加入会议室${state.isJoinSuccess.value}-会议室对象${state.rctEngine.value}-成员列表${state.users.value.length}-全员观看ID${state.remoteUid.value}'),*/
)),