Fix some known issues and add some new functions
Android APK Release / Build Android APK (push) Failing after 52m53s

This commit is contained in:
2026-05-25 20:03:59 +08:00
parent 74abb4a1c5
commit 39d8361080
8 changed files with 587 additions and 221 deletions
+3 -18
View File
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:lucide_icons/lucide_icons.dart';
import '../../core/utils/file_utils.dart';
/// 面包屑导航组件
class FileBreadcrumb extends StatelessWidget {
@@ -14,7 +15,7 @@ class FileBreadcrumb extends StatelessWidget {
@override
Widget build(BuildContext context) {
final pathParts = currentPath.split('/');
final pathParts = FileUtils.toRelativePath(currentPath).split('/');
pathParts.removeWhere((part) => part.isEmpty);
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
@@ -54,7 +55,7 @@ class FileBreadcrumb extends StatelessWidget {
),
_buildBreadcrumbItem(
context,
name: _decodePathSegment(pathParts[i]),
name: FileUtils.decodePathSegment(pathParts[i]),
path: '/${pathParts.sublist(0, i + 1).join('/')}',
icon: null,
primaryColor: colorScheme.primary,
@@ -68,22 +69,6 @@ class FileBreadcrumb extends StatelessWidget {
);
}
String _decodePathSegment(String value) {
var decoded = value;
for (var i = 0; i < 5; i++) {
try {
final next = Uri.decodeComponent(decoded);
if (next == decoded) break;
decoded = next;
} on FormatException {
break;
}
}
return decoded;
}
Widget _buildBreadcrumbItem(
BuildContext context, {
required String name,
+164 -77
View File
@@ -5,6 +5,7 @@ import '../../data/models/file_model.dart';
import '../../core/utils/date_utils.dart' as date_utils;
import '../../core/utils/file_icon_utils.dart';
import '../../core/utils/file_type_utils.dart';
import '../../core/utils/file_utils.dart';
import '../../services/file_service.dart';
import '../../router/app_router.dart';
import 'toast_helper.dart';
@@ -91,52 +92,54 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
child: SafeArea(
right: false,
child: Column(
children: [
Container(
padding: const EdgeInsets.only(
left: 16,
right: 8,
top: 8,
bottom: 12,
),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: theme.dividerColor.withValues(alpha: 0.2)),
children: [
Container(
padding: const EdgeInsets.only(
left: 16,
right: 8,
top: 8,
bottom: 12,
),
),
child: Row(
children: [
FileIconUtils.buildIconWidget(
context: context,
file: widget.file,
size: 32,
iconSize: 18,
borderRadius: 8,
),
const SizedBox(width: 12),
Expanded(
child: Text(
widget.file.name,
style: theme.textTheme.titleMedium,
maxLines: 1,
overflow: TextOverflow.ellipsis,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: theme.dividerColor.withValues(alpha: 0.2),
),
),
IconButton(
icon: const Icon(LucideIcons.x),
onPressed: () => Navigator.of(context).pop(),
),
],
),
child: Row(
children: [
FileIconUtils.buildIconWidget(
context: context,
file: widget.file,
size: 32,
iconSize: 18,
borderRadius: 8,
),
const SizedBox(width: 12),
Expanded(
child: Text(
widget.file.name,
style: theme.textTheme.titleMedium,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
IconButton(
icon: const Icon(LucideIcons.x),
onPressed: () => Navigator.of(context).pop(),
),
],
),
),
),
Expanded(
child: _isLoading
? const Center(child: CircularProgressIndicator())
: _error != null
? _buildError(theme)
: _buildContent(theme, colorScheme),
),
],
Expanded(
child: _isLoading
? const Center(child: CircularProgressIndicator())
: _error != null
? _buildError(theme)
: _buildContent(theme, colorScheme),
),
],
),
),
);
@@ -147,13 +150,21 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(LucideIcons.alertCircle, size: 48, color: theme.colorScheme.error),
Icon(
LucideIcons.alertCircle,
size: 48,
color: theme.colorScheme.error,
),
const SizedBox(height: 12),
Text('加载失败', style: theme.textTheme.titleSmall),
const SizedBox(height: 4),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Text(_error ?? '', style: TextStyle(color: theme.hintColor, fontSize: 12), textAlign: TextAlign.center),
child: Text(
_error ?? '',
style: TextStyle(color: theme.hintColor, fontSize: 12),
textAlign: TextAlign.center,
),
),
const SizedBox(height: 12),
FilledButton.tonal(onPressed: _loadFileInfo, child: const Text('重试')),
@@ -168,10 +179,8 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
? '文件夹'
: FileIconUtils.getFileTypeLabel(file.name);
final extendedInfo = _fileInfo?.extendedInfo;
final versionEntities = extendedInfo?.entities
?.where((e) => e.type == 0)
.toList() ??
[];
final versionEntities =
extendedInfo?.entities?.where((e) => e.type == 0).toList() ?? [];
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
@@ -198,15 +207,27 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
const SizedBox(height: 16),
// 基本信息
_buildInfoRow(LucideIcons.folderOpen, '位置', Uri.decodeComponent(file.relativePath)),
_buildInfoRow(
LucideIcons.folderOpen,
'位置',
FileUtils.decodePathForDisplay(file.relativePath),
),
if (file.isFile)
_buildInfoRow(
LucideIcons.hardDrive,
'大小',
date_utils.DateUtils.formatFileSize(file.size),
),
_buildInfoRow(LucideIcons.calendarPlus, '创建时间', date_utils.DateUtils.formatDateTime(file.createdAt)),
_buildInfoRow(LucideIcons.calendar, '修改时间', date_utils.DateUtils.formatDateTime(file.updatedAt)),
_buildInfoRow(
LucideIcons.calendarPlus,
'创建时间',
date_utils.DateUtils.formatDateTime(file.createdAt),
),
_buildInfoRow(
LucideIcons.calendar,
'修改时间',
date_utils.DateUtils.formatDateTime(file.updatedAt),
),
if (file.owned != null)
_buildInfoRow(LucideIcons.shield, '所有者', file.owned! ? '' : ''),
@@ -215,7 +236,12 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
const SizedBox(height: 12),
Divider(color: theme.dividerColor.withValues(alpha: 0.3)),
const SizedBox(height: 8),
Text('扩展信息', style: theme.textTheme.titleSmall?.copyWith(fontWeight: FontWeight.w600)),
Text(
'扩展信息',
style: theme.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
_buildInfoRow(LucideIcons.fingerprint, '文件ID', file.id),
if (file.primaryEntity != null)
@@ -247,7 +273,12 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
const SizedBox(height: 12),
Divider(color: theme.dividerColor.withValues(alpha: 0.3)),
const SizedBox(height: 8),
Text('文件夹信息', style: theme.textTheme.titleSmall?.copyWith(fontWeight: FontWeight.w600)),
Text(
'文件夹信息',
style: theme.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
_buildFolderSummary(theme, colorScheme),
],
@@ -270,7 +301,12 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
children: [
Row(
children: [
Text('版本历史', style: theme.textTheme.titleSmall?.copyWith(fontWeight: FontWeight.w600)),
Text(
'版本历史',
style: theme.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(width: 8),
Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
@@ -318,7 +354,9 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
required bool isPreviewable,
required FileModel file,
}) {
final shortId = entity.id.length > 6 ? entity.id.substring(0, 6) : entity.id;
final shortId = entity.id.length > 6
? entity.id.substring(0, 6)
: entity.id;
final createdBy = entity.createdBy?.nickname ?? '未知';
return Container(
@@ -340,24 +378,32 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
_buildVersionActionButton(
icon: LucideIcons.externalLink,
tooltip: '打开',
onPressed: _isVersionLoading ? null : () => _openVersion(entity),
onPressed: _isVersionLoading
? null
: () => _openVersion(entity),
),
_buildVersionActionButton(
icon: LucideIcons.download,
tooltip: '下载',
onPressed: _isVersionLoading ? null : () => _downloadVersion(entity),
onPressed: _isVersionLoading
? null
: () => _downloadVersion(entity),
),
if (!isCurrent) ...[
_buildVersionActionButton(
icon: LucideIcons.pin,
tooltip: '设为当前版本',
onPressed: _isVersionLoading ? null : () => _setCurrentVersion(entity),
onPressed: _isVersionLoading
? null
: () => _setCurrentVersion(entity),
),
_buildVersionActionButton(
icon: LucideIcons.trash2,
tooltip: '删除',
color: colorScheme.error,
onPressed: _isVersionLoading ? null : () => _deleteVersion(entity),
onPressed: _isVersionLoading
? null
: () => _deleteVersion(entity),
),
],
];
@@ -403,8 +449,10 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
const SizedBox(height: 1),
Text(
'${date_utils.DateUtils.formatDateTime(entity.createdAt)} · $createdBy',
style: const TextStyle(fontSize: 11, color: null)
.copyWith(color: theme.hintColor),
style: const TextStyle(
fontSize: 11,
color: null,
).copyWith(color: theme.hintColor),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
@@ -449,14 +497,26 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildInfoRow(LucideIcons.hash, 'ID', entity.id),
_buildInfoRow(LucideIcons.hardDrive, '大小', date_utils.DateUtils.formatFileSize(entity.size)),
_buildInfoRow(LucideIcons.calendarPlus, '创建时间', date_utils.DateUtils.formatDateTime(entity.createdAt)),
_buildInfoRow(
LucideIcons.hardDrive,
'大小',
date_utils.DateUtils.formatFileSize(entity.size),
),
_buildInfoRow(
LucideIcons.calendarPlus,
'创建时间',
date_utils.DateUtils.formatDateTime(entity.createdAt),
),
if (createdBy != null) ...[
_buildInfoRow(LucideIcons.user, '创建者', createdBy.nickname),
_buildInfoRow(LucideIcons.fingerprint, '创建者ID', createdBy.id),
],
if (entity.storagePolicy != null)
_buildInfoRow(LucideIcons.server, '存储策略', '${entity.storagePolicy!.name} (${entity.storagePolicy!.type})'),
_buildInfoRow(
LucideIcons.server,
'存储策略',
'${entity.storagePolicy!.name} (${entity.storagePolicy!.type})',
),
if (entity.encryptedWith != null)
_buildInfoRow(LucideIcons.lock, '加密', entity.encryptedWith!),
],
@@ -508,9 +568,13 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
} else if (FileTypeUtils.isAudio(file.name)) {
Navigator.of(context).pushNamed(RouteNames.audioPreview, arguments: args);
} else if (FileTypeUtils.isMarkdown(file.name)) {
Navigator.of(context).pushNamed(RouteNames.markdownPreview, arguments: args);
Navigator.of(
context,
).pushNamed(RouteNames.markdownPreview, arguments: args);
} else if (FileTypeUtils.isTextCode(file.name)) {
Navigator.of(context).pushNamed(RouteNames.documentPreview, arguments: args);
Navigator.of(
context,
).pushNamed(RouteNames.documentPreview, arguments: args);
}
}
@@ -561,12 +625,16 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
Future<void> _deleteVersion(EntityModel entity) async {
final colorScheme = Theme.of(context).colorScheme;
final shortId = entity.id.length > 6 ? entity.id.substring(0, 6) : entity.id;
final shortId = entity.id.length > 6
? entity.id.substring(0, 6)
: entity.id;
final confirmed = await showDialog<bool>(
context: context,
builder: (dialogContext) => AlertDialog(
title: const Text('删除版本'),
content: Text('确定要删除版本 "$shortId" (${date_utils.DateUtils.formatFileSize(entity.size)}) 吗?'),
content: Text(
'确定要删除版本 "$shortId" (${date_utils.DateUtils.formatFileSize(entity.size)}) 吗?',
),
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(false),
@@ -611,15 +679,29 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
children: [
_buildInfoRow(LucideIcons.file, '包含文件', '${summary.files}'),
_buildInfoRow(LucideIcons.folder, '包含文件夹', '${summary.folders}'),
_buildInfoRow(LucideIcons.hardDrive, '总大小', date_utils.DateUtils.formatFileSize(summary.size)),
_buildInfoRow(
LucideIcons.hardDrive,
'总大小',
date_utils.DateUtils.formatFileSize(summary.size),
),
if (!summary.completed)
Padding(
padding: const EdgeInsets.only(top: 8),
child: Row(
children: [
Icon(LucideIcons.alertCircle, size: 14, color: theme.colorScheme.error),
Icon(
LucideIcons.alertCircle,
size: 14,
color: theme.colorScheme.error,
),
const SizedBox(width: 6),
Text('计算未完成,结果可能不完整', style: TextStyle(fontSize: 12, color: theme.colorScheme.error)),
Text(
'计算未完成,结果可能不完整',
style: TextStyle(
fontSize: 12,
color: theme.colorScheme.error,
),
),
],
),
),
@@ -633,7 +715,12 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
}
return _isCalculatingFolder
? const Center(child: Padding(padding: EdgeInsets.all(16), child: CircularProgressIndicator()))
? const Center(
child: Padding(
padding: EdgeInsets.all(16),
child: CircularProgressIndicator(),
),
)
: SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
@@ -655,13 +742,13 @@ class _FileInfoPanelState extends State<FileInfoPanel> {
const SizedBox(width: 8),
SizedBox(
width: 72,
child: Text(label, style: TextStyle(fontSize: 13, color: theme.hintColor)),
child: Text(
label,
style: TextStyle(fontSize: 13, color: theme.hintColor),
),
),
Expanded(
child: SelectableText(
value,
style: const TextStyle(fontSize: 13),
),
child: SelectableText(value, style: const TextStyle(fontSize: 13)),
),
],
),
+26 -12
View File
@@ -2,6 +2,7 @@ import 'package:cloudreve4_flutter/data/models/file_model.dart';
import 'package:cloudreve4_flutter/services/file_service.dart';
import 'package:flutter/material.dart';
import '../../core/utils/app_logger.dart';
import '../../core/utils/file_utils.dart';
/// 文件夹选择器
class FolderPicker extends StatefulWidget {
@@ -61,7 +62,7 @@ class _FolderPickerState extends State<FolderPicker> {
void _enterFolder(FileModel folder) {
setState(() {
_currentPath = folder.path;
_currentPath = folder.relativePath;
});
_loadFolders();
}
@@ -80,7 +81,10 @@ class _FolderPickerState extends State<FolderPicker> {
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: widget.maxVisibleItems != null
? (widget.maxVisibleItems! * 56.0 + 40.0).clamp(80.0, maxHeight)
? (widget.maxVisibleItems! * 56.0 + 40.0).clamp(
80.0,
maxHeight,
)
: maxHeight,
),
child: _buildListContent(context, primaryColor),
@@ -108,7 +112,10 @@ class _FolderPickerState extends State<FolderPicker> {
children: [
Icon(Icons.folder_off, size: 48, color: Colors.grey.shade400),
const SizedBox(height: 12),
Text('此文件夹为空', style: TextStyle(color: Colors.grey.shade600, fontSize: 14)),
Text(
'此文件夹为空',
style: TextStyle(color: Colors.grey.shade600, fontSize: 14),
),
],
),
);
@@ -146,7 +153,13 @@ class _FolderPickerState extends State<FolderPicker> {
),
const SizedBox(width: 12),
Expanded(
child: Text(folder.name, style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500)),
child: Text(
folder.name,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
),
),
),
Icon(Icons.chevron_right, color: Colors.grey.shade400, size: 20),
],
@@ -156,7 +169,7 @@ class _FolderPickerState extends State<FolderPicker> {
}
Widget _buildBreadcrumb(BuildContext context, Color primaryColor) {
final pathParts = _currentPath.split('/');
final pathParts = FileUtils.toRelativePath(_currentPath).split('/');
pathParts.removeWhere((part) => part.isEmpty);
return Column(
@@ -180,8 +193,8 @@ class _FolderPickerState extends State<FolderPicker> {
),
...pathParts.asMap().entries.expand((entry) {
final index = entry.key;
final part = entry.value;
final path = '/${pathParts.sublist(0, index + 1).join('/')}';
final path =
'/${pathParts.sublist(0, index + 1).join('/')}';
return [
Padding(
@@ -194,7 +207,7 @@ class _FolderPickerState extends State<FolderPicker> {
),
_buildBreadcrumbItem(
context,
name: part,
name: FileUtils.decodePathSegment(entry.value),
path: path,
isLast: index == pathParts.length - 1,
primaryColor: primaryColor,
@@ -208,13 +221,14 @@ class _FolderPickerState extends State<FolderPicker> {
const SizedBox(width: 12),
FilledButton.tonal(
onPressed: () {
final relative = _currentPath.startsWith('cloudreve://my')
? _currentPath.replaceFirst('cloudreve://my', '')
: _currentPath;
final relative = FileUtils.toRelativePath(_currentPath);
widget.onFolderSelected(relative.isEmpty ? '/' : relative);
},
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
),
child: const Text('选择'),
),
+41 -27
View File
@@ -6,6 +6,7 @@ import 'package:provider/provider.dart';
import '../../core/utils/date_utils.dart' as date_utils;
import '../../core/utils/file_icon_utils.dart';
import '../../core/utils/file_utils.dart';
import '../../data/models/file_model.dart';
import '../../services/file_service.dart';
import '../../services/storage_service.dart';
@@ -38,7 +39,8 @@ class SearchDialog extends StatefulWidget {
child: FadeTransition(opacity: fadeAnim, child: child),
);
},
pageBuilder: (context, animation, secondaryAnimation) => const SearchDialog(),
pageBuilder: (context, animation, secondaryAnimation) =>
const SearchDialog(),
);
}
@@ -145,8 +147,10 @@ class _SearchDialogState extends State<SearchDialog> {
// 在 async gap 之前获取所有引用
final navProvider = Provider.of<NavigationProvider>(context, listen: false);
final fileManager =
Provider.of<FileManagerProvider>(context, listen: false);
final fileManager = Provider.of<FileManagerProvider>(
context,
listen: false,
);
final parentPath = _extractParentPath(file.path);
final filePath = file.path;
@@ -286,16 +290,20 @@ class _SearchDialogState extends State<SearchDialog> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(LucideIcons.alertCircle,
size: 40, color: colorScheme.error.withValues(alpha: 0.7)),
Icon(
LucideIcons.alertCircle,
size: 40,
color: colorScheme.error.withValues(alpha: 0.7),
),
const SizedBox(height: 8),
Text(_errorMessage!,
style: TextStyle(color: theme.hintColor),
textAlign: TextAlign.center),
Text(
_errorMessage!,
style: TextStyle(color: theme.hintColor),
textAlign: TextAlign.center,
),
const SizedBox(height: 12),
FilledButton.tonal(
onPressed: () =>
_performSearch(_searchController.text.trim()),
onPressed: () => _performSearch(_searchController.text.trim()),
child: const Text('重试'),
),
],
@@ -316,12 +324,13 @@ class _SearchDialogState extends State<SearchDialog> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(LucideIcons.searchX,
size: 40,
color: theme.hintColor.withValues(alpha: 0.5)),
Icon(
LucideIcons.searchX,
size: 40,
color: theme.hintColor.withValues(alpha: 0.5),
),
const SizedBox(height: 8),
Text('未找到匹配文件',
style: TextStyle(color: theme.hintColor)),
Text('未找到匹配文件', style: TextStyle(color: theme.hintColor)),
],
),
),
@@ -330,8 +339,7 @@ class _SearchDialogState extends State<SearchDialog> {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 32),
child: Center(
child: Text('输入关键词搜索文件',
style: TextStyle(color: theme.hintColor)),
child: Text('输入关键词搜索文件', style: TextStyle(color: theme.hintColor)),
),
);
}
@@ -364,17 +372,21 @@ class _SearchDialogState extends State<SearchDialog> {
children: [
Icon(LucideIcons.history, size: 16, color: theme.hintColor),
const SizedBox(width: 6),
Text('搜索历史',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: theme.hintColor)),
Text(
'搜索历史',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: theme.hintColor,
),
),
const Spacer(),
GestureDetector(
onTap: _clearHistory,
child: Text('清除',
style:
TextStyle(fontSize: 12, color: colorScheme.primary)),
child: Text(
'清除',
style: TextStyle(fontSize: 12, color: colorScheme.primary),
),
),
],
),
@@ -416,13 +428,15 @@ class _SearchDialogState extends State<SearchDialog> {
Text(
file.name,
style: const TextStyle(
fontWeight: FontWeight.w500, fontSize: 14),
fontWeight: FontWeight.w500,
fontSize: 14,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
Uri.decodeComponent(file.relativePath),
FileUtils.decodePathForDisplay(file.relativePath),
style: TextStyle(fontSize: 12, color: theme.hintColor),
maxLines: 1,
overflow: TextOverflow.ellipsis,