release
This commit is contained in:
@@ -1,14 +1,49 @@
|
||||
/// 时间: 2025-03-21
|
||||
/// 功能: 应用配置文件
|
||||
/// 介绍: 包含应用的所有配置常量,包括响应式布局、主题、API等配置
|
||||
/// 最新变化: 从根目录config移动到lib/config目录
|
||||
/// 最新变化: 从根目录config移动到lib/config目录,使用package_info_plus动态获取版本号
|
||||
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AppConfig {
|
||||
// 应用基础配置
|
||||
static const String appName = '情景诗词';
|
||||
static const String appVersion = '1.3.31';
|
||||
static const String appDescription = 'A new Flutter project';
|
||||
static const int appVersionCode = 26040206;
|
||||
static const String _fallbackAppVersion = '1.4.1';
|
||||
static const int _fallbackAppVersionCode = 26040202;
|
||||
static const String appDescription = '腹有诗书气自华';
|
||||
|
||||
static PackageInfo? _packageInfo;
|
||||
static bool _isInitialized = false;
|
||||
static final RxString _rxAppVersion = _fallbackAppVersion.obs;
|
||||
static final RxInt _rxAppVersionCode = _fallbackAppVersionCode.obs;
|
||||
|
||||
static Future<void> init() async {
|
||||
if (_isInitialized) return;
|
||||
try {
|
||||
_packageInfo = await PackageInfo.fromPlatform();
|
||||
_rxAppVersion.value = _packageInfo?.version ?? _fallbackAppVersion;
|
||||
_rxAppVersionCode.value =
|
||||
int.tryParse(_packageInfo?.buildNumber ?? '') ??
|
||||
_fallbackAppVersionCode;
|
||||
_isInitialized = true;
|
||||
} catch (e) {
|
||||
print('获取版本信息失败: $e');
|
||||
_packageInfo = null;
|
||||
_isInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
static String get appVersion {
|
||||
return _rxAppVersion.value;
|
||||
}
|
||||
|
||||
static int get appVersionCode {
|
||||
return _rxAppVersionCode.value;
|
||||
}
|
||||
|
||||
static RxString get rxAppVersion => _rxAppVersion;
|
||||
static RxInt get rxAppVersionCode => _rxAppVersionCode;
|
||||
|
||||
// 响应式布局断点
|
||||
static const double mobileBreakpoint = 768.0;
|
||||
|
||||
Reference in New Issue
Block a user