处理部分问题

This commit is contained in:
1147192855@qq.com 2024-11-07 10:09:17 +08:00
parent 1ec5c5eb62
commit 261d1ad4a4
6 changed files with 35 additions and 53 deletions

View File

@ -20,8 +20,8 @@ class RequestConfig {
static const connectTimeout = 8000; // static const connectTimeout = 8000; //
static const receiveTimeout = 8000; // static const receiveTimeout = 8000; //
static const bool requestDataPrinting = false; // static const bool requestDataPrinting = true; //
static const bool printSwitch = false; // static const bool printSwitch = true; //
static const successCode = [204, 200]; // code static const successCode = [204, 200]; // code
static final BasePage basePage = BasePage(1, 10); // static final BasePage basePage = BasePage(1, 10); //

View File

@ -9,14 +9,14 @@ import 'package:functional_widget_annotation/functional_widget_annotation.dart';
part 'cached_network_img.g.dart'; part 'cached_network_img.g.dart';
@hwidget @hwidget
Widget $theCachedNetworkImage(ImageWidgetBuilder imageBuilder, {required String imageUrl}) { Widget $theCachedNetworkImage(ImageWidgetBuilder imageBuilder, {required String imageUrl, double? imgWidth}) {
UseCachedImgRefresh useImgRefsh = UseCachedImgRefresh.use(); UseCachedImgRefresh useImgRefsh = UseCachedImgRefresh.use();
return CachedNetworkImage( return CachedNetworkImage(
key: useImgRefsh.imageKey.value, key: useImgRefsh.imageKey.value,
cacheKey: imageUrl, cacheKey: imageUrl,
fit: BoxFit.fitWidth, fit: BoxFit.fitWidth,
width: double.infinity, width: imgWidth ?? double.infinity,
imageUrl: imageUrl, imageUrl: imageUrl,
imageBuilder: imageBuilder, imageBuilder: imageBuilder,
placeholder: (context, url) => Center(child: SpinKitWave(color: Theme.of(context).primaryColor, size: 50.r)), placeholder: (context, url) => Center(child: SpinKitWave(color: Theme.of(context).primaryColor, size: 50.r)),

View File

@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:functional_widget_annotation/functional_widget_annotation.dart'; import 'package:functional_widget_annotation/functional_widget_annotation.dart';
import 'package:gesture_zoom_box/gesture_zoom_box.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_bus.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_paper_bus.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_param.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_param.dart';
@ -632,6 +631,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
children: [ children: [
$TheCachedNetworkImage( $TheCachedNetworkImage(
imageUrl: imageUrl, imageUrl: imageUrl,
imgWidth: maxWidth,
(context, imageProvider) { (context, imageProvider) {
Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth); Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth);
imageStream?.removeListener(imageStreamListener.value); imageStream?.removeListener(imageStreamListener.value);
@ -648,6 +648,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
foregroundPainter: DrawingPainter(ctrl: vnHandWritings), foregroundPainter: DrawingPainter(ctrl: vnHandWritings),
child: showZgtAnnotate != null child: showZgtAnnotate != null
? $TheCachedNetworkImage( ? $TheCachedNetworkImage(
imgWidth: maxWidth,
imageUrl: showZgtAnnotate, imageUrl: showZgtAnnotate,
(_, imageProvider) => Image(image: imageProvider, fit: BoxFit.fitWidth), (_, imageProvider) => Image(image: imageProvider, fit: BoxFit.fitWidth),
) )

View File

@ -61,8 +61,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
late StreamSubscription<DoPaperDetailsParam> _paramListen; late StreamSubscription<DoPaperDetailsParam> _paramListen;
late StreamSubscription<DoPaperDetailsResult?> _dataListen; late StreamSubscription<DoPaperDetailsResult?> _dataListen;
final HomeworkReviewState state = HomeworkReviewState(); final HomeworkReviewState state = HomeworkReviewState();
final HomeworkReviewAnnotationsControlState annotationState = final HomeworkReviewAnnotationsControlState annotationState = HomeworkReviewAnnotationsControlState();
HomeworkReviewAnnotationsControlState();
@override @override
void onInit() { void onInit() {
@ -92,11 +91,9 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
} }
void getData() async { void getData() async {
var timerControl = Timer( var timerControl = Timer(const Duration(milliseconds: 300), () => ToastUtils.showLoading());
const Duration(milliseconds: 300), () => ToastUtils.showLoading());
try { try {
DoPaperDetailsResult? data = DoPaperDetailsResult? data = await getClient().getDoPaperDetails(state.param.value);
await getClient().getDoPaperDetails(state.param.value);
// var studentQuestions = data.studentQuestions; // var studentQuestions = data.studentQuestions;
// // 0 // // 0
// for (var i = 0; i < studentQuestions.length; i++) { // for (var i = 0; i < studentQuestions.length; i++) {
@ -110,7 +107,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
state.studentQuestions.value = data.studentQuestions; state.studentQuestions.value = data.studentQuestions;
} catch (e) { } catch (e) {
print('获取数据报错了:$e'); print('获取数据报错了:$e');
ToastUtils.showError('获取试题数据出错,请重试'); ToastUtils.showError('获取试题数据,请重试');
state.getDataError.value = true; state.getDataError.value = true;
} finally { } finally {
if (timerControl.isActive) timerControl.cancel(); if (timerControl.isActive) timerControl.cancel();
@ -168,16 +165,12 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
if (data == null) return null; if (data == null) return null;
// OSS url // OSS url
String imgKey = UploadOssImgUtils.getInstance().setImgKey( String imgKey = UploadOssImgUtils.getInstance().setImgKey(param.homeworkId, data.studentId.toString(), data.templateId.toString());
param.homeworkId,
data.studentId.toString(),
data.templateId.toString());
var resUrl = await getClient().getOssPresignedUri(imgKey); var resUrl = await getClient().getOssPresignedUri(imgKey);
if (resUrl == null) return null; if (resUrl == null) return null;
// //
RenderRepaintBoundary? boundary = pictureOverviewKey.currentContext! RenderRepaintBoundary? boundary = pictureOverviewKey.currentContext!.findRenderObject() as RenderRepaintBoundary?;
.findRenderObject() as RenderRepaintBoundary?;
if (boundary == null) return null; if (boundary == null) return null;
// double dpr = MediaQuery.of(context).devicePixelRatio; // double dpr = MediaQuery.of(context).devicePixelRatio;
@ -189,20 +182,16 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
} }
ui.Image image = await boundary.toImage(pixelRatio: pixelRatio); ui.Image image = await boundary.toImage(pixelRatio: pixelRatio);
ByteData? byteData = ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
await image.toByteData(format: ui.ImageByteFormat.png);
if (byteData == null) return null; if (byteData == null) return null;
Dio dio = Dio(); Dio dio = Dio();
dio.options.contentType = null; dio.options.contentType = null;
List<int> bytes = byteData.buffer List<int> bytes = byteData.buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes);
.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes);
await dio.put( await dio.put(
resUrl, resUrl,
data: Stream.fromIterable(bytes.map((e) => [e])), data: Stream.fromIterable(bytes.map((e) => [e])),
options: Options( options: Options(contentType: null, headers: {Headers.contentLengthHeader: bytes.length}),
contentType: null,
headers: {Headers.contentLengthHeader: bytes.length}),
); );
return imgKey; return imgKey;
@ -224,8 +213,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
if (state.data.value?.studentQuestions.isEmpty ?? true) return; if (state.data.value?.studentQuestions.isEmpty ?? true) return;
var studentQuestions = state.data.value!.studentQuestions; var studentQuestions = state.data.value!.studentQuestions;
var noRatingElement = var noRatingElement = studentQuestions.firstWhereOrNull((e) => e.studentScore == null);
studentQuestions.firstWhereOrNull((e) => e.studentScore == null);
if (noRatingElement != null) { if (noRatingElement != null) {
ToastUtils.showInfo('${noRatingElement.questionNo}题请评分'); ToastUtils.showInfo('${noRatingElement.questionNo}题请评分');
return; return;

View File

@ -7,6 +7,7 @@ import 'package:making_school_asignment_app/page/global_widget/my_text.dart';
import 'package:making_school_asignment_app/page/home_page/children/annotate_class/annotate_class_logic.dart'; import 'package:making_school_asignment_app/page/home_page/children/annotate_class/annotate_class_logic.dart';
import 'package:making_school_asignment_app/page/home_page/children/homework_review/components/question_paper_view.dart'; import 'package:making_school_asignment_app/page/home_page/children/homework_review/components/question_paper_view.dart';
import 'package:making_school_asignment_app/page/home_page/home_logic.dart'; import 'package:making_school_asignment_app/page/home_page/home_logic.dart';
import 'package:zoom_widget/zoom_widget.dart';
import 'components/bottom_operation_bar.dart'; import 'components/bottom_operation_bar.dart';
import 'components/dropdown_switch_students_type.dart'; import 'components/dropdown_switch_students_type.dart';
@ -62,33 +63,24 @@ class _HomeworkReviewState extends State<HomeworkReview> {
elevation: 0, elevation: 0,
actions: [const FavoriteWidget(), SizedBox(width: 5.w), const ReturnToHomepage()], actions: [const FavoriteWidget(), SizedBox(width: 5.w), const ReturnToHomepage()],
), ),
body: SafeArea( body: Column(
child: Column(
children: [ children: [
// //
const DropdownSwitchStudentsType(), const DropdownSwitchStudentsType(),
SizedBox(height: 1.h), SizedBox(height: 1.h),
const Expanded(child: QuestionPaperView() const Expanded(
// child: CustomZoomWidget( child: QuestionPaperView(),
// child: Image.network('https://cdn3-banquan.ituchong.com/weili/image/l/903170934517792920.jpeg'),
// ), // child: Container(
// child: CustomZoomWidget( // height: double.infinity,
// child: Image.network('https://cdn3-banquan.ituchong.com/weili/image/l/903170934517792920.jpeg'), // width: double.infinity,
// minScale: 0.8, // color: Colors.red,
// maxScale: 4,
// resetDuration: const Duration(milliseconds: 200),
// boundaryMargin: const EdgeInsets.only(bottom: 0),
// clipBehavior: Clip.hardEdge,
// useOverlay: false,
// maxOverlayOpacity: 0.5,
// overlayColor: Colors.black,
// fingersRequiredToPinch: 2,
// ), // ),
// child: QuestionPaperView(),
), ),
const BottomAnnotationSwitch() const BottomAnnotationSwitch()
], ],
), ),
),
// floatingActionButton: const ButtonFloatingAction(), // floatingActionButton: const ButtonFloatingAction(),
// floatingActionButtonLocation: FloatingActionButtonLocation.startFloat, // floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
), ),

View File

@ -97,6 +97,7 @@ dependencies:
icons_launcher: ^2.1.7 icons_launcher: ^2.1.7
app_settings: ^5.1.1 app_settings: ^5.1.1
device_info_plus: ^11.1.0 device_info_plus: ^11.1.0
zoom_widget: ^2.0.1