103 lines
3.1 KiB
Dart
Executable File
103 lines
3.1 KiB
Dart
Executable File
import 'dart:async';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:path/path.dart' as path;
|
|
import 'package:star_lock/flavors.dart';
|
|
import 'package:star_lock/mine/about/debug/debug_tool.dart';
|
|
import 'package:star_lock/network/api_provider.dart';
|
|
import 'package:star_lock/network/api_repository.dart';
|
|
import 'package:star_lock/tools/bugly/bugly_tool.dart';
|
|
import 'package:star_lock/tools/device_info_service.dart';
|
|
import 'package:star_lock/tools/platform_info_services.dart';
|
|
import 'package:star_lock/tools/push/xs_jPhush.dart';
|
|
import 'package:star_lock/tools/storage.dart';
|
|
import 'package:star_lock/translations/trans_lib.dart';
|
|
|
|
import 'app.dart';
|
|
import 'app_settings/app_settings.dart';
|
|
import 'tools/store_service.dart';
|
|
|
|
// 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明
|
|
FutureOr<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await _setCommonServices();
|
|
|
|
// 设置国际化信息
|
|
await _initTranslation();
|
|
|
|
final bool isLogin = await getLoginStatus();
|
|
if (isLogin) {
|
|
await privacySDKInitialization();
|
|
}
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
final bool? openDeBug = await Storage.getBool(isOpenDeBug);
|
|
if (openDeBug == true) {
|
|
DeBug.showFloatWidget();
|
|
}
|
|
});
|
|
|
|
runApp(MyApp(isLogin: isLogin));
|
|
|
|
if (AppPlatform.isAndroid) {
|
|
const SystemUiOverlayStyle systemUiOverlayStyle =
|
|
SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
|
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
|
}
|
|
|
|
// checkChinese();
|
|
}
|
|
|
|
// 设置国际化信息
|
|
Future<void> _initTranslation() async => TranslationLoader.loadTranslation();
|
|
|
|
// 设置包名服务设备信息
|
|
Future<void> _setCommonServices() async {
|
|
await Get.putAsync(() => StoreService().init());
|
|
Get.put(ApiProvider());
|
|
Get.put(ApiRepository(Get.find<ApiProvider>()));
|
|
if (F.isLite) {
|
|
//上架审核注释 获取设备信息
|
|
// await Get.putAsync(() => DeviceInfoService().init());
|
|
} else {
|
|
await Get.putAsync(() => DeviceInfoService().init());
|
|
}
|
|
}
|
|
|
|
//关于隐私协议的初始化
|
|
Future<void> privacySDKInitialization() async {
|
|
await Get.putAsync(() => PlatformInfoService().init());
|
|
await BuglyTool.init();
|
|
// 初始化JPush服务
|
|
final XSJPushProvider jpushProvider = XSJPushProvider();
|
|
await jpushProvider.initJPushService();
|
|
}
|
|
|
|
void checkChinese(){
|
|
// 获取当前脚本的目录
|
|
final String scriptDir = path.dirname(Platform.script.path);
|
|
|
|
// 遍历这个目录下的所有 .dart 文件
|
|
findChineseCharacters(Directory(scriptDir));
|
|
}
|
|
|
|
void findChineseCharacters(Directory directory) {
|
|
final List<FileSystemEntity> files = directory.listSync(recursive: true);
|
|
for (FileSystemEntity file in files) {
|
|
if (file is File && file.path.endsWith('.dart')) {
|
|
final String content = file.readAsStringSync(encoding: utf8);
|
|
if (hasChineseCharacters(content)) {
|
|
print('Found Chinese characters in ${file.path}');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool hasChineseCharacters(String input) {
|
|
return RegExp(r'[\u4e00-\u9fa5]').hasMatch(input);
|
|
} |