feat, web toast (#9686)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-10-17 17:23:09 +08:00 committed by GitHub
parent 5e920f0fd0
commit ae8dfe84a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
44 changed files with 77 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import 'dart:math';
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:bot_toast/bot_toast.dart';
import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -269,6 +270,8 @@ class FfiModel with ChangeNotifier {
var name = evt['name']; var name = evt['name'];
if (name == 'msgbox') { if (name == 'msgbox') {
handleMsgBox(evt, sessionId, peerId); handleMsgBox(evt, sessionId, peerId);
} else if (name == 'toast') {
handleToast(evt, sessionId, peerId);
} else if (name == 'set_multiple_windows_session') { } else if (name == 'set_multiple_windows_session') {
handleMultipleWindowsSession(evt, sessionId, peerId); handleMultipleWindowsSession(evt, sessionId, peerId);
} else if (name == 'peer_info') { } else if (name == 'peer_info') {
@ -595,6 +598,37 @@ class FfiModel with ChangeNotifier {
} }
} }
handleToast(Map<String, dynamic> evt, SessionID sessionId, String peerId) {
final type = evt['type'] ?? 'info';
final text = evt['text'] ?? '';
final durMsc = evt['dur_msec'] ?? 2000;
final duration = Duration(milliseconds: durMsc);
if ((text).isEmpty) {
BotToast.showLoading(
duration: duration,
clickClose: true,
allowClick: true,
);
} else {
if (type.contains('error')) {
BotToast.showText(
contentColor: Colors.red,
text: translate(text),
duration: duration,
clickClose: true,
onlyOne: true,
);
} else {
BotToast.showText(
text: translate(text),
duration: duration,
clickClose: true,
onlyOne: true,
);
}
}
}
/// Show a message box with [type], [title] and [text]. /// Show a message box with [type], [title] and [text].
showMsgBox(SessionID sessionId, String type, String title, String text, showMsgBox(SessionID sessionId, String type, String title, String text,
String link, bool hasRetry, OverlayDialogManager dialogManager, String link, bool hasRetry, OverlayDialogManager dialogManager,

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", "下载"), ("Download", "下载"),
("Upload folder", "上传文件夹"), ("Upload folder", "上传文件夹"),
("Upload files", "上传文件"), ("Upload files", "上传文件"),
("Clipboard is synchronized", "剪贴板已同步"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", "Herunterladen"), ("Download", "Herunterladen"),
("Upload folder", "Ordner hochladen"), ("Upload folder", "Ordner hochladen"),
("Upload files", "Dateien hochladen"), ("Upload files", "Dateien hochladen"),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", "Download"), ("Download", "Download"),
("Upload folder", "Cartella upload"), ("Upload folder", "Cartella upload"),
("Upload files", "File upload"), ("Upload files", "File upload"),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", "下載"), ("Download", "下載"),
("Upload folder", "上傳資料夾"), ("Upload folder", "上傳資料夾"),
("Upload files", "上傳檔案"), ("Upload files", "上傳檔案"),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -651,5 +651,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Download", ""), ("Download", ""),
("Upload folder", ""), ("Upload folder", ""),
("Upload files", ""), ("Upload files", ""),
("Clipboard is synchronized", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }