Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Tabby
提交
d319a54f
T
Tabby
项目概览
后端镜像
/
Tabby
通知
37
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Tabby
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d319a54f
编写于
9月 19, 2021
作者:
E
Eugene Pankov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
show recent profiles in the start page - fixes #4585
上级
397a93bd
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
48 addition
and
27 deletion
+48
-27
tabby-core/src/api/toolbarButtonProvider.ts
tabby-core/src/api/toolbarButtonProvider.ts
+4
-0
tabby-core/src/buttonProvider.ts
tabby-core/src/buttonProvider.ts
+20
-25
tabby-core/src/components/appRoot.component.ts
tabby-core/src/components/appRoot.component.ts
+1
-0
tabby-core/src/components/startPage.component.ts
tabby-core/src/components/startPage.component.ts
+1
-0
tabby-core/src/icons/history.svg
tabby-core/src/icons/history.svg
+1
-0
tabby-core/src/services/profiles.service.ts
tabby-core/src/services/profiles.service.ts
+21
-2
未找到文件。
tabby-core/src/api/toolbarButtonProvider.ts
浏览文件 @
d319a54f
...
...
@@ -27,6 +27,10 @@ export interface ToolbarButton {
/** @hidden */
submenuItems
?:
ToolbarButton
[]
showInToolbar
?:
boolean
showInStartPage
?:
boolean
}
/**
...
...
tabby-core/src/buttonProvider.ts
浏览文件 @
d319a54f
...
...
@@ -3,8 +3,6 @@ import { Injectable } from '@angular/core'
import
{
ToolbarButton
,
ToolbarButtonProvider
}
from
'
./api/toolbarButtonProvider
'
import
{
HostAppService
,
Platform
}
from
'
./api/hostApp
'
import
{
PartialProfile
,
Profile
}
from
'
./api/profileProvider
'
import
{
ConfigService
}
from
'
./services/config.service
'
import
{
HotkeysService
}
from
'
./services/hotkeys.service
'
import
{
ProfilesService
}
from
'
./services/profiles.service
'
...
...
@@ -14,7 +12,6 @@ export class ButtonProvider extends ToolbarButtonProvider {
constructor
(
private
hostApp
:
HostAppService
,
private
profilesService
:
ProfilesService
,
private
config
:
ConfigService
,
hotkeys
:
HotkeysService
,
)
{
super
()
...
...
@@ -28,31 +25,29 @@ export class ButtonProvider extends ToolbarButtonProvider {
async
activate
()
{
const
profile
=
await
this
.
profilesService
.
showProfileSelector
()
if
(
profile
)
{
this
.
launchProfile
(
profile
)
this
.
profilesService
.
launchProfile
(
profile
)
}
}
async
launchProfile
(
profile
:
PartialProfile
<
Profile
>
)
{
await
this
.
profilesService
.
openNewTabForProfile
(
profile
)
let
recentProfiles
:
PartialProfile
<
Profile
>
[]
=
JSON
.
parse
(
window
.
localStorage
[
'
recentProfiles
'
]
??
'
[]
'
)
if
(
this
.
config
.
store
.
terminal
.
showRecentProfiles
>
0
)
{
recentProfiles
=
recentProfiles
.
filter
(
x
=>
x
.
group
!==
profile
.
group
||
x
.
name
!==
profile
.
name
)
recentProfiles
.
unshift
(
profile
)
recentProfiles
=
recentProfiles
.
slice
(
0
,
this
.
config
.
store
.
terminal
.
showRecentProfiles
)
}
else
{
recentProfiles
=
[]
}
window
.
localStorage
[
'
recentProfiles
'
]
=
JSON
.
stringify
(
recentProfiles
)
}
provide
():
ToolbarButton
[]
{
return
[{
icon
:
this
.
hostApp
.
platform
===
Platform
.
Web
?
require
(
'
./icons/plus.svg
'
)
:
require
(
'
./icons/profiles.svg
'
),
title
:
'
New tab with profile
'
,
click
:
()
=>
this
.
activate
(),
}]
return
[
{
icon
:
this
.
hostApp
.
platform
===
Platform
.
Web
?
require
(
'
./icons/plus.svg
'
)
:
require
(
'
./icons/profiles.svg
'
),
title
:
'
New tab with profile
'
,
click
:
()
=>
this
.
activate
(),
},
...
this
.
profilesService
.
getRecentProfiles
().
map
(
profile
=>
({
icon
:
require
(
'
./icons/history.svg
'
),
title
:
profile
.
name
,
showInToolbar
:
false
,
showinStartPage
:
true
,
click
:
async
()
=>
{
const
p
=
(
await
this
.
profilesService
.
getProfiles
()).
find
(
x
=>
x
.
id
===
profile
.
id
)
??
profile
this
.
profilesService
.
launchProfile
(
p
)
},
})),
]
}
}
tabby-core/src/components/appRoot.component.ts
浏览文件 @
d319a54f
...
...
@@ -203,6 +203,7 @@ export class AppRootComponent {
buttons
=
buttons
.
concat
(
provider
.
provide
())
})
return
buttons
.
filter
(
x
=>
x
.
showInToolbar
??
true
)
.
filter
(
button
=>
(
button
.
weight
??
0
)
>
0
===
aboveZero
)
.
sort
((
a
:
ToolbarButton
,
b
:
ToolbarButton
)
=>
(
a
.
weight
??
0
)
-
(
b
.
weight
??
0
))
}
...
...
tabby-core/src/components/startPage.component.ts
浏览文件 @
d319a54f
...
...
@@ -25,6 +25,7 @@ export class StartPageComponent {
return
this
.
config
.
enabledServices
(
this
.
toolbarButtonProviders
)
.
map
(
provider
=>
provider
.
provide
())
.
reduce
((
a
,
b
)
=>
a
.
concat
(
b
))
.
filter
(
x
=>
x
.
showInStartPage
??
true
)
.
filter
(
x
=>
!!
x
.
click
)
.
sort
((
a
:
ToolbarButton
,
b
:
ToolbarButton
)
=>
(
a
.
weight
??
0
)
-
(
b
.
weight
??
0
))
}
...
...
tabby-core/src/icons/history.svg
0 → 100644
浏览文件 @
d319a54f
<svg
aria-hidden=
"true"
focusable=
"false"
data-prefix=
"far"
data-icon=
"history"
class=
"svg-inline--fa fa-history fa-w-16"
role=
"img"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 512 512"
><path
fill=
"#fff"
d=
"M504 255.532c.252 136.64-111.182 248.372-247.822 248.468-64.014.045-122.373-24.163-166.394-63.942-5.097-4.606-5.3-12.543-.443-17.4l16.96-16.96c4.529-4.529 11.776-4.659 16.555-.395C158.208 436.843 204.848 456 256 456c110.549 0 200-89.468 200-200 0-110.549-89.468-200-200-200-55.52 0-105.708 22.574-141.923 59.043l49.091 48.413c7.641 7.535 2.305 20.544-8.426 20.544H26.412c-6.627 0-12-5.373-12-12V45.443c0-10.651 12.843-16.023 20.426-8.544l45.097 44.474C124.866 36.067 187.15 8 256 8c136.811 0 247.747 110.781 248 247.532zm-167.058 90.173l14.116-19.409c3.898-5.36 2.713-12.865-2.647-16.763L280 259.778V116c0-6.627-5.373-12-12-12h-24c-6.627 0-12 5.373-12 12v168.222l88.179 64.13c5.36 3.897 12.865 2.712 16.763-2.647z"
></path></svg>
tabby-core/src/services/profiles.service.ts
浏览文件 @
d319a54f
...
...
@@ -89,11 +89,16 @@ export class ProfilesService {
}
}
getRecentProfiles
():
PartialProfile
<
Profile
>
[]
{
let
recentProfiles
:
PartialProfile
<
Profile
>
[]
=
JSON
.
parse
(
window
.
localStorage
[
'
recentProfiles
'
]
??
'
[]
'
)
recentProfiles
=
recentProfiles
.
slice
(
0
,
this
.
config
.
store
.
terminal
.
showRecentProfiles
)
return
recentProfiles
}
showProfileSelector
():
Promise
<
PartialProfile
<
Profile
>|
null
>
{
return
new
Promise
<
PartialProfile
<
Profile
>|
null
>
(
async
(
resolve
,
reject
)
=>
{
try
{
let
recentProfiles
:
PartialProfile
<
Profile
>
[]
=
JSON
.
parse
(
window
.
localStorage
[
'
recentProfiles
'
]
??
'
[]
'
)
recentProfiles
=
recentProfiles
.
slice
(
0
,
this
.
config
.
store
.
terminal
.
showRecentProfiles
)
const
recentProfiles
=
this
.
getRecentProfiles
()
let
options
:
SelectorOption
<
void
>
[]
=
recentProfiles
.
map
(
p
=>
({
...
this
.
selectorOptionForProfile
(
p
),
...
...
@@ -188,4 +193,18 @@ export class ProfilesService {
].
reduce
(
configMerge
,
{})
return
new
ConfigProxy
(
profile
,
defaults
)
as
unknown
as
T
}
async
launchProfile
(
profile
:
PartialProfile
<
Profile
>
):
Promise
<
void
>
{
await
this
.
openNewTabForProfile
(
profile
)
let
recentProfiles
:
PartialProfile
<
Profile
>
[]
=
JSON
.
parse
(
window
.
localStorage
[
'
recentProfiles
'
]
??
'
[]
'
)
if
(
this
.
config
.
store
.
terminal
.
showRecentProfiles
>
0
)
{
recentProfiles
=
recentProfiles
.
filter
(
x
=>
x
.
group
!==
profile
.
group
||
x
.
name
!==
profile
.
name
)
recentProfiles
.
unshift
(
profile
)
recentProfiles
=
recentProfiles
.
slice
(
0
,
this
.
config
.
store
.
terminal
.
showRecentProfiles
)
}
else
{
recentProfiles
=
[]
}
window
.
localStorage
[
'
recentProfiles
'
]
=
JSON
.
stringify
(
recentProfiles
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录