From 8287518fc18aa2f6509871ca99cfd2af9ea3b5d8 Mon Sep 17 00:00:00 2001 From: "1147192855@qq.com" <1147192855@qq.com> Date: Wed, 15 May 2024 14:00:37 +0800 Subject: [PATCH] no message --- .../model/marking/marking_text_question.dart | 2 +- .../lib/components/PictureOverview.dart | 3 +- marking_app/lib/pages/mainPage.dart | 2 +- .../lib/provider/upload_file_provider.dart | 35 ++++++++++++------- .../lib/utils/request/rest_client.dart | 4 +++ 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/marking_app/lib/common/model/marking/marking_text_question.dart b/marking_app/lib/common/model/marking/marking_text_question.dart index 12adc1c..d917720 100644 --- a/marking_app/lib/common/model/marking/marking_text_question.dart +++ b/marking_app/lib/common/model/marking/marking_text_question.dart @@ -146,7 +146,7 @@ class MarkingTextQuestion extends Object { for (var i = 0; i < commentImageUrl.length; i++) { var element = commentImageUrl[i]; var originalImage = studentAnswerList[i]; - commentImageUrlMap[originalImage] = '$element?${DateTime.now().millisecondsSinceEpoch}'; + commentImageUrlMap[originalImage] = 'https:$element?${DateTime.now().millisecondsSinceEpoch}'; } } else { for (var element in studentAnswerList) { diff --git a/marking_app/lib/components/PictureOverview.dart b/marking_app/lib/components/PictureOverview.dart index 8bb4258..d9e4fb4 100644 --- a/marking_app/lib/components/PictureOverview.dart +++ b/marking_app/lib/components/PictureOverview.dart @@ -216,7 +216,8 @@ class PictureOverviewState extends ConsumerState with CommonMix crypto.Digest fileMd5 = crypto.md5.convert(await temFile!.readAsBytes()); RestClient _client = await getClient(); - BaseStructureResult resUploadConfig = await _client.getUploadFile(UploadFileInterfaceConfigParams( + + BaseStructureResult resUploadConfig = await _client.getMarkingUploadFile(UploadFileInterfaceConfigParams( fileName: '1.png', fileMd5: fileMd5.toString(), contentLength: temFile!.lengthSync(), diff --git a/marking_app/lib/pages/mainPage.dart b/marking_app/lib/pages/mainPage.dart index 7bea9b9..82c2aed 100644 --- a/marking_app/lib/pages/mainPage.dart +++ b/marking_app/lib/pages/mainPage.dart @@ -107,7 +107,7 @@ class TheMainPageState extends ConsumerState with CommonMixin { } void getAppUpgrade(UserInfo user) async { - // if (!bool.fromEnvironment('dart.vm.product')) return; + if (!bool.fromEnvironment('dart.vm.product')) return; try { showUpgrade = true; if (['18888888888'].contains(user.loginName)) return; diff --git a/marking_app/lib/provider/upload_file_provider.dart b/marking_app/lib/provider/upload_file_provider.dart index 6b85b02..044e6de 100644 --- a/marking_app/lib/provider/upload_file_provider.dart +++ b/marking_app/lib/provider/upload_file_provider.dart @@ -22,8 +22,8 @@ import 'package:marking_app/utils/request/rest_client.dart'; // API -final uploadFileProvider = StateNotifierProvider( - (ref) => UploadFileProviderHandle(UploadImgSecretKey())); +final uploadFileProvider = + StateNotifierProvider((ref) => UploadFileProviderHandle(UploadImgSecretKey())); class UploadFileProviderHandle extends StateNotifier with CommonMixin { // Minio? _minio; @@ -109,24 +109,35 @@ class UploadFileProviderHandle extends StateNotifier with Co Future getUploadFileConfig(UploadFileInterfaceConfig uploadConfig, File fileData) async { Dio dio = Dio(); + dio.options.contentType = null; try { late Response response; final bytes = await fileData.readAsBytes(); if (uploadConfig.uploadMethod == "PUT") { - response = await dio.put(uploadConfig.uploadUri!, - data: Stream.fromIterable(bytes.map((e) => [e])), - options: Options(headers: { + response = await dio.put( + uploadConfig.uploadUri!, + data: Stream.fromIterable(bytes.map((e) => [e])), + options: Options( + contentType: null, + headers: { Headers.contentLengthHeader: bytes.length, // Set the content-length. - HttpHeaders.contentTypeHeader: 'image/png', - })); + // HttpHeaders.contentTypeHeader: 'image/png', + }, + ), + ); } else if (uploadConfig.uploadMethod == "POST") { - response = await dio.post(uploadConfig.uploadUri!, - data: Stream.fromIterable(bytes.map((e) => [e])), - options: Options(headers: { + response = await dio.post( + uploadConfig.uploadUri!, + data: Stream.fromIterable(bytes.map((e) => [e])), + options: Options( + contentType: null, + headers: { Headers.contentLengthHeader: bytes.length, // Set the content-length. - HttpHeaders.contentTypeHeader: 'image/png', - })); + // HttpHeaders.contentTypeHeader: 'image/png', + }, + ), + ); } print('文件上传成功:${response.data}'); if ([200, 201, 204].contains(response.statusCode)) { diff --git a/marking_app/lib/utils/request/rest_client.dart b/marking_app/lib/utils/request/rest_client.dart index ac772d0..a6a81d8 100644 --- a/marking_app/lib/utils/request/rest_client.dart +++ b/marking_app/lib/utils/request/rest_client.dart @@ -190,6 +190,10 @@ abstract class RestClient { @the_retrofit.GET("/api/marking/rating-info") Future>> getMarkingRatingInfo(@the_retrofit.Query("markingUserId") int id); + // 阅卷 => 上传图片请求参数 + @the_retrofit.GET("/api/Upload") + Future> getMarkingUploadFile(@the_retrofit.Queries() UploadFileInterfaceConfigParams params); + // ------------------------------------------ 作业 ------------------------------------------ // 作业 => 作业列表