Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
luna
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
luna
Commits
ff7e8f3a
Commit
ff7e8f3a
authored
Oct 23, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 根据操作系统调整terminal 行高
parent
88619fc4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
19 deletions
+27
-19
angular.json
angular.json
+1
-2
json.component.ts
src/app/elements/replay/json/json.component.ts
+2
-8
ssh-term.component.ts
src/app/elements/ssh-term/ssh-term.component.ts
+2
-9
common.ts
src/app/utils/common.ts
+22
-0
No files found.
angular.json
View file @
ff7e8f3a
...
...
@@ -151,4 +151,4 @@
"prefix"
:
"app"
}
}
}
\ No newline at end of file
}
src/app/elements/replay/json/json.component.ts
View file @
ff7e8f3a
...
...
@@ -2,6 +2,7 @@ import {Component, Input, OnInit, OnChanges} from '@angular/core';
import
{
Terminal
}
from
'xterm'
;
import
{
HttpService
,
LogService
}
from
'@app/services'
;
import
{
Replay
}
from
'@app/model'
;
import
{
newTerminal
}
from
'@app/utils/common'
;
function
zeroPad
(
num
,
minLength
)
{
let
str
=
num
.
toString
();
...
...
@@ -80,14 +81,7 @@ export class ElementReplayJsonComponent implements OnInit {
constructor
(
private
_http
:
HttpService
)
{}
ngOnInit
()
{
this
.
term
=
new
Terminal
({
fontFamily
:
'"Monaco", "Consolas", "monospace"'
,
fontSize
:
14
,
rightClickSelectsWord
:
true
,
theme
:
{
background
:
'#1f1b1b'
}
});
this
.
term
=
newTerminal
(
14
);
if
(
this
.
replay
.
src
!==
'READY'
)
{
this
.
_http
.
getReplayData
(
this
.
replay
.
src
)
.
subscribe
(
...
...
src/app/elements/ssh-term/ssh-term.component.ts
View file @
ff7e8f3a
...
...
@@ -4,6 +4,7 @@ import {View} from '@app/model';
import
{
LogService
,
SettingService
,
UUIDService
}
from
'@app/services'
;
import
{
Socket
}
from
'@app/utils/socket'
;
import
{
getWsSocket
,
translate
}
from
'@app/globals'
;
import
{
newTerminal
}
from
'@app/utils/common'
;
@
Component
({
...
...
@@ -38,15 +39,7 @@ export class ElementSshTermComponent implements OnInit, OnDestroy {
newTerm
()
{
const
fontSize
=
this
.
settingSvc
.
setting
.
fontSize
;
this
.
term
=
new
Terminal
({
fontFamily
:
'monaco, Consolas, "Lucida Console", monospace'
,
lineHeight
:
1.2
,
fontSize
:
fontSize
,
rightClickSelectsWord
:
true
,
theme
:
{
background
:
'#1f1b1b'
}
});
this
.
term
=
newTerminal
(
fontSize
);
this
.
view
.
Term
=
this
.
term
;
this
.
term
.
attachCustomKeyEventHandler
(
e
=>
{
if
(
e
.
ctrlKey
&&
e
.
key
===
'c'
&&
this
.
term
.
hasSelection
())
{
...
...
src/app/utils/common.ts
View file @
ff7e8f3a
import
{
Terminal
}
from
'xterm'
;
export
function
groupBy
(
array
,
f
)
{
const
groups
=
{};
array
.
forEach
(
function
(
o
)
{
...
...
@@ -9,3 +11,23 @@ export function groupBy(array, f) {
return
groups
[
group
];
});
}
export
function
newTerminal
(
fontSize
?:
number
)
{
if
(
!
fontSize
||
fontSize
<
5
||
fontSize
>
50
)
{
fontSize
=
13
;
}
const
ua
=
navigator
.
userAgent
.
toLowerCase
();
let
lineHeight
=
1
;
if
(
ua
.
indexOf
(
'windows'
)
!==
-
1
)
{
lineHeight
=
1.2
;
}
return
new
Terminal
({
fontFamily
:
'monaco, Consolas, "Lucida Console", monospace'
,
lineHeight
:
lineHeight
,
fontSize
:
fontSize
,
rightClickSelectsWord
:
true
,
theme
:
{
background
:
'#1f1b1b'
}
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment