Skip to content

Commit

Permalink
feat(alist page): change get pwd to generate pwd
Browse files Browse the repository at this point in the history
In AList version 3.25.0, the passwords are stored encrypted, so they can't be obtained directly and are replaced by randomly generated passwords.
  • Loading branch information
Xmarmalade committed Aug 10, 2023
1 parent 95a2642 commit 8361b74
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/i18n/strings_en.i18n.json
Expand Up @@ -3,8 +3,8 @@
"alistOperation": {
"startAlist": "Start",
"endAlist": "End",
"openGUI": "Open GUI",
"getAdmin": "Admin",
"openGUI": "Open Web GUI",
"genRandomPwd": "Generate Random Pwd",
"getVersion": "Version"
},
"rcloneOperation": {
Expand Down
4 changes: 2 additions & 2 deletions lib/i18n/strings_zh-Hans-CN.i18n.json
Expand Up @@ -3,8 +3,8 @@
"alistOperation": {
"startAlist": "启动",
"endAlist": "关闭",
"openGUI": "打开 GUI",
"getAdmin": "管理员信息",
"openGUI": "打开 Web GUI",
"genRandomPwd": "生成随机密码",
"getVersion": "版本信息"
},
"rcloneOperation": {
Expand Down
4 changes: 2 additions & 2 deletions lib/i18n/strings_zh-Hant-TW.i18n.json
Expand Up @@ -3,8 +3,8 @@
"alistOperation": {
"startAlist": "啟動",
"endAlist": "關閉",
"openGUI": "開啟 GUI",
"getAdmin": "管理員資訊",
"openGUI": "開啟 Web GUI",
"genRandomPwd": "生成隨機密碼",
"getVersion": "版本資訊"
},
"rcloneOperation": {
Expand Down
12 changes: 7 additions & 5 deletions lib/provider/alist_provider.dart
Expand Up @@ -110,21 +110,23 @@ class AlistNotifier extends StateNotifier<AlistState> {
}

//get alist admin
Future<void> getAlistAdmin() async {
Future<void> genRandomPwd() async {
Process alistAdmin;
if (Platform.isWindows) {
alistAdmin = await Process.start(
'$workingDirectory\\alist.exe', ['admin'],
'$workingDirectory\\alist.exe', ['admin', 'random'],
workingDirectory: workingDirectory);
} else {
alistAdmin = await Process.start('$workingDirectory/alist', ['admin'],
alistAdmin = await Process.start('$workingDirectory/alist', ['admin', 'random'],
workingDirectory: workingDirectory);
}
alistAdmin.stderr.listen((data) {
String text = TextUtils.stdDecode(data, false);
String password = text.split('password:')[1].trim();
if (text.contains('password:')) {
String password = text.split('password:')[1].trim();
addOutput(password);
}
addOutput(text);
addOutput(password);
});
}

Expand Down
20 changes: 20 additions & 0 deletions lib/provider/rclone_provider.dart
Expand Up @@ -67,6 +67,26 @@ class RcloneNotifier extends StateNotifier<RcloneState> {
});
}


void getRcloneInfo() async {
Process process;
if (Platform.isWindows) {
process = await Process.start('$workingDirectory\\rclone.exe', ['version'],
workingDirectory: workingDirectory);
} else {
process = await Process.start('$workingDirectory/rclone', ['version'],
workingDirectory: workingDirectory);
}
process.stdout.listen((data) {
String text = TextUtils.stdDecode(data, false);
addOutput(text);
});
process.stderr.listen((data) {
String text = TextUtils.stdDecode(data, false);
addOutput(text);
});
}

static Future<void> endRcloneProcess() async {
if (Platform.isWindows) {
await Process.start('taskkill', ['/f', '/im', 'rclone.exe']);
Expand Down
1 change: 0 additions & 1 deletion lib/widgets/alist_args_tile.dart
Expand Up @@ -201,7 +201,6 @@ class __RcloneArgsDialogState extends State<_RcloneArgsDialog> {
onPressed: () {
setState(() {
args.removeAt(i);
print(args);
});
},
icon: const Icon(Icons.delete_forever_rounded),
Expand Down
11 changes: 7 additions & 4 deletions lib/widgets/button_card.dart
Expand Up @@ -51,10 +51,11 @@ class AlistMultiButtonCard extends ConsumerWidget {
onPressed: alistState.isRunning ? openGUI : null,
child: Text(t.alistOperation.openGUI)),
ElevatedButton(
onPressed: () => alistNotifier.getAlistAdmin(),
child: Text(t.alistOperation.getAdmin)),
onPressed: () => alistNotifier.genRandomPwd(),
child: Text(t.alistOperation.genRandomPwd)),
ElevatedButton(
onPressed: () => alistNotifier.getAlistCurrentVersion(addToOutput:true),
onPressed: () =>
alistNotifier.getAlistCurrentVersion(addToOutput: true),
child: Text(t.alistOperation.getVersion)),
],
),
Expand Down Expand Up @@ -98,6 +99,9 @@ class RcloneMultiButtonCard extends ConsumerWidget {
? () => rcloneNotifier.endRclone()
: null,
child: Text(t.rcloneOperation.endRclone)),
ElevatedButton(
onPressed: () => rcloneNotifier.getRcloneInfo(),
child: Text("t.rcloneOperation.getRcloneInfo")),
],
),
),
Expand All @@ -107,4 +111,3 @@ class RcloneMultiButtonCard extends ConsumerWidget {
);
}
}

2 changes: 1 addition & 1 deletion lib/widgets/pages/rclone_page.dart
Expand Up @@ -44,7 +44,7 @@ class RclonePage extends ConsumerWidget {
margin: const EdgeInsets.fromLTRB(20, 10, 20, 20),
child: LogsViewer(
output: ref.watch(
rcloneProvider.select((rclone) => rclone.output)))),
rcloneProvider).output)),
),
],
),
Expand Down

0 comments on commit 8361b74

Please sign in to comment.