mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-24 04:12:20 +08:00
This commit is contained in:
parent
673986d045
commit
fda1e5e231
@ -646,7 +646,7 @@ impl PeerConfig {
|
|||||||
Config::path(path).with_extension("toml")
|
Config::path(path).with_extension("toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn peers() -> Vec<(String, SystemTime, PeerInfoSerde)> {
|
pub fn peers() -> Vec<(String, SystemTime, PeerConfig)> {
|
||||||
if let Ok(peers) = Config::path(PEERS).read_dir() {
|
if let Ok(peers) = Config::path(PEERS).read_dir() {
|
||||||
if let Ok(peers) = peers
|
if let Ok(peers) = peers
|
||||||
.map(|res| res.map(|e| e.path()))
|
.map(|res| res.map(|e| e.path()))
|
||||||
@ -667,13 +667,13 @@ impl PeerConfig {
|
|||||||
.map(|p| p.to_str().unwrap_or(""))
|
.map(|p| p.to_str().unwrap_or(""))
|
||||||
.unwrap_or("")
|
.unwrap_or("")
|
||||||
.to_owned();
|
.to_owned();
|
||||||
let info = PeerConfig::load(&id).info;
|
let c = PeerConfig::load(&id);
|
||||||
if info.platform.is_empty() {
|
if c.info.platform.is_empty() {
|
||||||
fs::remove_file(&p).ok();
|
fs::remove_file(&p).ok();
|
||||||
}
|
}
|
||||||
(id, t, info)
|
(id, t, c)
|
||||||
})
|
})
|
||||||
.filter(|p| !p.2.platform.is_empty())
|
.filter(|p| !p.2.info.platform.is_empty())
|
||||||
.collect();
|
.collect();
|
||||||
peers.sort_unstable_by(|a, b| b.1.cmp(&a.1));
|
peers.sort_unstable_by(|a, b| b.1.cmp(&a.1));
|
||||||
return peers;
|
return peers;
|
||||||
|
27
src/ui.rs
27
src/ui.rs
@ -266,6 +266,21 @@ impl UI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_peer_option(&self, id: String, name: String) -> String {
|
||||||
|
let c = PeerConfig::load(&id);
|
||||||
|
c.options.get(&name).unwrap_or(&"".to_owned()).to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_peer_option(&self, id: String, name: String, value: String) {
|
||||||
|
let mut c = PeerConfig::load(&id);
|
||||||
|
if value.is_empty() {
|
||||||
|
c.options.remove(&name);
|
||||||
|
} else {
|
||||||
|
c.options.insert(name, value);
|
||||||
|
}
|
||||||
|
c.store(&id);
|
||||||
|
}
|
||||||
|
|
||||||
fn get_options(&self) -> Value {
|
fn get_options(&self) -> Value {
|
||||||
let mut m = Value::map();
|
let mut m = Value::map();
|
||||||
for (k, v) in self.2.lock().unwrap().iter() {
|
for (k, v) in self.2.lock().unwrap().iter() {
|
||||||
@ -364,9 +379,13 @@ impl UI {
|
|||||||
.map(|p| {
|
.map(|p| {
|
||||||
let values = vec![
|
let values = vec![
|
||||||
p.0.clone(),
|
p.0.clone(),
|
||||||
p.2.username.clone(),
|
p.2.info.username.clone(),
|
||||||
p.2.hostname.clone(),
|
p.2.info.hostname.clone(),
|
||||||
p.2.platform.clone(),
|
p.2.info.platform.clone(),
|
||||||
|
p.2.options
|
||||||
|
.get("alias")
|
||||||
|
.unwrap_or(&"".to_owned())
|
||||||
|
.to_owned(),
|
||||||
];
|
];
|
||||||
Value::from_iter(values)
|
Value::from_iter(values)
|
||||||
})
|
})
|
||||||
@ -535,6 +554,8 @@ impl sciter::EventHandler for UI {
|
|||||||
fn fix_login_wayland();
|
fn fix_login_wayland();
|
||||||
fn get_options();
|
fn get_options();
|
||||||
fn get_option(String);
|
fn get_option(String);
|
||||||
|
fn get_peer_option(String, String);
|
||||||
|
fn set_peer_option(String, String, String);
|
||||||
fn test_if_valid_server(String);
|
fn test_if_valid_server(String);
|
||||||
fn get_sound_inputs();
|
fn get_sound_inputs();
|
||||||
fn set_options(Value);
|
fn set_options(Value);
|
||||||
|
@ -64,13 +64,14 @@ class RecentSessions: Reactor.Component {
|
|||||||
var username = s[1];
|
var username = s[1];
|
||||||
var hostname = s[2];
|
var hostname = s[2];
|
||||||
var platform = s[3];
|
var platform = s[3];
|
||||||
|
var alias = s[4];
|
||||||
return <div .remote-session id={id} platform={platform} style={"background:"+string2RGB(id+platform, 0.5)}>
|
return <div .remote-session id={id} platform={platform} style={"background:"+string2RGB(id+platform, 0.5)}>
|
||||||
<div .platform>
|
<div .platform>
|
||||||
{platformSvg(platform, "white")}
|
{platformSvg(platform, "white")}
|
||||||
<div .username>{username}@{hostname}</div>
|
<div .username>{username}@{hostname}</div>
|
||||||
</div>
|
</div>
|
||||||
<div .text>
|
<div .text>
|
||||||
<div>{formatId(id)}</div>
|
<div #alias>{alias ? alias : formatId(id)}</div>
|
||||||
{svg_menu}
|
{svg_menu}
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
@ -109,6 +110,17 @@ event click $(menu#remote-context li) (evt, me) {
|
|||||||
createNewConnect(id, "rdp");
|
createNewConnect(id, "rdp");
|
||||||
} else if (action == "tunnel") {
|
} else if (action == "tunnel") {
|
||||||
createNewConnect(id, "port-forward");
|
createNewConnect(id, "port-forward");
|
||||||
|
} else if (action == "rename") {
|
||||||
|
var old_name = handler.get_peer_option(id, "alias");
|
||||||
|
handler.msgbox("custom-rename", "Rename", "<div .form> \
|
||||||
|
<div><input name='name' style='width: *; height: 23px', value='" + old_name + "' /></div> \
|
||||||
|
</div> \
|
||||||
|
", function(res=null) {
|
||||||
|
if (!res) return;
|
||||||
|
var name = (res.name || "").trim();
|
||||||
|
if (name != old_name) handler.set_peer_option(id, "alias", name);
|
||||||
|
self.select('#' + id).select('#alias').text = name || id;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,6 +330,7 @@ class App: Reactor.Component
|
|||||||
<li #transfer>Transfer File</li>
|
<li #transfer>Transfer File</li>
|
||||||
<li #tunnel>TCP Tunneling</li>
|
<li #tunnel>TCP Tunneling</li>
|
||||||
<li #rdp>RDP</li>
|
<li #rdp>RDP</li>
|
||||||
|
<li #rename>Rename</li>
|
||||||
<li #remove>Remove</li>
|
<li #remove>Remove</li>
|
||||||
{is_win && <li #shortcut>Create Desktop Shortcut</li>}
|
{is_win && <li #shortcut>Create Desktop Shortcut</li>}
|
||||||
</menu>
|
</menu>
|
||||||
|
Loading…
Reference in New Issue
Block a user