Commit af5e0b44 authored by ibuler's avatar ibuler

[Update] 更新初始terminal大小

parent e5703176
......@@ -2,7 +2,9 @@ import {AfterViewInit, Component, Input, OnInit } from '@angular/core';
import {Terminal} from 'xterm';
import {NavList} from '../../pages/control/control/control.component';
import {UUIDService} from '../../app.service';
import {CookieService} from 'ngx-cookie-service';
import {TermWS} from '../../globals';
import {isNumber} from 'ngx-bootstrap/timepicker/timepicker.utils';
const ws = TermWS;
......@@ -20,7 +22,7 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
term: Terminal;
secret: string;
constructor(private _uuid: UUIDService) {
constructor(private _uuid: UUIDService, private _cookie: CookieService) {
}
ngOnInit() {
......@@ -33,6 +35,11 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
background: '#1f1b1b'
}
});
const rowInit = this._cookie.get('rows') || '24';
const colsInit = this._cookie.get('cols') || '80';
if (isNumber(rowInit) && isNumber(colsInit)) {
this.term.resize(parseInt(colsInit, 10), parseInt(rowInit, 10));
}
}
ngAfterViewInit() {
......
......@@ -3,6 +3,7 @@ import {ElementRef} from '@angular/core';
import {Terminal} from 'xterm';
import {fit} from 'xterm/lib/addons/fit/fit';
import {Observable} from 'rxjs/Rx';
import { CookieService } from 'ngx-cookie-service';
import 'rxjs/Observable';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
......@@ -21,7 +22,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
@Output() winSizeChangeTrigger = new EventEmitter<Array<number>>();
winSizeChange$: Observable<any>;
constructor() {
constructor(private _cookie: CookieService) {
}
ngOnInit() {
......@@ -44,17 +45,9 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
resizeTerm() {
fit(this.term);
// let contentElement = $('.window.active');
// if (contentElement.length === 0) {
// contentElement = $('body');
// }
// const markerElement = $('#marker');
// const col = Math.floor((contentElement.width() - 30) / markerElement.width() * 6) - 1;
// const row = Math.floor((contentElement.height() - 30) / markerElement.height());
// this.col = col > 80 ? col : 80;
// this.row = row > 24 ? row : 24;
// this.term.resize(this.col, this.row);
this.winSizeChangeTrigger.emit([this.term.cols, this.term.rows]);
this._cookie.set('cols', this.term.cols.toString(), 0, '/', document.domain);
this._cookie.set('rows', this.term.rows.toString(), 0, '/', document.domain);
}
active() {
......
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