portable service

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-11-10 10:27:13 +08:00
parent eb60ab0b79
commit 8e1545b432
46 changed files with 1217 additions and 72 deletions

View File

@@ -68,7 +68,7 @@ div.permissions {
}
div.permissions > div {
size: 48px;
size: 42px;
background: color(accent);
}

View File

@@ -51,6 +51,10 @@ impl InvokeUiCM for SciterHandler {
fn change_language(&self) {
// TODO
}
fn show_elevation(&self, show: bool) {
self.call("showElevation", &make_args!(show));
}
}
impl SciterHandler {
@@ -123,6 +127,14 @@ impl SciterConnectionManager {
fn t(&self, name: String) -> String {
crate::client::translate(name)
}
fn can_elevate(&self) -> bool {
crate::ui_cm_interface::can_elevate()
}
fn elevate_portable(&self, id: i32) {
crate::ui_cm_interface::elevate_portable(id);
}
}
impl sciter::EventHandler for SciterConnectionManager {
@@ -141,5 +153,7 @@ impl sciter::EventHandler for SciterConnectionManager {
fn authorize(i32);
fn switch_permission(i32, String, bool);
fn send_msg(i32, String);
fn can_elevate();
fn elevate_portable(i32);
}
}

View File

@@ -3,6 +3,7 @@ view.windowFrame = is_osx ? #extended : #solid;
var body;
var connections = [];
var show_chat = false;
var show_elevation = true;
class Body: Reactor.Component
{
@@ -27,6 +28,7 @@ class Body: Reactor.Component
};
var right_style = show_chat ? "" : "display: none";
var disconnected = c.disconnected;
var show_elevation_btn = handler.can_elevate() && show_elevation;
// below size:* is work around for Linux, it alreayd set in css, but not work, shit sciter
return <div .content style="size:*">
<div .left-panel>
@@ -55,10 +57,12 @@ class Body: Reactor.Component
{c.port_forward ? <div>Port Forwarding: {c.port_forward}</div> : ""}
<div style="size:*"/>
<div .buttons>
{auth ? "" : <button .button tabindex="-1" #accept>{translate('Accept')}</button>}
{auth ? "" : <button .button tabindex="-1" .outline #dismiss>{translate('Dismiss')}</button>}
{auth && !disconnected ? <button .button tabindex="-1" #disconnect>{translate('Disconnect')}</button> : ""}
{auth && disconnected ? <button .button tabindex="-1" #close>{translate('Close')}</button> : ""}
{!auth && show_elevation_btn ? <button .button tabindex="-1" #elevate_accept style="width:50;background-color:green;">{translate('Elevate')}</button> : "" }
{auth ? "" : <button .button tabindex="-1" style={!auth && show_elevation_btn ? "width:50;" : ""} #accept>{translate('Accept')}</button>}
{auth ? "" : <button .button tabindex="-1" style={!auth && show_elevation_btn ? "width:50;" : ""} .outline #dismiss>{translate('Dismiss')}</button>}
{auth && !disconnected && show_elevation_btn ? <button .button tabindex="-1" #elevate style="width:50;background-color:green;">{translate('Elevate')}</button> : "" }
{auth && !disconnected ? <button .button tabindex="-1" #disconnect style={auth && show_elevation_btn ? "width:50;" : ""} >{translate('Disconnect')}</button> : ""}
{auth && disconnected ? <button .button tabindex="-1" #close>{translate('Close')}</button> : ""}
</div>
{c.is_file_transfer || c.port_forward ? "" : <div .chaticon>{svg_chat}</div>}
</div>
@@ -144,6 +148,32 @@ class Body: Reactor.Component
});
}
event click $(button#elevate_accept) {
var { cid, connection } = this;
checkClickTime(function() {
connection.authorized = true;
show_elevation = false;
body.update();
handler.elevate_portable(cid);
handler.authorize(cid);
self.timer(30ms, function() {
view.windowState = View.WINDOW_MINIMIZED;
});
});
}
event click $(button#elevate) {
var { cid, connection } = this;
checkClickTime(function() {
show_elevation = false;
body.update();
handler.elevate_portable(cid);
self.timer(30ms, function() {
view.windowState = View.WINDOW_MINIMIZED;
});
});
}
event click $(button#dismiss) {
var cid = this.cid;
checkClickTime(function() {
@@ -386,6 +416,13 @@ handler.newMessage = function(id, text) {
update();
}
handler.showElevation = function(show) {
if (show != show_elevation) {
show_elevation = show;
update();
}
}
view << event statechange {
adjustBorder();
}