mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
new: use foreground service to keep ssh conn (#265)
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/analysis.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/locale.dart';
|
||||
import 'package:toolbox/core/update.dart';
|
||||
import 'package:toolbox/core/utils/ui.dart';
|
||||
import 'package:toolbox/data/res/build_data.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
@@ -86,9 +85,6 @@ class MyApp extends StatelessWidget {
|
||||
|
||||
void _setup(BuildContext context) async {
|
||||
setTransparentNavigationBar(context);
|
||||
if (Stores.setting.autoCheckAppUpdate.fetch()) {
|
||||
doUpdate(context);
|
||||
}
|
||||
Analysis.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 734;
|
||||
static const int build = 736;
|
||||
static const String engine = "3.16.9";
|
||||
static const String buildAt = "2024-02-01 11:26:59";
|
||||
static const int modifications = 5;
|
||||
static const String buildAt = "2024-02-01 15:39:49";
|
||||
static const int modifications = 11;
|
||||
static const int script = 36;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ class DebugPage extends StatelessWidget {
|
||||
builder: (_, provider, __) {
|
||||
return ListView(
|
||||
key: ValueKey(provider.widgets.length),
|
||||
reverse: true,
|
||||
children: provider.widgets,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:toolbox/core/channel/home_widget.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
import 'package:toolbox/core/update.dart';
|
||||
import 'package:toolbox/core/utils/platform/auth.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
@@ -316,6 +317,10 @@ ${GithubIds.participants.map((e) => '[$e](${e.url})').join(' ')}
|
||||
Future<void> afterFirstLayout(BuildContext context) async {
|
||||
// Auth required for first launch
|
||||
_auth();
|
||||
|
||||
if (Stores.setting.autoCheckAppUpdate.fetch()) {
|
||||
doUpdate(context);
|
||||
}
|
||||
HomeWidgetMC.update();
|
||||
await GetIt.I.allReady();
|
||||
await Pros.server.load();
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_background_service/flutter_background_service.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
@@ -369,6 +370,8 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
||||
_listen(session.stdout);
|
||||
_listen(session.stderr);
|
||||
|
||||
_initService();
|
||||
|
||||
if (widget.initCmd != null) {
|
||||
_terminal.textInput(widget.initCmd!);
|
||||
_terminal.keyInput(TerminalKey.enter);
|
||||
@@ -432,4 +435,21 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
Future<void> _initService() async {
|
||||
final service = FlutterBackgroundService();
|
||||
|
||||
await service.configure(
|
||||
androidConfiguration: AndroidConfiguration(
|
||||
onStart: _onStart,
|
||||
autoStart: true,
|
||||
isForegroundMode: true,
|
||||
initialNotificationTitle: 'SSH',
|
||||
initialNotificationContent: l10n.bgRun,
|
||||
),
|
||||
iosConfiguration: IosConfiguration(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onStart(ServiceInstance service) async {}
|
||||
|
||||
Reference in New Issue
Block a user