|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
|
|
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:get_storage/get_storage.dart';
|
|
|
|
import 'package:isekai_wiki/global.dart';
|
|
|
|
import 'package:isekai_wiki/models/lifecycle.dart';
|
|
|
|
import 'package:isekai_wiki/models/site_config.dart';
|
|
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
|
|
|
|
|
|
import 'app.dart';
|
|
|
|
|
|
|
|
Future<void> init() async {
|
|
|
|
// 仅允许竖屏
|
|
|
|
/*SystemChrome.setPreferredOrientations(
|
|
|
|
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);*/
|
|
|
|
SystemChrome.setSystemUIOverlayStyle(
|
|
|
|
const SystemUiOverlayStyle(statusBarColor: Colors.transparent));
|
|
|
|
|
|
|
|
if (kIsWeb) {
|
|
|
|
// 设置web origin
|
|
|
|
Global.webOrigin = Uri.base.origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
await GetStorage.init();
|
|
|
|
|
|
|
|
// 检测是否已激活
|
|
|
|
var storage = GetStorage();
|
|
|
|
Global.isAppActive = storage.read<bool>("appActive") ?? false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> postInit() async {
|
|
|
|
Global.packageInfo = await PackageInfo.fromPlatform();
|
|
|
|
|
|
|
|
if (!kIsWeb && GetPlatform.isAndroid) {
|
|
|
|
// 启用高刷
|
|
|
|
try {
|
|
|
|
if (kDebugMode) {
|
|
|
|
var modes = await FlutterDisplayMode.supported;
|
|
|
|
print("Refresh rate list:");
|
|
|
|
// ignore: avoid_print
|
|
|
|
modes.forEach(print);
|
|
|
|
print("Preferred refresh rate:");
|
|
|
|
print(await FlutterDisplayMode.preferred);
|
|
|
|
}
|
|
|
|
await FlutterDisplayMode.setHighRefreshRate();
|
|
|
|
} catch (err) {
|
|
|
|
if (kDebugMode) {
|
|
|
|
print("Cannot set to high refresh rate: ");
|
|
|
|
print(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
if (GetPlatform.isAndroid) {
|
|
|
|
await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> main() async {
|
|
|
|
await init();
|
|
|
|
|
|
|
|
Get.put(LifeCycleController());
|
|
|
|
Get.put(SiteConfigController());
|
|
|
|
|
|
|
|
runApp(const IsekaiWikiApp());
|
|
|
|
|
|
|
|
postInit();
|
|
|
|
}
|