set LANG in shell

This commit is contained in:
Junyuan Feng
2022-05-05 16:53:35 +08:00
parent 29e3ee0156
commit 74a933eb6e
12 changed files with 65 additions and 66 deletions

View File

@@ -354,7 +354,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 123; CURRENT_PROJECT_VERSION = 125;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -362,7 +362,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.123; MARKETING_VERSION = 1.0.125;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -484,7 +484,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 123; CURRENT_PROJECT_VERSION = 125;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -492,7 +492,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.123; MARKETING_VERSION = 1.0.125;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -508,7 +508,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 123; CURRENT_PROJECT_VERSION = 125;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -516,7 +516,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.123; MARKETING_VERSION = 1.0.125;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";

View File

@@ -41,5 +41,10 @@
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key> <key>UIViewControllerBasedStatusBarAppearance</key>
<false/> <false/>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>zh</string>
</array>
</dict> </dict>
</plist> </plist>

View File

@@ -33,10 +33,10 @@ class MyApp extends StatelessWidget {
final textStyle = TextStyle(color: primaryColor); final textStyle = TextStyle(color: primaryColor);
return MaterialApp( return MaterialApp(
localizationsDelegates: const [ localizationsDelegates: const [
S.delegate, S.delegate,
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate, GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
], ],
supportedLocales: S.delegate.supportedLocales, supportedLocales: S.delegate.supportedLocales,
title: BuildData.name, title: BuildData.name,

View File

@@ -30,7 +30,8 @@ List<SSHKeyPair> loadIndentity(String key) {
} }
const seperator = 'A====A'; const seperator = 'A====A';
const shellCmd = "cat /proc/net/dev && date +%s \necho $seperator \n " const shellCmd = "export LANG=en_US.utf-8 \necho '$seperator' \n"
"cat /proc/net/dev && date +%s \necho $seperator \n "
"cat /etc/os-release | grep PRETTY_NAME \necho $seperator \n" "cat /etc/os-release | grep PRETTY_NAME \necho $seperator \n"
"cat /proc/stat | grep cpu \necho $seperator \n" "cat /proc/stat | grep cpu \necho $seperator \n"
"uptime \necho $seperator \n" "uptime \necho $seperator \n"
@@ -40,6 +41,7 @@ const shellCmd = "cat /proc/net/dev && date +%s \necho $seperator \n "
"cat /sys/class/thermal/thermal_zone*/type \necho $seperator \n" "cat /sys/class/thermal/thermal_zone*/type \necho $seperator \n"
"cat /sys/class/thermal/thermal_zone*/temp"; "cat /sys/class/thermal/thermal_zone*/temp";
const shellPath = '.serverbox.sh'; const shellPath = '.serverbox.sh';
const memPrefix = 'Mem:';
final cpuTempReg = RegExp('(x86_pkg_temp|cpu_thermal)'); final cpuTempReg = RegExp('(x86_pkg_temp|cpu_thermal)');
class ServerProvider extends BusyProvider { class ServerProvider extends BusyProvider {
@@ -192,6 +194,7 @@ class ServerProvider extends BusyProvider {
if (si.client == null) return; if (si.client == null) return;
final raw = await si.client!.run("sh $shellPath").string; final raw = await si.client!.run("sh $shellPath").string;
final lines = raw.split(seperator).map((e) => e.trim()).toList(); final lines = raw.split(seperator).map((e) => e.trim()).toList();
lines.removeAt(0);
try { try {
_getCPU(spi, lines[2], lines[7], lines[8]); _getCPU(spi, lines[2], lines[7], lines[8]);
@@ -322,25 +325,22 @@ class ServerProvider extends BusyProvider {
} }
void _getMem(ServerPrivateInfo spi, String raw) { void _getMem(ServerPrivateInfo spi, String raw) {
const memPrefixies = ['Mem:', '内存:'];
final info = _servers.firstWhere((e) => e.info == spi); final info = _servers.firstWhere((e) => e.info == spi);
for (var item in raw.split('\n')) { for (var item in raw.split('\n')) {
var found = false; var found = false;
for (var memPrefix in memPrefixies) { if (item.contains(memPrefix)) {
if (item.contains(memPrefix)) { found = true;
found = true; final split = item.replaceFirst(memPrefix, '').split(' ');
final split = item.replaceFirst(memPrefix, '').split(' '); split.removeWhere((e) => e == '');
split.removeWhere((e) => e == ''); final memList = split.map((e) => int.parse(e)).toList();
final memList = split.map((e) => int.parse(e)).toList(); info.status.memory = Memory(
info.status.memory = Memory( total: memList[0],
total: memList[0], used: memList[1],
used: memList[1], free: memList[2],
free: memList[2], shared: memList[3],
shared: memList[3], cache: memList[4],
cache: memList[4], avail: memList[5]);
avail: memList[5]); break;
break;
}
} }
if (found) break; if (found) break;
} }

View File

@@ -2,9 +2,9 @@
class BuildData { class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 123; static const int build = 125;
static const String engine = static const String engine =
"Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 5464c5bac7 (2 weeks ago) • 2022-04-18 09:55:37 -0700\nEngine • revision 57d3bac3dd\nTools • Dart 2.16.2 • DevTools 2.9.2\n"; "Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 5464c5bac7 (2 weeks ago) • 2022-04-18 09:55:37 -0700\nEngine • revision 57d3bac3dd\nTools • Dart 2.16.2 • DevTools 2.9.2\n";
static const String buildAt = "2022-05-04 21:08:15.263486"; static const String buildAt = "2022-05-05 16:11:07.575227";
static const int modifications = 0; static const int modifications = 2;
} }

View File

@@ -247,8 +247,7 @@ class _MyHomePageState extends State<MyHomePage>
applicationIcon: _buildIcon(), applicationIcon: _buildIcon(),
aboutBoxChildren: [ aboutBoxChildren: [
UrlText( UrlText(
text: s.madeWithLove(myGithub), text: s.madeWithLove(myGithub), replace: 'LollipopKit'),
replace: 'LollipopKit'),
UrlText( UrlText(
text: s.aboutThanks(rainSunMeGithub), text: s.aboutThanks(rainSunMeGithub),
replace: 'RainSunMe', replace: 'RainSunMe',

View File

@@ -75,7 +75,10 @@ class _PingPageState extends State<PingPage>
title: Text(result.serverName, title: Text(result.serverName,
style: TextStyle( style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold, color: primaryColor)), fontSize: 18, fontWeight: FontWeight.bold, color: primaryColor)),
subtitle: Text(_buildPingSummary(result, unknown, ms), style: summaryTextStyle,), subtitle: Text(
_buildPingSummary(result, unknown, ms),
style: summaryTextStyle,
),
trailing: Text( trailing: Text(
s.pingAvg + s.pingAvg +
(result.statistic?.avg?.toStringAsFixed(2) ?? s.unknown) + (result.statistic?.avg?.toStringAsFixed(2) ?? s.unknown) +

View File

@@ -92,8 +92,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
final key = keyController.text; final key = keyController.text;
final pwd = pwdController.text; final pwd = pwdController.text;
if (name.isEmpty || key.isEmpty) { if (name.isEmpty || key.isEmpty) {
showSnackBar( showSnackBar(context, Text(s.fieldMustNotEmpty));
context, Text(s.fieldMustNotEmpty));
return; return;
} }
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();

View File

@@ -60,26 +60,22 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
widget.spi != null widget.spi != null
? IconButton( ? IconButton(
onPressed: () { onPressed: () {
showRoundDialog( showRoundDialog(context, 'Attention',
context, Text(s.sureToDeleteServer(widget.spi!.name)), [
'Attention', TextButton(
Text( onPressed: () {
s.sureToDeleteServer(widget.spi!.name)), _serverProvider.delServer(widget.spi!);
[ Navigator.of(context).pop();
TextButton( Navigator.of(context).pop();
onPressed: () { },
_serverProvider.delServer(widget.spi!); child: Text(
Navigator.of(context).pop(); s.ok,
Navigator.of(context).pop(); style: const TextStyle(color: Colors.red),
}, )),
child: Text( TextButton(
s.ok, onPressed: () => Navigator.of(context).pop(),
style: const TextStyle(color: Colors.red), child: Text(s.cancel))
)), ]);
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(s.cancel))
]);
}, },
icon: const Icon(Icons.delete)) icon: const Icon(Icons.delete))
: const SizedBox() : const SizedBox()
@@ -93,8 +89,8 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
TextField( TextField(
controller: nameController, controller: nameController,
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
decoration: decoration: buildDecoration(s.name,
buildDecoration(s.name, icon: Icons.info, hint: s.exampleName), icon: Icons.info, hint: s.exampleName),
), ),
TextField( TextField(
controller: ipController, controller: ipController,

View File

@@ -122,7 +122,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
TextButton( TextButton(
onPressed: () async => onPressed: () async =>
await _import(_importFieldController.text.trim()), await _import(_importFieldController.text.trim()),
child: Text('GO'), child: const Text('GO'),
) )
]); ]);
} }
@@ -246,11 +246,9 @@ class _SnippetListPageState extends State<SnippetListPage> {
])); ]));
}), [ }), [
TextButton( TextButton(
onPressed: () async => run(context, snippet), onPressed: () async => run(context, snippet), child: Text(s.run)),
child: Text(s.run)),
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(), child: Text(s.cancel)),
child: Text(s.cancel)),
]); ]);
} }
@@ -261,8 +259,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
showRoundDialog(context, s.result, showRoundDialog(context, s.result,
Text(result, style: const TextStyle(fontSize: 13)), [ Text(result, style: const TextStyle(fontSize: 13)), [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(), child: Text(s.close))
child: Text(s.close))
]); ]);
} }
} }