Skip to content

Commit 41e5a18

Browse files
committed
¿
1 parent 117b39c commit 41e5a18

File tree

9 files changed

+86
-36
lines changed

9 files changed

+86
-36
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,7 @@ _Pvt_Extensions
234234

235235
# FAKE - F# Make
236236
.fake/
237+
238+
239+
winpty.dll
240+
winpty-agent.exe

Helpers/PtyHelper.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class PtyHelper
1515
private static PtyHelper? _ptyHelper = null;
1616

1717
private CancellationTokenSource? _cancellationToken = null;
18-
18+
protected UTF8Encoding Encoding = new(false);
1919

2020
private PtyHelper()
2121
{
@@ -97,7 +97,7 @@ public async Task<IPtyConnection> get_terminal()
9797

9898
_cancellationToken = new CancellationTokenSource();
9999

100-
_ptyConnection = await PtyProvider.SpawnAsync(new PtyOptions() {Cols = 90, Rows = 50, App = shell_type, Cwd = "/", VerbatimCommandLine = true, ForceWinPty = true}, _cancellationToken.Token);
100+
_ptyConnection = await PtyProvider.SpawnAsync(new PtyOptions() {Cols = 90, Rows = 30, App = shell_type, Cwd = "/", VerbatimCommandLine = true, ForceWinPty = true}, _cancellationToken.Token);
101101

102102

103103

@@ -139,21 +139,21 @@ public async void read_term(Stream term)
139139

140140

141141

142-
byte[] buffer = new byte[4096];
142+
byte[] buffer = new byte[8096];
143143

144144
while (!_cancellationToken!.IsCancellationRequested)
145145
{
146-
147-
148-
int count = await term.ReadAsync(buffer, 0, buffer.Length, this._cancellationToken.Token).ConfigureAwait(false);
146+
147+
148+
int count = await term.ReadAsync(buffer, 0, buffer.Length, this._cancellationToken.Token);
149149

150150
if (count == 0)
151151
{
152152
return;
153153
}
154154

155155

156-
var stuff = Encoding.UTF8.GetString(buffer, 0, count);
156+
var stuff = Encoding.GetString(buffer, 0, count);
157157

158158
/*await clientProxy.SendAsync("shell_session", stuff);*/
159159

Program.cs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@
1414
using spa.Helpers;
1515

1616

17+
struct my_json
18+
{
19+
public string my_username;
20+
public string my_password;
21+
22+
}
23+
24+
25+
struct my_json2
26+
{
27+
28+
public string username;
29+
public string password;
30+
31+
}
32+
33+
34+
1735
public class Program
1836
{
1937
public static void Main(string[] args)
@@ -58,14 +76,9 @@ public void init(){
5876

5977
var json = File.ReadAllText("appsettings.json");
6078

61-
dynamic stuff = JsonConvert.DeserializeObject(json)!;
79+
var stuff = JsonConvert.DeserializeObject<my_json>(json)!;
6280

6381

64-
var username = (string)stuff.my_username;
65-
var password = (string)stuff.my_password;
66-
67-
68-
6982

7083

7184
builder.Services.AddSignalR(options =>
@@ -160,10 +173,10 @@ public void init(){
160173
}
161174

162175

163-
dynamic stuff = JsonConvert.DeserializeObject(bodyAsText)!;
176+
var thejson = JsonConvert.DeserializeObject<my_json2>(bodyAsText)!;
164177

165-
var user = (string)stuff.username;
166-
var pass = (string)stuff.password;
178+
var user = (string)thejson.username;
179+
var pass = (string)thejson.password;
167180

168181

169182
if (string.IsNullOrWhiteSpace(user))
@@ -180,9 +193,9 @@ public void init(){
180193

181194

182195

183-
if (user.Equals(username))
196+
if (user.Equals(stuff.my_username))
184197
{
185-
if (pass.Equals(password))
198+
if (pass.Equals(stuff.my_password))
186199
{
187200
httpContext.Response.Cookies.Append("secret",Jwt.create_jwt(),new CookieOptions(){Expires = DateTimeOffset.UtcNow.AddDays(7)});
188201
await httpContext.Response.WriteAsync("ok");

README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

embedded/ClientApp/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4+
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0">-->
55
<title>Terminal</title>
66
</head>
77

embedded/ClientApp/package-lock.json

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

embedded/ClientApp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"vite": "^3.1.3",
2222
"vue": "^3.2.39",
2323
"vue-router": "^4.1.5",
24-
"xterm": "^5.0.0"
24+
"xterm": "^5.0.0",
25+
"xterm-addon-webgl": "^0.13.0"
2526
},
2627
"devDependencies": {
2728
"@vitejs/plugin-vue": "^3.1.0"

embedded/ClientApp/src/pages/hello.vue

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
<div class="py-4"/>
1818

19-
<div style="padding: 15px; border-radius: 1rem; overflow: hidden; ; background-color: #002b36" class="shadow-6">
19+
20+
<div style="padding: 15px; border-radius: 1rem; overflow: hidden; ; background-color: #002b36; " class="shadow-6">
2021
<div id="terminal"></div>
2122
</div>
2223

@@ -48,24 +49,27 @@
4849
<script lang="ts">
4950
5051
import 'xterm/css/xterm.css';
51-
import type {Terminal} from 'xterm'
52+
import type {ITerminalAddon, Terminal} from 'xterm'
5253
import {ismobile, singleton} from "../singleton";
53-
54+
//@ts-ignore
55+
import { WebglAddon } from 'xterm-addon-webgl'
5456
5557
export default {
5658
5759
data(){
5860
return{
5961
xterm:null as Terminal,
60-
wtf:false as boolean
62+
addon:null as ITerminalAddon
63+
6164
}
6265
},
6366
6467
6568
6669
unmounted() {
67-
this.xterm?.dispose()
68-
this.xterm = null
70+
this.dispose()
71+
72+
6973
},
7074
7175
@@ -77,10 +81,7 @@ export default {
7781
7882
this.$nextTick(async()=>{
7983
80-
81-
this.xterm?.dispose()
82-
this.xterm = null
83-
84+
this.dispose()
8485
8586
/* await singleton.Instance.socket_send('SendMessage',"cool")*/
8687
@@ -100,6 +101,13 @@ export default {
100101
101102
methods:{
102103
104+
dispose(){
105+
this.addon?.dispose()
106+
this.addon = null
107+
this.xterm?.dispose()
108+
this.xterm = null
109+
110+
},
103111
104112
toast(){
105113
@@ -135,10 +143,16 @@ export default {
135143
136144
const load = await import('xterm')
137145
146+
147+
138148
if (this.xterm) return
139149
140150
141-
this.xterm = new load.Terminal({cursorBlink:true,
151+
this.xterm = new load.Terminal({
152+
153+
allowProposedApi:true,
154+
155+
cursorBlink:true,
142156
143157
144158
convertEol:true,
@@ -173,14 +187,18 @@ export default {
173187
174188
this.xterm.open(el);
175189
176-
177-
178190
el.setAttribute('contenteditable', 'true');
179191
el.setAttribute('spellcheck', 'false');
180192
el.setAttribute('autocorrect', 'false');
181193
el.setAttribute('autocomplete', 'false');
182194
el.setAttribute('autocapitalize', 'false');
183195
196+
197+
this.addon = new WebglAddon();
198+
this.addon.activate(this.xterm)
199+
200+
201+
184202
this.xterm.onData(async data=>{
185203
186204

spa.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>

0 commit comments

Comments
 (0)