init function
Implementation
Future<void> init() async {
Directory appDir = await getApplicationDocumentsDirectory();
print("appDir.path:${appDir.path}");
var backgrounService = BackgrounService(AListWebAPIBaseUrl);
while(true) {
var ret = await backgrounService.waitHttpPong();
if (ret != "restarted") {
break;
}
await initBackgroundService();
await Future.delayed(Duration(milliseconds: 400));
}
await backgrounService.setConfigData(appDir.path);
// await Future.delayed(Duration(milliseconds: 50));
await backgrounService.initAList();
await backgrounService.startAList();
SharedPreferences prefs = await SharedPreferences.getInstance();
// 换另一个标志,只有用户设置过的才不重置密码,因为不卸载安装新的开发版密码不正确
if (!prefs.containsKey(PasswordHasBeenSet)) {
await backgrounService.setAdminPassword("admin");
prefs.setBool("PasswordHasBeenSet", true);
}
inited = true;
}