此提交包含多项变更: 1. 新增鸿蒙平台支持,完善设备检测与数据库适配 2. 替换旧版分享插件API为SharePlus 3. 批量迁移StateNotifier到Notifier以适配新版Riverpod 4. 修复zip编码判断、图表API参数等bug 5. 更新应用图标、启动页资源与多尺寸适配图标 6. 调整Android最小SDK版本与应用名称 7. 优化日志打印与正则表达式使用 8. 修正编辑器画布样式初始化与配置逻辑 9. 更新依赖与CI插件配置
41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
// ============================================================
|
|
// 闲言APP — 图片导入服务
|
|
// 创建时间: 2026-05-16
|
|
// 更新时间: 2026-05-16
|
|
// 作用: 图片导入/预处理(裁剪/压缩/格式转换)
|
|
// 上次更新: 初始创建占位实现
|
|
// ============================================================
|
|
|
|
import 'dart:io';
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:file_picker/file_picker.dart';
|
|
import 'package:xianyan/core/utils/logger.dart';
|
|
|
|
class ImageImportService {
|
|
ImageImportService._();
|
|
|
|
static Future<Uint8List?> showImportSheet(BuildContext context) async {
|
|
try {
|
|
final result = await FilePicker.platform.pickFiles(type: FileType.image);
|
|
if (result == null || result.files.isEmpty) return null;
|
|
final file = result.files.first;
|
|
if (file.bytes != null) return file.bytes;
|
|
if (file.path != null) {
|
|
final f = File(file.path!);
|
|
return await f.readAsBytes();
|
|
}
|
|
return null;
|
|
} catch (e) {
|
|
Log.e('图片导入失败', e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
static Future<Uint8List?> preprocessImage(Uint8List bytes) async {
|
|
return bytes;
|
|
}
|
|
}
|