mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-02-17 22:11:30 +08:00
show login dialog when clicking note if not logged in (#13856)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -6,10 +6,12 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/common/shared_state.dart';
|
||||
import 'package:flutter_hbb/common/widgets/dialog.dart';
|
||||
import 'package:flutter_hbb/common/widgets/login.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/desktop/widgets/remote_toolbar.dart';
|
||||
import 'package:flutter_hbb/models/model.dart';
|
||||
import 'package:flutter_hbb/models/platform_model.dart';
|
||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
bool isEditOsPassword = false;
|
||||
@@ -193,14 +195,26 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
|
||||
);
|
||||
}
|
||||
// note
|
||||
if (isDefaultConn &&
|
||||
bind
|
||||
.sessionGetAuditServerSync(sessionId: sessionId, typ: "conn")
|
||||
.isNotEmpty) {
|
||||
if (isDefaultConn && !bind.isDisableAccount()) {
|
||||
v.add(
|
||||
TTextMenu(
|
||||
child: Text(translate('Note')),
|
||||
onPressed: () => showAuditDialog(ffi)),
|
||||
onPressed: () async {
|
||||
bool isLogin =
|
||||
bind.mainGetLocalOption(key: 'access_token').isNotEmpty;
|
||||
if (!isLogin) {
|
||||
final res = await loginDialog();
|
||||
if (res != true) return;
|
||||
// Desktop: send message to main window to refresh login status
|
||||
// Web: login is required before connection, so no need to refresh
|
||||
// Mobile: same isolate, no need to send message
|
||||
if (isDesktop) {
|
||||
rustDeskWinManager.call(
|
||||
WindowType.Main, kWindowRefreshCurrentUser, "");
|
||||
}
|
||||
}
|
||||
showAuditDialog(ffi);
|
||||
}),
|
||||
);
|
||||
}
|
||||
// divider
|
||||
|
||||
@@ -50,6 +50,7 @@ const String kAppTypeDesktopPortForward = "port forward";
|
||||
const String kAppTypeDesktopTerminal = "terminal";
|
||||
|
||||
const String kWindowMainWindowOnTop = "main_window_on_top";
|
||||
const String kWindowRefreshCurrentUser = "refresh_current_user";
|
||||
const String kWindowGetWindowInfo = "get_window_info";
|
||||
const String kWindowGetScreenList = "get_screen_list";
|
||||
// This method is not used, maybe it can be removed.
|
||||
|
||||
@@ -776,6 +776,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
}
|
||||
if (call.method == kWindowMainWindowOnTop) {
|
||||
windowOnTop(null);
|
||||
} else if (call.method == kWindowRefreshCurrentUser) {
|
||||
gFFI.userModel.refreshCurrentUser();
|
||||
} else if (call.method == kWindowGetWindowInfo) {
|
||||
final screen = (await window_size.getWindowInfo()).screen;
|
||||
if (screen == null) {
|
||||
|
||||
@@ -561,19 +561,21 @@ class _GeneralState extends State<_General> {
|
||||
children.add(_OptionCheckBox(
|
||||
context, 'Allow linux headless', kOptionAllowLinuxHeadless));
|
||||
}
|
||||
children.add(_OptionCheckBox(
|
||||
context,
|
||||
'note-at-conn-end-tip',
|
||||
kOptionAllowAskForNoteAtEndOfConnection,
|
||||
isServer: false,
|
||||
optSetter: (key, value) async {
|
||||
if (value && !gFFI.userModel.isLogin) {
|
||||
final res = await loginDialog();
|
||||
if (res != true) return;
|
||||
}
|
||||
await mainSetLocalBoolOption(key, value);
|
||||
},
|
||||
));
|
||||
if (!bind.isDisableAccount()) {
|
||||
children.add(_OptionCheckBox(
|
||||
context,
|
||||
'note-at-conn-end-tip',
|
||||
kOptionAllowAskForNoteAtEndOfConnection,
|
||||
isServer: false,
|
||||
optSetter: (key, value) async {
|
||||
if (value && !gFFI.userModel.isLogin) {
|
||||
final res = await loginDialog();
|
||||
if (res != true) return;
|
||||
}
|
||||
await mainSetLocalBoolOption(key, value);
|
||||
},
|
||||
));
|
||||
}
|
||||
return _Card(title: 'Other', children: children);
|
||||
}
|
||||
|
||||
|
||||
@@ -786,23 +786,24 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
|
||||
showThemeSettings(gFFI.dialogManager);
|
||||
},
|
||||
),
|
||||
SettingsTile.switchTile(
|
||||
title: Text(translate('note-at-conn-end-tip')),
|
||||
initialValue: _allowAskForNoteAtEndOfConnection,
|
||||
onToggle: (v) async {
|
||||
if (v && !gFFI.userModel.isLogin) {
|
||||
final res = await loginDialog();
|
||||
if (res != true) return;
|
||||
}
|
||||
await mainSetLocalBoolOption(
|
||||
kOptionAllowAskForNoteAtEndOfConnection, v);
|
||||
final newValue = mainGetLocalBoolOptionSync(
|
||||
kOptionAllowAskForNoteAtEndOfConnection);
|
||||
setState(() {
|
||||
_allowAskForNoteAtEndOfConnection = newValue;
|
||||
});
|
||||
},
|
||||
)
|
||||
if (!bind.isDisableAccount())
|
||||
SettingsTile.switchTile(
|
||||
title: Text(translate('note-at-conn-end-tip')),
|
||||
initialValue: _allowAskForNoteAtEndOfConnection,
|
||||
onToggle: (v) async {
|
||||
if (v && !gFFI.userModel.isLogin) {
|
||||
final res = await loginDialog();
|
||||
if (res != true) return;
|
||||
}
|
||||
await mainSetLocalBoolOption(
|
||||
kOptionAllowAskForNoteAtEndOfConnection, v);
|
||||
final newValue = mainGetLocalBoolOptionSync(
|
||||
kOptionAllowAskForNoteAtEndOfConnection);
|
||||
setState(() {
|
||||
_allowAskForNoteAtEndOfConnection = newValue;
|
||||
});
|
||||
},
|
||||
)
|
||||
]),
|
||||
if (isAndroid)
|
||||
SettingsSection(title: Text(translate('Hardware Codec')), tiles: [
|
||||
|
||||
@@ -1101,6 +1101,9 @@ class FfiModel with ChangeNotifier {
|
||||
|
||||
void _queryAuditGuid(String peerId) async {
|
||||
try {
|
||||
if (bind.isDisableAccount()) {
|
||||
return;
|
||||
}
|
||||
if (bind
|
||||
.sessionGetAuditServerSync(sessionId: sessionId, typ: "conn/active")
|
||||
.isEmpty) {
|
||||
|
||||
Reference in New Issue
Block a user