Merge pull request #6310 from 21pages/install_after_connect

fix install after connection
This commit is contained in:
RustDesk 2023-11-07 11:37:52 +08:00 committed by GitHub
commit 05a254c682
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 123 additions and 96 deletions

View File

@ -336,11 +336,17 @@ class _DesktopHomePageState extends State<DesktopHomePage>
} }
if (Platform.isWindows) { if (Platform.isWindows) {
if (!bind.mainIsInstalled()) { if (!bind.mainIsInstalled()) {
return buildInstallCard( return buildInstallCard("", "install_tip", "Install", () async {
"", "install_tip", "Install", bind.mainGotoInstall); await rustDeskWinManager.closeAllSubWindows();
bind.mainGotoInstall();
});
} else if (bind.mainIsInstalledLowerVersion()) { } else if (bind.mainIsInstalledLowerVersion()) {
return buildInstallCard("Status", "Your installation is lower version.", return buildInstallCard(
"Click to upgrade", bind.mainUpdateMe); "Status", "Your installation is lower version.", "Click to upgrade",
() async {
await rustDeskWinManager.closeAllSubWindows();
bind.mainUpdateMe();
});
} }
} else if (Platform.isMacOS) { } else if (Platform.isMacOS) {
if (!bind.mainIsCanScreenRecording(prompt: false)) { if (!bind.mainIsCanScreenRecording(prompt: false)) {
@ -384,13 +390,16 @@ class _DesktopHomePageState extends State<DesktopHomePage>
final keyShowSelinuxHelpTip = "show-selinux-help-tip"; final keyShowSelinuxHelpTip = "show-selinux-help-tip";
if (bind.mainGetLocalOption(key: keyShowSelinuxHelpTip) != 'N') { if (bind.mainGetLocalOption(key: keyShowSelinuxHelpTip) != 'N') {
LinuxCards.add(buildInstallCard( LinuxCards.add(buildInstallCard(
"Warning", "selinux_tip", "", () async {}, "Warning",
marginTop: LinuxCards.isEmpty ? 20.0 : 5.0, "selinux_tip",
help: 'Help', "",
link: () async {},
'https://rustdesk.com/docs/en/client/linux/#permissions-issue', marginTop: LinuxCards.isEmpty ? 20.0 : 5.0,
closeButton: true, help: 'Help',
closeOption: keyShowSelinuxHelpTip, link:
'https://rustdesk.com/docs/en/client/linux/#permissions-issue',
closeButton: true,
closeOption: keyShowSelinuxHelpTip,
)); ));
} }
} }
@ -418,7 +427,11 @@ class _DesktopHomePageState extends State<DesktopHomePage>
Widget buildInstallCard(String title, String content, String btnText, Widget buildInstallCard(String title, String content, String btnText,
GestureTapCallback onPressed, GestureTapCallback onPressed,
{double marginTop = 20.0, String? help, String? link, bool? closeButton, String? closeOption}) { {double marginTop = 20.0,
String? help,
String? link,
bool? closeButton,
String? closeOption}) {
void closeCard() async { void closeCard() async {
if (closeOption != null) { if (closeOption != null) {
await bind.mainSetLocalOption(key: closeOption, value: 'N'); await bind.mainSetLocalOption(key: closeOption, value: 'N');
@ -439,89 +452,90 @@ class _DesktopHomePageState extends State<DesktopHomePage>
Container( Container(
margin: EdgeInsets.only(top: marginTop), margin: EdgeInsets.only(top: marginTop),
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.centerLeft, begin: Alignment.centerLeft,
end: Alignment.centerRight, end: Alignment.centerRight,
colors: [ colors: [
Color.fromARGB(255, 226, 66, 188), Color.fromARGB(255, 226, 66, 188),
Color.fromARGB(255, 244, 114, 124), Color.fromARGB(255, 244, 114, 124),
], ],
)), )),
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: (title.isNotEmpty children: (title.isNotEmpty
? <Widget>[ ? <Widget>[
Center( Center(
child: Text(
translate(title),
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 15),
).marginOnly(bottom: 6)),
]
: <Widget>[]) +
<Widget>[
Text(
translate(content),
style: TextStyle(
height: 1.5,
color: Colors.white,
fontWeight: FontWeight.normal,
fontSize: 13),
).marginOnly(bottom: 20)
] +
(btnText.isNotEmpty
? <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FixedWidthButton(
width: 150,
padding: 8,
isOutline: true,
text: translate(btnText),
textColor: Colors.white,
borderColor: Colors.white,
textSize: 20,
radius: 10,
onTap: onPressed,
)
])
]
: <Widget>[]) +
(help != null
? <Widget>[
Center(
child: InkWell(
onTap: () async =>
await launchUrl(Uri.parse(link!)),
child: Text( child: Text(
translate(help), translate(title),
style: TextStyle( style: TextStyle(
decoration: TextDecoration.underline, color: Colors.white,
color: Colors.white, fontWeight: FontWeight.bold,
fontSize: 12), fontSize: 15),
)).marginOnly(top: 6)), ).marginOnly(bottom: 6)),
] ]
: <Widget>[]))), : <Widget>[]) +
<Widget>[
Text(
translate(content),
style: TextStyle(
height: 1.5,
color: Colors.white,
fontWeight: FontWeight.normal,
fontSize: 13),
).marginOnly(bottom: 20)
] +
(btnText.isNotEmpty
? <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FixedWidthButton(
width: 150,
padding: 8,
isOutline: true,
text: translate(btnText),
textColor: Colors.white,
borderColor: Colors.white,
textSize: 20,
radius: 10,
onTap: onPressed,
)
])
]
: <Widget>[]) +
(help != null
? <Widget>[
Center(
child: InkWell(
onTap: () async =>
await launchUrl(Uri.parse(link!)),
child: Text(
translate(help),
style: TextStyle(
decoration:
TextDecoration.underline,
color: Colors.white,
fontSize: 12),
)).marginOnly(top: 6)),
]
: <Widget>[]))),
), ),
if (closeButton != null && closeButton == true) if (closeButton != null && closeButton == true)
Positioned( Positioned(
top: 18, top: 18,
right: 0, right: 0,
child: IconButton( child: IconButton(
icon: Icon( icon: Icon(
Icons.close, Icons.close,
color: Colors.white, color: Colors.white,
size: 20, size: 20,
),
onPressed: closeCard,
), ),
onPressed: closeCard,
), ),
),
], ],
); );
} }

View File

@ -123,14 +123,21 @@ class CmFileModel {
} }
int removeUnreadCount = 0; int removeUnreadCount = 0;
if (data.dir) { if (data.dir) {
bool isChild(String parent, String child) {
if (child.startsWith(parent) && child.length > parent.length) {
final suffix = child.substring(parent.length);
return suffix.startsWith('/') || suffix.startsWith('\\');
}
return false;
}
removeUnreadCount = jobTable removeUnreadCount = jobTable
.where((e) => .where((e) =>
e.action == CmFileAction.remove && e.action == CmFileAction.remove &&
e.fileName.startsWith(data.path)) isChild(data.path, e.fileName))
.length; .length;
jobTable.removeWhere((e) => jobTable.removeWhere((e) =>
e.action == CmFileAction.remove && e.action == CmFileAction.remove && isChild(data.path, e.fileName));
e.fileName.startsWith(data.path));
} }
jobTable.add(CmFileLog() jobTable.add(CmFileLog()
..id = data.id ..id = data.id

View File

@ -49,6 +49,7 @@ use sha2::{Digest, Sha256};
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use std::{ use std::{
num::NonZeroI64, num::NonZeroI64,
path::PathBuf,
sync::{atomic::AtomicI64, mpsc as std_mpsc}, sync::{atomic::AtomicI64, mpsc as std_mpsc},
}; };
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
@ -2953,12 +2954,17 @@ impl FileRemoveLogControl {
fn on_remove_dir(&mut self, d: FileRemoveDir) -> Option<ipc::Data> { fn on_remove_dir(&mut self, d: FileRemoveDir) -> Option<ipc::Data> {
self.instant = Instant::now(); self.instant = Instant::now();
self.removed_files.retain(|f| !f.path.starts_with(&d.path)); let direct_child = |parent: &str, child: &str| {
self.removed_dirs.retain(|x| !x.path.starts_with(&d.path)); PathBuf::from(child).parent().map(|x| x.to_path_buf()) == Some(PathBuf::from(parent))
};
self.removed_files
.retain(|f| !direct_child(&f.path, &d.path));
self.removed_dirs
.retain(|x| !direct_child(&d.path, &x.path));
if !self if !self
.removed_dirs .removed_dirs
.iter() .iter()
.any(|x| d.path.starts_with(&x.path)) .any(|x| direct_child(&x.path, &d.path))
{ {
self.removed_dirs.push(d.clone()); self.removed_dirs.push(d.clone());
} }