new: vnc (beta #227)

This commit is contained in:
lollipopkit
2023-12-03 14:16:07 +08:00
parent 7c2480f027
commit 5035fdce86
6 changed files with 144 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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');
}
}