优化登录功能

This commit is contained in:
xkeyC 2023-10-28 13:22:53 +08:00
parent 6153bcf9c0
commit 0640761299
3 changed files with 9 additions and 2 deletions

View File

@ -229,6 +229,7 @@ async function getRSILauncherToken() {
}); });
if (r.status !== 200) { if (r.status !== 200) {
// wait login // wait login
window.chrome.webview.postMessage({action: 'webview_rsi_login_show_window'});
return; return;
} }
@ -268,7 +269,7 @@ async function getRSILauncherToken() {
body: releaseFormData body: releaseFormData
}); });
if (releaseR.status !== 200) return; if (releaseR.status !== 200) return;
let releaseDataJson = await releaseR.json(); let releaseDataJson = (await releaseR.json())['data'];
console.log(releaseDataJson); console.log(releaseDataJson);
// post message // post message

View File

@ -472,6 +472,7 @@ class HomeUIModel extends BaseUIModel {
// SystemHelper.checkAndLaunchRSILauncher(rsiLauncherInstalledPath); // SystemHelper.checkAndLaunchRSILauncher(rsiLauncherInstalledPath);
goWebView("登录 RSI 账户", "https://robertsspaceindustries.com/connect", goWebView("登录 RSI 账户", "https://robertsspaceindustries.com/connect",
loginMode: true, rsiLoginCallback: (data, ok) { loginMode: true, rsiLoginCallback: (data, ok) {
dPrint("======rsiLoginCallback=== $ok =====\n$data}");
isRsiLauncherStarting = false; isRsiLauncherStarting = false;
notifyListeners(); notifyListeners();
}, useLocalization: true); }, useLocalization: true);

View File

@ -53,6 +53,9 @@ class WebViewModel {
userDataFolderWindows: userDataFolderWindows:
"${AppConf.applicationSupportDir}/webview_data", "${AppConf.applicationSupportDir}/webview_data",
title: title)); title: title));
if (loginMode) {
await webview.setWebviewWindowVisibility(false);
}
// webview.openDevToolsWindow(); // webview.openDevToolsWindow();
webview.isNavigating.addListener(() async { webview.isNavigating.addListener(() async {
@ -141,7 +144,9 @@ class WebViewModel {
if (loginMode) { if (loginMode) {
webview.addOnWebMessageReceivedCallback((messageString) { webview.addOnWebMessageReceivedCallback((messageString) {
final message = json.decode(messageString); final message = json.decode(messageString);
if (message["action"] == "webview_rsi_login_success") { if (message["action"] == "webview_rsi_login_show_window") {
webview.setWebviewWindowVisibility(true);
} else if (message["action"] == "webview_rsi_login_success") {
_loginModeSuccess = true; _loginModeSuccess = true;
loginCallback?.call(message, true); loginCallback?.call(message, true);
webview.close(); webview.close();