Merge remote-tracking branch 'origin/main'

# Conflicts:
#	.flutter-plugins-dependencies
#	.idea/libraries/Dart_Packages.xml
#	.idea/libraries/Flutter_Plugins.xml
#	example/pubspec.lock
#	pubspec.lock
This commit is contained in:
2026-04-16 10:40:36 +08:00
7 changed files with 128 additions and 22 deletions

View File

@@ -241,6 +241,42 @@
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "flutter_image_compress",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress-2.4.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "flutter_image_compress_common",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_common-1.0.6",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "flutter_image_compress_macos",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_macos-1.0.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "flutter_image_compress_ohos",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_ohos-0.0.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "flutter_image_compress_platform_interface",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_platform_interface-1.0.5",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "flutter_image_compress_web",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/flutter_image_compress_web-0.1.5",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "flutter_inappwebview",
"rootUri": "file:///Users/threeone/.pub-cache/hosted/pub.flutter-io.cn/flutter_inappwebview-6.1.5",
@@ -649,6 +685,18 @@
"packageUri": "lib/",
"languageVersion": "3.8"
},
{
"name": "photo_manager",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/photo_manager-3.8.3",
"packageUri": "lib/",
"languageVersion": "2.13"
},
{
"name": "photo_manager_image_provider",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/photo_manager_image_provider-2.2.0",
"packageUri": "lib/",
"languageVersion": "2.13"
},
{
"name": "photo_view",
"rootUri": "file:///Users/threeone/.pub-cache/hosted/pub.flutter-io.cn/photo_view-0.15.0",
@@ -1015,6 +1063,18 @@
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "wechat_assets_picker",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/wechat_assets_picker-10.1.0",
"packageUri": "lib/",
"languageVersion": "3.6"
},
{
"name": "wechat_picker_library",
"rootUri": "file:///Users/wxl/.pub-cache/hosted/pub.flutter-io.cn/wechat_picker_library-1.0.7",
"packageUri": "lib/",
"languageVersion": "3.4"
},
{
"name": "win32",
"rootUri": "file:///Users/threeone/.pub-cache/hosted/pub.flutter-io.cn/win32-5.15.0",

View File

@@ -19,8 +19,8 @@ class HttpUtils {
BaseOptions options = BaseOptions(
baseUrl: baseUrl,
contentType: 'application/json; charset=utf-8',
connectTimeout: const Duration(milliseconds: 15000),
receiveTimeout: const Duration(milliseconds: 15000),
connectTimeout: const Duration(seconds: 60),
receiveTimeout: const Duration(seconds: 60),
responseType: ResponseType.json,
validateStatus: (status) {
return true;

View File

@@ -77,6 +77,10 @@ class UploadOss {
);
print("response ===== $response");
EasyLoading.dismiss();
if(fileType == 'jpg'){
/// 删除临时文件
File(path).deleteSync();
}
// 成功后返回文件访问路径
return "$ossHost/$ossDirectory$pathName";
} on DioError catch (e) {

View File

@@ -280,7 +280,7 @@ class _UploadImagesState extends State<UploadImages> {
title: const Text('上传图片'),
message: (max == null || max == 0)
? null
: Text('请选择上传方式\n相册最多${max ?? 9}'),
: Text('请选择上传方式\n相册最多$max张'),
actions: <Widget>[
CupertinoActionSheetAction(
child: const Text('拍照上传'),

View File

@@ -1,13 +1,16 @@
import 'dart:io';
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter_common/upload_image/ossUtil.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
// import 'package:images_picker/images_picker.dart';
// import 'package:images_picker/images_picker.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
class UploadImagesTool {
static uploadImagesTool({
@@ -136,9 +139,7 @@ class UploadImagesTool {
)
: CupertinoActionSheet(
title: const Text('上传图片'),
message: (max == null || max == 0)
? null
: Text('请选择上传方式\n相册最多${max ?? 9}'),
message: (max == null || max == 0) ? null : Text('请选择上传方式\n相册最多${max}'),
actions: isAddOtherWidget != null
? <Widget>[
isAddOtherWidget,
@@ -152,8 +153,7 @@ class UploadImagesTool {
policy: policy ?? '',
callback: callback ?? '',
signature: signature ?? '',
chooseImages: (list) =>
chooseImages?.call(list),
chooseImages: (list) => chooseImages?.call(list),
);
Get.back();
},
@@ -169,8 +169,7 @@ class UploadImagesTool {
policy: policy ?? '',
callback: callback ?? '',
signature: signature ?? '',
chooseImages: (list) =>
chooseImages?.call(list),
chooseImages: (list) => chooseImages?.call(list),
);
Get.back();
},
@@ -187,8 +186,7 @@ class UploadImagesTool {
policy: policy ?? '',
callback: callback ?? '',
signature: signature ?? '',
chooseImages: (list) =>
chooseImages?.call(list),
chooseImages: (list) => chooseImages?.call(list),
);
Get.back();
},
@@ -205,8 +203,7 @@ class UploadImagesTool {
callback: callback ?? '',
signature: signature ?? '',
isShowLoading: isShowLoading,
chooseImages: (list) =>
chooseImages?.call(list),
chooseImages: (list) => chooseImages?.call(list),
);
Get.back();
},
@@ -235,6 +232,9 @@ class UploadImagesTool {
}) async {
XFile? file = await ImagePicker().pickImage(
source: ImageSource.camera,
maxHeight: 1080,
maxWidth: 1920,
imageQuality: 80
);
if (file == null) {
Get.back();
@@ -265,7 +265,11 @@ class UploadImagesTool {
bool? isShowLoading,
}) async {
if (isVideo == true) {
XFile? video = await ImagePicker().pickVideo(source: ImageSource.gallery);
final List<AssetEntity>? result = await AssetPicker.pickAssets(
Get.context!,
pickerConfig: AssetPickerConfig(maxAssets: 1, requestType: RequestType.video),
);
final File? video = await result?.first.file;
String path = await saveNetworkImgGallery(
video?.path ?? '',
fileType: 'mp4',
@@ -277,11 +281,34 @@ class UploadImagesTool {
signature: signature ?? '',
);
chooseImages?.call([path]);
print('video path ============ $path');
} else {
List<XFile>? images = await ImagePicker().pickMultiImage();
/// 创建临时目录
final Directory tempDir = Directory.systemTemp.createTempSync('compressed_images_');
final List<AssetEntity>? result = await AssetPicker.pickAssets(
Get.context!,
pickerConfig: AssetPickerConfig(maxAssets: max ?? 50),
);
/// 临时存储选中的图片
final List<XFile> selectedFiles = [];
if (result != null && result.isNotEmpty) {
for (int i = 0; i < result.length; i++) {
final File? file = await result[i].file;
if (file != null) {
/// 获取文件扩展名
final String extension = file.absolute.path.split('.').last;
/// 压缩并保存到临时文件
final XFile? compressedFile = await FlutterImageCompress.compressAndGetFile(
file.absolute.path, '${tempDir.path}/${DateTime.now().millisecondsSinceEpoch}_compressed.$extension',
quality: 80, minWidth: 1920, minHeight: 1080);
if (compressedFile != null) {
selectedFiles.add(compressedFile);
}
}
}
}
/// 上传选中的图片
List<String> list = [];
for (var element in images) {
for (var element in selectedFiles) {
String path = await saveNetworkImgGallery(
element.path,
oSSAccessKeyId: oSSAccessKeyId ?? '',
@@ -333,7 +360,7 @@ class UploadImagesTool {
String? signature,
String? ossDirectory,
String? ossHost,
bool? isShowLoading,
bool? isShowLoading,
}) async {
String string = await UploadOss.upload(
path,

View File

@@ -96,16 +96,29 @@ class CustomerImagesNetworking extends StatelessWidget {
@override
Widget build(BuildContext context) {
String? sizeParams = '';
int tempHeight = 300;
int tempWidth = 300;
if (height != null) {
sizeParams = '?x-oss-process=image/resize,h_$tempHeight,w_$tempHeight';
}
if (width != null) {
tempWidth = width!.toInt() <= 300 ? 300 : width!.toInt();
sizeParams = '?x-oss-process=image/resize,h_$tempWidth,w_$tempWidth';
}
if (height != null && width != null) {
tempHeight = height!.toInt() <= 300 ? 300 : height!.toInt();
sizeParams = '?x-oss-process=image/resize,h_$tempHeight,w_$tempWidth';
}
return CachedNetworkImage(
imageUrl: imageUrl,
imageUrl: imageUrl + sizeParams,
width: width,
height: height,
fit: fit,
errorWidget: (_, object, s) {
return Container(
return SizedBox(
width: width,
height: height,
padding: EdgeInsets.all((width ?? 0) / 2),
child: Center(
child: Image.asset(
'assets/images/noContainer.png',

View File

@@ -42,6 +42,8 @@ dependencies:
image_editor_plus: ^1.0.6
path_provider: ^2.1.5
cached_network_image: ^3.4.1
wechat_assets_picker: ^10.1.0
flutter_image_compress: ^2.4.0
dev_dependencies:
flutter_test: