新增游戏功能记录模块

This commit is contained in:
DelLevin-Home
2026-07-06 01:33:42 +08:00
parent 0ad3713382
commit 4a7296f00f
32 changed files with 5735 additions and 37 deletions

View File

@@ -6,9 +6,11 @@ import 'slide_up_page_route.dart';
import '../pages/movies/movie_form_page.dart';
import '../pages/book/book_form_page.dart';
import '../pages/note/note_form_page.dart';
import '../pages/game/game_form_page.dart';
import '../pages/movies/movie_detail_page.dart';
import '../pages/book/book_detail_page.dart';
import '../pages/note/note_detail_page.dart';
import '../pages/game/game_detail_page.dart';
import '../pages/movies/douban_webview_page.dart';
/// 路由生成器
@@ -59,6 +61,22 @@ class AppRouter {
}
return SlideUpPageRoute(page: NoteDetailPage(note: note));
case '/game-form':
final args = settings.arguments;
final Game? game = args is Game ? args : null;
final String? initialStatus =
args is Map<String, dynamic> ? (args['initialStatus'] as String?) : null;
return SlideUpPageRoute(
page: GameFormPage(game: game, initialStatus: initialStatus),
);
case '/game-detail':
final game = settings.arguments is Game ? settings.arguments as Game : null;
if (game == null) {
return _buildUnknownRoute(settings.name);
}
return SlideUpPageRoute(page: GameDetailPage(game: game));
case '/douban-webview':
final url = settings.arguments is String ? settings.arguments as String : null;
if (url == null) {

View File

@@ -10,6 +10,8 @@ import 'package:path/path.dart' as p;
/// images/movies/{movieId}/posterimgs/xxxx.jpg - 影视海报墙图片
/// images/books/{bookId}/xxxx.jpg - 书籍封面
/// images/notes/{noteId}/xxxx.jpg - 笔记图片
/// images/games/{gameId}/xxxx.jpg - 游戏封面
/// images/games/{gameId}/screenshots/xxxx.jpg - 游戏截图
class ImagePathHelper {
static final ImagePathHelper instance = ImagePathHelper._init();
@@ -93,6 +95,36 @@ class ImagePathHelper {
return p.join(dir, fileName);
}
// ==================== 游戏相关路径 ====================
/// 获取游戏图片目录
/// 路径: images/games/{gameId}/
Future<String> getGameImagesDir(String gameId) async {
final root = await imagesRoot;
return p.join(root, 'games', gameId);
}
/// 获取游戏封面路径
/// 路径: images/games/{gameId}/{fileName}
Future<String> getGameCoverPath(String gameId, String fileName) async {
final dir = await getGameImagesDir(gameId);
return p.join(dir, fileName);
}
/// 获取游戏截图目录
/// 路径: images/games/{gameId}/screenshots/
Future<String> getGameScreenshotImgsDir(String gameId) async {
final dir = await getGameImagesDir(gameId);
return p.join(dir, 'screenshots');
}
/// 获取游戏截图图片路径
/// 路径: images/games/{gameId}/screenshots/{fileName}
Future<String> getGameScreenshotImgPath(String gameId, String fileName) async {
final dir = await getGameScreenshotImgsDir(gameId);
return p.join(dir, fileName);
}
// ==================== 目录操作 ====================
/// 确保目录存在
@@ -129,6 +161,13 @@ class ImagePathHelper {
await _deleteDirectory(dirPath);
}
/// 删除游戏图片目录
/// 删除路径: images/games/{gameId}/
Future<void> deleteGameImages(String gameId) async {
final dirPath = await getGameImagesDir(gameId);
await _deleteDirectory(dirPath);
}
/// 删除目录及其内容
Future<void> _deleteDirectory(String dirPath) async {
try {

View File

@@ -104,6 +104,10 @@ class UserPrefs {
bool get showNoteTab => prefs.getBool('showNoteTab') ?? true;
Future<bool> setShowNoteTab(bool value) => prefs.setBool('showNoteTab', value);
/// 是否显示游戏标签
bool get showGameTab => prefs.getBool('showGameTab') ?? false;
Future<bool> setShowGameTab(bool value) => prefs.setBool('showGameTab', value);
/// 默认启动标签 (0: 影视, 1: 阅读, 2: 笔记)
int get defaultMainTabIndex => prefs.getInt('defaultMainTabIndex') ?? 0;
Future<bool> setDefaultMainTabIndex(int value) => prefs.setInt('defaultMainTabIndex', value);
@@ -169,6 +173,18 @@ class UserPrefs {
bool get bookshelfMode => prefs.getBool('bookshelfMode') ?? false;
Future<bool> setBookshelfMode(bool value) => prefs.setBool('bookshelfMode', value);
/// 游戏排序方式 (0: 更新时间, 1: 创建时间, 2: 评分)
int get gameSortMode => prefs.getInt('gameSortMode') ?? 0;
Future<bool> setGameSortMode(int value) => prefs.setInt('gameSortMode', value);
/// 游戏布局样式 (0: 网格, 1: 列表, 2: 大图卡片)
int get gameLayoutStyle => prefs.getInt('gameLayoutStyle') ?? 0;
Future<bool> setGameLayoutStyle(int value) => prefs.setInt('gameLayoutStyle', value);
/// 游戏墙模式
bool get gameWallMode => prefs.getBool('gameWallMode') ?? false;
Future<bool> setGameWallMode(bool value) => prefs.setBool('gameWallMode', value);
// ========== 应用图标设置 ==========
// ========== Markdown 阅读器 ==========