主要变更: 1. 重构"国学"相关模块为"经典名句",统一命名规范 2. 重命名"阅读报告"为"使用报告",调整相关文案与配置 3. 修复iOS模拟器图片缓存兼容问题,优化图表渲染逻辑 4. 新增设备活跃状态前端兜底判断,修复在线计数异常 5. 完善登录/注册流程,新增忘记密码路由与账户编辑提示 6. 优化文件传输与字体导入逻辑,废弃过时的bytes属性使用 7. 添加Spotlight全局快捷键支持,更新隐私权限与通知配置 8. 补充数据库迁移脚本与部署文档,修复后端接口兼容问题 9. 调整部分UI交互细节,优化内存占用与应用稳定性
42 lines
1.2 KiB
Dart
42 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.pickFiles(type: FileType.image);
|
|
if (result == null || result.files.isEmpty) return null;
|
|
final file = result.files.first;
|
|
// 优先通过路径读取,避免使用已废弃的 bytes 属性
|
|
if (file.path != null) {
|
|
final f = File(file.path!);
|
|
return await f.readAsBytes();
|
|
}
|
|
// 路径不可用时回退到 readAsBytes
|
|
return await file.readAsBytes();
|
|
} catch (e) {
|
|
Log.e('图片导入失败', e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
static Future<Uint8List?> preprocessImage(Uint8List bytes) async {
|
|
return bytes;
|
|
}
|
|
}
|