generated from dellevin/template
windows版本初步完成
This commit is contained in:
@@ -17,19 +17,24 @@ class ImagePathHelper {
|
||||
|
||||
ImagePathHelper._init();
|
||||
|
||||
String? _appDirPath;
|
||||
static String? _appDirPath;
|
||||
|
||||
/// 获取应用文档目录
|
||||
Future<String> get _appDir async {
|
||||
/// 获取应用数据根目录(Windows 下统一到 mooknote 子目录)
|
||||
/// 所有需要访问 images/、epub_books/ 等目录的代码都应使用此方法
|
||||
static Future<String> getAppDir() async {
|
||||
if (_appDirPath != null) return _appDirPath!;
|
||||
final appDir = await getApplicationDocumentsDirectory();
|
||||
_appDirPath = appDir.path;
|
||||
if (Platform.isWindows) {
|
||||
_appDirPath = p.join(appDir.path, 'mooknote');
|
||||
} else {
|
||||
_appDirPath = appDir.path;
|
||||
}
|
||||
return _appDirPath!;
|
||||
}
|
||||
|
||||
/// 获取图片根目录
|
||||
Future<String> get imagesRoot async {
|
||||
final appDir = await _appDir;
|
||||
final appDir = await getAppDir();
|
||||
return p.join(appDir, 'images');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:io' show Platform;
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// 响应式布局断点工具
|
||||
@@ -8,15 +9,24 @@ class Breakpoint {
|
||||
/// ≥900dp: 宽屏内容区(列表-详情并排显示)
|
||||
static const double wideContent = 900.0;
|
||||
|
||||
/// ≥1200dp: 桌面布局(侧边导航 + 宽内容区)
|
||||
static const double desktop = 1200.0;
|
||||
|
||||
static bool isTablet(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width >= tablet;
|
||||
Platform.isWindows || MediaQuery.sizeOf(context).width >= tablet;
|
||||
|
||||
static bool isPhone(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width < tablet;
|
||||
!Platform.isWindows && MediaQuery.sizeOf(context).width < tablet;
|
||||
|
||||
/// 是否使用宽屏内容布局(列表+详情并排)
|
||||
/// 桌面模式下始终为 true(列表已在第二栏,第三栏只显示详情)
|
||||
static bool isWideContent(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width >= wideContent;
|
||||
Platform.isWindows || MediaQuery.sizeOf(context).width >= wideContent;
|
||||
|
||||
/// 是否使用桌面布局(侧边导航 + 宽内容区)
|
||||
/// Windows 平台始终使用桌面布局
|
||||
static bool isDesktop(BuildContext context) =>
|
||||
Platform.isWindows || MediaQuery.sizeOf(context).width >= desktop;
|
||||
}
|
||||
|
||||
/// 根据可用宽度动态计算网格列数
|
||||
|
||||
Reference in New Issue
Block a user