mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: vnc (beta #227)
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:toolbox/core/utils/misc.dart';
|
||||
import 'package:toolbox/data/res/path.dart';
|
||||
|
||||
// abstract final class SecureStore {
|
||||
// static const _secureStorage = FlutterSecureStorage();
|
||||
@@ -40,6 +42,34 @@ class PersistentStore {
|
||||
boxName,
|
||||
//encryptionCipher: SecureStore._cipher,
|
||||
);
|
||||
|
||||
|
||||
/// Get all db filenames.
|
||||
///
|
||||
/// - [suffixs] defaults to ['.hive']
|
||||
///
|
||||
/// - If [hideSetting] is true, hide 'setting.hive'
|
||||
static Future<List<String>> getFileNames({
|
||||
bool hideSetting = false,
|
||||
List<String>? suffixs,
|
||||
}) async {
|
||||
final docPath = await Paths.doc;
|
||||
final dir = Directory(docPath);
|
||||
final files = await dir.list().toList();
|
||||
if (suffixs != null) {
|
||||
files.removeWhere((e) => !suffixs.contains(e.path.split('.').last));
|
||||
} else {
|
||||
// filter out non-hive(db) files
|
||||
files.removeWhere((e) => !e.path.endsWith('.hive'));
|
||||
}
|
||||
if (hideSetting) {
|
||||
files.removeWhere((e) => e.path.endsWith('setting.hive'));
|
||||
}
|
||||
final paths =
|
||||
files.map((e) => e.path.replaceFirst('$docPath/', '')).toList();
|
||||
return paths;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension BoxX on Box {
|
||||
|
||||
@@ -15,6 +15,7 @@ import 'package:toolbox/view/page/snippet/result.dart';
|
||||
import 'package:toolbox/view/page/ssh/page.dart';
|
||||
import 'package:toolbox/view/page/setting/virt_key.dart';
|
||||
import 'package:toolbox/view/page/storage/local.dart';
|
||||
import 'package:toolbox/view/page/vnc.dart';
|
||||
|
||||
import '../data/model/server/snippet.dart';
|
||||
import '../view/page/debug.dart';
|
||||
@@ -218,4 +219,8 @@ class AppRoute {
|
||||
),
|
||||
'snippet_result');
|
||||
}
|
||||
|
||||
static AppRoute vnc({Key? key}) {
|
||||
return AppRoute(VNCPage(key: key), 'vnc');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,10 @@ class BackupPage extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
icloudLoading.value = true;
|
||||
final files = await PersistentStore.getFileNames();
|
||||
for (final file in files) {
|
||||
await ICloud.download(relativePath: file);
|
||||
}
|
||||
icloudLoading.value = false;
|
||||
},
|
||||
child: Text(l10n.download),
|
||||
@@ -121,6 +125,10 @@ class BackupPage extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
icloudLoading.value = true;
|
||||
final files = await PersistentStore.getFileNames();
|
||||
for (final file in files) {
|
||||
await ICloud.upload(relativePath: file);
|
||||
}
|
||||
icloudLoading.value = false;
|
||||
},
|
||||
child: Text(l10n.upload),
|
||||
|
||||
44
lib/view/page/vnc.dart
Normal file
44
lib/view/page/vnc.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_rfb/flutter_rfb.dart';
|
||||
import 'package:toolbox/data/res/ui.dart';
|
||||
|
||||
class VNCPage extends StatefulWidget {
|
||||
const VNCPage({super.key});
|
||||
|
||||
@override
|
||||
State<VNCPage> createState() => _VNCPageState();
|
||||
}
|
||||
|
||||
class _VNCPageState extends State<VNCPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: InteractiveViewer(
|
||||
constrained: true,
|
||||
maxScale: 10,
|
||||
child: RemoteFrameBufferWidget(
|
||||
hostName: '47.108.212.173',
|
||||
onError: (final Object error) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Error: $error'),
|
||||
),
|
||||
);
|
||||
},
|
||||
connectingWidget: UIs.centerLoading,
|
||||
password: 'Pwd123',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
56
pubspec.lock
56
pubspec.lock
@@ -57,6 +57,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.0"
|
||||
binary:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: binary
|
||||
sha256: e40eff285745e241c25b21a464b1437cbf56bad99c681de3783ff36fad52b707
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -234,6 +242,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
dart_des:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_des
|
||||
sha256: "0a66afb8883368c824497fd2a1fd67bdb1a785965a3956728382c03d40747c33"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
dart_rfb:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_rfb
|
||||
sha256: cbd2301868febdac476fcb293ed69b6e2a3223e4f6f13ff58d1b258e9b6f037f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.0"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -364,6 +388,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.17"
|
||||
flutter_rfb:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_rfb
|
||||
sha256: "8982187776b9638152ac0689f6ccabf6cacdb5ffd37bb018609b9ca0e9f4f5ea"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.2"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@@ -374,6 +406,22 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
fpdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fpdart
|
||||
sha256: "21053522d5a97347737525c84e8839340a0af3c0ef592f98fac37380fdd6a57b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.4.1"
|
||||
freezed_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: freezed_annotation
|
||||
sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -582,6 +630,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
matan:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matan
|
||||
sha256: "41e73fe0cd0e20ff22f4cdfdb66b1a02149e80b918fc43f3dc453ca5fb67830c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -61,6 +61,7 @@ dependencies:
|
||||
choice: ^2.0.0
|
||||
#flutter_secure_storage: ^9.0.0
|
||||
xml: ^6.4.2
|
||||
flutter_rfb: ^0.6.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_native_splash: ^2.1.6
|
||||
|
||||
Reference in New Issue
Block a user