mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-23 16:45:27 +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',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user