Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a0e0e88a
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
a0e0e88a
编写于
11月 20, 2017
作者:
M
Martin Aeschlimann
提交者:
GitHub
11月 20, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #38683 from Microsoft/ben/30032
cache icon data optimistically like color themes
上级
12c6aaa7
c65e4b6c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
13 deletion
+74
-13
src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
...nch/services/themes/electron-browser/fileIconThemeData.ts
+33
-0
src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts
...services/themes/electron-browser/workbenchThemeService.ts
+41
-13
未找到文件。
src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
浏览文件 @
a0e0e88a
...
...
@@ -77,6 +77,39 @@ export class FileIconThemeData implements IFileIconTheme {
}
return
themeData
;
}
static
fromStorageData
(
input
:
string
):
FileIconThemeData
{
try
{
let
data
=
JSON
.
parse
(
input
);
let
theme
=
new
FileIconThemeData
();
for
(
let
key
in
data
)
{
switch
(
key
)
{
case
'
id
'
:
case
'
label
'
:
case
'
description
'
:
case
'
settingsId
'
:
case
'
extensionData
'
:
case
'
path
'
:
theme
[
key
]
=
data
[
key
];
break
;
}
}
return
theme
;
}
catch
(
e
)
{
return
null
;
}
}
toStorageData
()
{
return
JSON
.
stringify
({
id
:
this
.
id
,
label
:
this
.
label
,
description
:
this
.
description
,
settingsId
:
this
.
settingsId
,
path
:
this
.
path
,
extensionData
:
this
.
extensionData
});
}
}
interface
IconDefinition
{
...
...
src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts
浏览文件 @
a0e0e88a
...
...
@@ -38,6 +38,7 @@ const DEFAULT_THEME_ID = 'vs-dark vscode-theme-defaults-themes-dark_plus-json';
const
DEFAULT_THEME_SETTING_VALUE
=
'
Default Dark+
'
;
const
PERSISTED_THEME_STORAGE_KEY
=
'
colorThemeData
'
;
const
PERSISTED_ICON_THEME_STORAGE_KEY
=
'
iconThemeData
'
;
const
defaultThemeExtensionId
=
'
vscode-theme-defaults
'
;
const
oldDefaultThemeExtensionId
=
'
vscode-theme-colorful-defaults
'
;
...
...
@@ -132,6 +133,20 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
this
.
updateDynamicCSSRules
(
themeData
);
this
.
applyTheme
(
themeData
,
null
,
true
);
let
iconData
:
FileIconThemeData
=
null
;
let
persistedIconThemeData
=
this
.
storageService
.
get
(
PERSISTED_ICON_THEME_STORAGE_KEY
);
if
(
persistedIconThemeData
)
{
iconData
=
FileIconThemeData
.
fromStorageData
(
persistedIconThemeData
);
if
(
iconData
)
{
_applyIconTheme
(
iconData
,
()
=>
{
this
.
doSetFileIconTheme
(
iconData
);
return
TPromise
.
wrap
(
iconData
);
});
}
}
this
.
initialize
().
then
(
null
,
errors
.
onUnexpectedError
).
then
(
_
=>
{
this
.
installConfigurationListener
();
});
...
...
@@ -353,23 +368,15 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
return
this
.
writeFileIconConfiguration
(
settingsTarget
);
}
let
onApply
=
(
newIconTheme
:
FileIconThemeData
)
=>
{
this
.
doSetFileIconTheme
(
newIconTheme
);
// remember theme data for a quick restore
if
(
newIconTheme
)
{
this
.
currentIconTheme
=
newIconTheme
;
this
.
storageService
.
store
(
PERSISTED_ICON_THEME_STORAGE_KEY
,
newIconTheme
.
toStorageData
())
;
}
else
{
this
.
currentIconTheme
=
FileIconThemeData
.
noIconTheme
(
);
this
.
storageService
.
remove
(
PERSISTED_ICON_THEME_STORAGE_KEY
);
}
if
(
this
.
container
)
{
if
(
newIconTheme
)
{
$
(
this
.
container
).
addClass
(
fileIconsEnabledClass
);
}
else
{
$
(
this
.
container
).
removeClass
(
fileIconsEnabledClass
);
}
}
if
(
newIconTheme
)
{
this
.
sendTelemetry
(
newIconTheme
.
id
,
newIconTheme
.
extensionData
,
'
fileIcon
'
);
}
this
.
onFileIconThemeChange
.
fire
(
this
.
currentIconTheme
);
return
this
.
writeFileIconConfiguration
(
settingsTarget
);
};
...
...
@@ -378,6 +385,27 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
});
}
private
doSetFileIconTheme
(
iconThemeData
:
FileIconThemeData
):
void
{
if
(
iconThemeData
)
{
this
.
currentIconTheme
=
iconThemeData
;
}
else
{
this
.
currentIconTheme
=
FileIconThemeData
.
noIconTheme
();
}
if
(
this
.
container
)
{
if
(
iconThemeData
)
{
$
(
this
.
container
).
addClass
(
fileIconsEnabledClass
);
}
else
{
$
(
this
.
container
).
removeClass
(
fileIconsEnabledClass
);
}
}
if
(
iconThemeData
)
{
this
.
sendTelemetry
(
iconThemeData
.
id
,
iconThemeData
.
extensionData
,
'
fileIcon
'
);
}
this
.
onFileIconThemeChange
.
fire
(
this
.
currentIconTheme
);
}
private
writeFileIconConfiguration
(
settingsTarget
:
ConfigurationTarget
):
TPromise
<
IFileIconTheme
>
{
if
(
!
types
.
isUndefinedOrNull
(
settingsTarget
))
{
return
this
.
configurationWriter
.
writeConfiguration
(
ICON_THEME_SETTING
,
this
.
currentIconTheme
.
settingsId
,
settingsTarget
).
then
(
_
=>
this
.
currentIconTheme
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录