Commit d2f9fd14 authored by liuzheng712's avatar liuzheng712 Committed by i317280

fix: use canvas to replace the iframe

parent 74b26dc1
...@@ -27,7 +27,13 @@ ...@@ -27,7 +27,13 @@
"../node_modules/jquery/dist/jquery.min.js", "../node_modules/jquery/dist/jquery.min.js",
"../node_modules/tether/dist/js/tether.min.js", "../node_modules/tether/dist/js/tether.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js", "../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/xterm/dist/xterm.js" "../node_modules/xterm/dist/xterm.js",
"../node_modules/socket.io-client/dist/socket.io.js",
"./assets/js/mstsc.js",
"./assets/js/keyboard.js",
"./assets/js/rle.js",
"./assets/js/client.js",
"./assets/js/canvas.js"
], ],
"environmentSource": "environments/environment.ts", "environmentSource": "environments/environment.ts",
"environments": { "environments": {
......
...@@ -6,5 +6,12 @@ ...@@ -6,5 +6,12 @@
"/socket.io/": { "/socket.io/": {
"target": "http://localhost:3000", "target": "http://localhost:3000",
"secure": false "secure": false
},
"/rdp/socket.io/": {
"target": "http://localhost:9250",
"pathRewrite": {
"^/rdp": ""
},
"secure": false
} }
} }
...@@ -25,11 +25,13 @@ export class CleftbarComponent implements OnInit { ...@@ -25,11 +25,13 @@ export class CleftbarComponent implements OnInit {
{ {
name: "ops-linux", name: "ops-linux",
uuid: "xxxx", uuid: "xxxx",
type: "ssh" type: "ssh",
token: "sshxxx"
}, { }, {
name: "ops-win", name: "ops-win",
uuid: "win-aasdf", uuid: "win-aasdf",
type: "rdp" type: "rdp",
token: "rdpxxx"
} }
], ],
}]; }];
......
...@@ -48,7 +48,6 @@ export class ControlnavComponent implements OnInit { ...@@ -48,7 +48,6 @@ export class ControlnavComponent implements OnInit {
} else if (NavList.List[index].type === 'rdp') { } else if (NavList.List[index].type === 'rdp') {
jQuery("app-ssh").hide(); jQuery("app-ssh").hide();
jQuery("app-rdp").show(); jQuery("app-rdp").show();
jQuery("#rdp-" + index + " iframe")[0].contentWindow.focus();
} }
} }
......
<div id="rdp"> <div id="rdp">
<div *ngFor="let m of NavList.List;let i=index" <div *ngFor="let m of NavList.List;let i=index"
[ngClass]="{'disconnected':!m.connected,'hidden': m.hide,'hidden':m.type!='rdp'}" id="rdp-{{i}}"> [ngClass]="{'disconnected':!m.connected,'hidden': m.hide,'hidden':m.type!='rdp'}" id="rdp-{{i}}">
<iframe src="http://127.0.0.1:9250/?token=000"></iframe> <canvas id="canvas-{{i}}"></canvas>
</div> </div>
</div> </div>
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {NavList, View, Rdp} from '../control.component'; import {NavList, View, Rdp} from '../control.component';
declare let jQuery: any; declare let Mstsc: any;
@Component({ @Component({
selector: 'app-rdp', selector: 'app-rdp',
...@@ -35,12 +35,17 @@ export class RdpComponent implements OnInit { ...@@ -35,12 +35,17 @@ export class RdpComponent implements OnInit {
NavList.List[id].hide = false; NavList.List[id].hide = false;
NavList.Active = id; NavList.Active = id;
jQuery("#rdp-" + id + " iframe")[0].contentWindow.focus(); let client = Mstsc.client.create(Mstsc.$("canvas-" + id));
let canvas = Mstsc.$("canvas-" + id);
canvas.style.display = 'inline';
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
client.connect("xxxx", "rdp/socket.io");
} }
static Disconnect(host) { static Disconnect(host) {
host.connected = false; host.connected = false;
// document.getElementById("templatesrc").remove(); // document.getElementById("templatesrc").remove();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment