mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-01-31 13:25:10 +01:00
opt. & fix
This commit is contained in:
@@ -43,6 +43,36 @@ class PersistentStore {
|
||||
boxName,
|
||||
//encryptionCipher: SecureStore._cipher,
|
||||
);
|
||||
|
||||
_StoreProperty<T> property<T>(
|
||||
String key,
|
||||
T defaultValue, {
|
||||
bool updateLastModified = true,
|
||||
}) {
|
||||
return _StoreProperty<T>(
|
||||
box,
|
||||
key,
|
||||
defaultValue,
|
||||
updateLastModified: updateLastModified,
|
||||
);
|
||||
}
|
||||
|
||||
_StoreListProperty<T> listProperty<T>(
|
||||
String key,
|
||||
List<T> defaultValue, {
|
||||
bool updateLastModified = true,
|
||||
T Function(dynamic val)? decoder,
|
||||
dynamic Function(T val)? encoder,
|
||||
}) {
|
||||
return _StoreListProperty<T>(
|
||||
box,
|
||||
key,
|
||||
defaultValue,
|
||||
updateLastModified: updateLastModified,
|
||||
encoder: encoder,
|
||||
decoder: decoder,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension BoxX on Box {
|
||||
@@ -80,38 +110,6 @@ extension BoxX on Box {
|
||||
}
|
||||
}
|
||||
|
||||
extension StoreX on PersistentStore {
|
||||
_StoreProperty<T> property<T>(
|
||||
String key,
|
||||
T defaultValue, {
|
||||
bool updateLastModified = true,
|
||||
}) {
|
||||
return _StoreProperty<T>(
|
||||
box,
|
||||
key,
|
||||
defaultValue,
|
||||
updateLastModified: updateLastModified,
|
||||
);
|
||||
}
|
||||
|
||||
_StoreListProperty<T> listProperty<T>(
|
||||
String key,
|
||||
List<T> defaultValue, {
|
||||
bool updateLastModified = true,
|
||||
T Function(dynamic val)? decoder,
|
||||
dynamic Function(T val)? encoder,
|
||||
}) {
|
||||
return _StoreListProperty<T>(
|
||||
box,
|
||||
key,
|
||||
defaultValue,
|
||||
updateLastModified: updateLastModified,
|
||||
encoder: encoder,
|
||||
decoder: decoder,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class StorePropertyBase<T> {
|
||||
ValueListenable<T> listenable();
|
||||
T fetch();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/core/extension/ssh_client.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/utils/platform/path.dart';
|
||||
import 'package:toolbox/data/model/app/shell_func.dart';
|
||||
import 'package:toolbox/data/model/server/system.dart';
|
||||
@@ -274,7 +274,7 @@ class ServerProvider extends ChangeNotifier {
|
||||
|
||||
ensure(await client.runWithSessionAction(ShellFunc.installerShellWriter,
|
||||
action: (session) async {
|
||||
session.stdin.add(utf8.encode(ShellFunc.allScript));
|
||||
session.stdin.add(ShellFunc.allScript.uint8List);
|
||||
})
|
||||
.string);
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 740;
|
||||
static const int build = 746;
|
||||
static const String engine = "3.16.9";
|
||||
static const String buildAt = "2024-02-02 22:52:02";
|
||||
static const String buildAt = "2024-02-15 16:45:05";
|
||||
static const int modifications = 2;
|
||||
static const int script = 37;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
import 'package:toolbox/data/res/default.dart';
|
||||
import 'package:toolbox/data/res/logger.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
|
||||
import '../../../../core/extension/order.dart';
|
||||
@@ -33,7 +34,14 @@ class _ServerDetailOrderPageState extends State<ServerDetailOrderPage> {
|
||||
return ValueListenableBuilder(
|
||||
valueListenable: prop.listenable(),
|
||||
builder: (_, vals, __) {
|
||||
final keys = List<String>.from(vals);
|
||||
final keys = () {
|
||||
try {
|
||||
return List<String>.from(vals);
|
||||
} catch (e) {
|
||||
Loggers.app.info('ServerDetailOrderPage: $e');
|
||||
return Defaults.detailCardOrder;
|
||||
}
|
||||
}();
|
||||
final disabled =
|
||||
Defaults.detailCardOrder.where((e) => !keys.contains(e)).toList();
|
||||
final allKeys = [...keys, ...disabled];
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
import 'package:toolbox/data/model/app/menu/server_func.dart';
|
||||
import 'package:toolbox/data/res/logger.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
|
||||
import '../../../../core/extension/order.dart';
|
||||
@@ -33,7 +34,14 @@ class _ServerDetailOrderPageState extends State<ServerFuncBtnsOrderPage> {
|
||||
return ValueListenableBuilder(
|
||||
valueListenable: prop.listenable(),
|
||||
builder: (_, vals, __) {
|
||||
final keys = List<int>.from(vals);
|
||||
final keys = () {
|
||||
try {
|
||||
return List<int>.from(vals);
|
||||
} catch (e) {
|
||||
Loggers.app.info('ServerFuncBtnsOrderPage: $e');
|
||||
return ServerFuncBtn.values.map((e) => e.index).toList();
|
||||
}
|
||||
}();
|
||||
final disabled = ServerFuncBtn.values
|
||||
.map((e) => e.index)
|
||||
.where((e) => !keys.contains(e))
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||
import 'package:toolbox/core/extension/order.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
import 'package:toolbox/data/model/ssh/virtual_key.dart';
|
||||
import 'package:toolbox/data/res/logger.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
import 'package:toolbox/data/res/ui.dart';
|
||||
import 'package:toolbox/view/widget/cardx.dart';
|
||||
@@ -34,7 +35,14 @@ class _SSHVirtKeySettingPageState extends State<SSHVirtKeySettingPage> {
|
||||
return ValueListenableBuilder(
|
||||
valueListenable: prop.listenable(),
|
||||
builder: (_, vals, __) {
|
||||
final keys = List<int>.from(vals);
|
||||
final keys = () {
|
||||
try {
|
||||
return List<int>.from(vals);
|
||||
} catch (e) {
|
||||
Loggers.app.info('SSHVirtKeySettingPage: $e');
|
||||
return VirtKey.values.map((e) => e.index).toList();
|
||||
}
|
||||
}();
|
||||
final disabled = VirtKey.values
|
||||
.map((e) => e.index)
|
||||
.where((e) => !keys.contains(e))
|
||||
|
||||
Reference in New Issue
Block a user