mirror of
https://github.com/tsl0922/ttyd.git
synced 2026-02-09 03:24:24 +01:00
html: use file-saver to save file
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
"dependencies": {
|
||||
"backoff": "^2.5.0",
|
||||
"decko": "^1.2.0",
|
||||
"file-saver": "^2.0.2",
|
||||
"preact": "^10.0.5",
|
||||
"xterm": "^4.2.0",
|
||||
"xterm-addon-fit": "^0.3.0",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { bind } from 'decko';
|
||||
import { h, Component } from 'preact';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { IDisposable, ITerminalAddon, Terminal } from 'xterm';
|
||||
import * as Zmodem from 'zmodem.js/src/zmodem_browser';
|
||||
|
||||
@@ -76,7 +77,7 @@ export class ZmodemAddon extends Component<Props, State> implements ITerminalAdd
|
||||
|
||||
@bind
|
||||
private zmodemWrite(data: ArrayBuffer): void {
|
||||
this.terminal.writeUtf8(new Uint8Array(data));
|
||||
this.terminal.write(new Uint8Array(data));
|
||||
}
|
||||
|
||||
@bind
|
||||
@@ -132,7 +133,10 @@ export class ZmodemAddon extends Component<Props, State> implements ITerminalAdd
|
||||
});
|
||||
offer
|
||||
.accept()
|
||||
.then(() => Zmodem.Browser.save_to_disk(fileBuffer, offer.get_details().name))
|
||||
.then(() => {
|
||||
const blob = new Blob(fileBuffer, { type: 'application/octet-stream' });
|
||||
saveAs(blob, offer.get_details().name);
|
||||
})
|
||||
.catch(e => handleError(e, 'receive'));
|
||||
});
|
||||
|
||||
|
||||
@@ -2667,6 +2667,11 @@ figures@^2.0.0:
|
||||
dependencies:
|
||||
escape-string-regexp "^1.0.5"
|
||||
|
||||
file-saver@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/file-saver/-/file-saver-2.0.2.tgz#06d6e728a9ea2df2cce2f8d9e84dfcdc338ec17a"
|
||||
integrity sha512-Wz3c3XQ5xroCxd1G8b7yL0Ehkf0TC9oYC6buPFkNnU9EnaPlifeAFCyCh+iewXTyFRcg0a6j3J7FmJsIhlhBdw==
|
||||
|
||||
fill-range@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7"
|
||||
|
||||
2
src/index.html
vendored
2
src/index.html
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user