Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a4f610ec
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a4f610ec
编写于
12月 19, 2019
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
5a94ca0b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
22 deletion
+27
-22
src/vs/workbench/services/themes/browser/workbenchThemeService.ts
...orkbench/services/themes/browser/workbenchThemeService.ts
+27
-22
未找到文件。
src/vs/workbench/services/themes/browser/workbenchThemeService.ts
浏览文件 @
a4f610ec
...
...
@@ -53,6 +53,7 @@ const DEFAULT_THEME_HC_SETTING_VALUE = 'Default High Contrast';
const
PERSISTED_THEME_STORAGE_KEY
=
'
colorThemeData
'
;
const
PERSISTED_ICON_THEME_STORAGE_KEY
=
'
iconThemeData
'
;
const
PERSISTED_OS_COLOR_SCHEME
=
'
osColorScheme
'
;
const
defaultThemeExtensionId
=
'
vscode-theme-defaults
'
;
const
oldDefaultThemeExtensionId
=
'
vscode-theme-colorful-defaults
'
;
...
...
@@ -273,16 +274,13 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
}
}
let
theme
=
await
this
.
colorThemeStore
.
findThemeDataBySettingsId
(
colorThemeSetting
,
DEFAULT_THEME_ID
);
const
preferredType
=
this
.
getPreferredColorScheme
();
let
settingsTarget
:
undefined
|
'
auto
'
=
undefined
;
if
(
preferredType
&&
theme
&&
theme
.
type
!==
preferredType
)
{
const
preferedTheme
=
await
this
.
getPreferredColorTheme
(
preferredType
);
if
(
preferedTheme
)
{
theme
=
preferedTheme
;
settingsTarget
=
'
auto
'
;
}
const
persistedColorScheme
=
this
.
storageService
.
get
(
PERSISTED_OS_COLOR_SCHEME
,
StorageScope
.
GLOBAL
);
const
preferredColorScheme
=
this
.
getPreferredColorScheme
();
if
(
persistedColorScheme
&&
preferredColorScheme
&&
persistedColorScheme
!==
preferredColorScheme
)
{
return
this
.
applyPreferredColorTheme
(
preferredColorScheme
);
}
return
this
.
setColorTheme
(
theme
&&
theme
.
id
,
settingsTarget
);
return
this
.
setColorTheme
(
theme
&&
theme
.
id
,
undefined
);
};
const
initializeIconTheme
=
async
()
=>
{
...
...
@@ -312,10 +310,16 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
}
}
if
(
e
.
affectsConfiguration
(
DETECT_COLOR_SCHEME_SETTING
))
{
let
autoSwitchColorTheme
=
this
.
configurationService
.
getValue
<
boolean
>
(
DETECT_COLOR_SCHEME_SETTING
);
if
(
autoSwitchColorTheme
)
{
this
.
preferredSchemeUpdated
();
}
this
.
preferredSchemeUpdated
();
}
if
(
e
.
affectsConfiguration
(
PREFERRED_DARK_THEME_SETTING
)
&&
this
.
getPreferredColorScheme
()
===
DARK
)
{
this
.
applyPreferredColorTheme
(
DARK
);
}
if
(
e
.
affectsConfiguration
(
PREFERRED_LIGHT_THEME_SETTING
)
&&
this
.
getPreferredColorScheme
()
===
LIGHT
)
{
this
.
applyPreferredColorTheme
(
LIGHT
);
}
if
(
e
.
affectsConfiguration
(
PREFERRED_HC_THEME_SETTING
)
&&
this
.
getPreferredColorScheme
()
===
HIGH_CONTRAST
)
{
this
.
applyPreferredColorTheme
(
HIGH_CONTRAST
);
}
if
(
e
.
affectsConfiguration
(
ICON_THEME_SETTING
))
{
let
iconThemeSetting
=
this
.
configurationService
.
getValue
<
string
|
null
>
(
ICON_THEME_SETTING
);
...
...
@@ -355,11 +359,9 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
private
async
preferredSchemeUpdated
()
{
const
scheme
=
this
.
getPreferredColorScheme
();
if
(
scheme
&&
this
.
currentColorTheme
.
type
!==
scheme
)
{
const
preferedTheme
=
await
this
.
getPreferredColorTheme
(
scheme
);
if
(
preferedTheme
)
{
return
this
.
setColorTheme
(
preferedTheme
.
id
,
'
auto
'
);
}
this
.
storageService
.
store
(
PERSISTED_OS_COLOR_SCHEME
,
scheme
,
StorageScope
.
GLOBAL
);
if
(
scheme
)
{
return
this
.
applyPreferredColorTheme
(
scheme
);
}
return
undefined
;
}
...
...
@@ -379,13 +381,16 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
return
undefined
;
}
private
getPreferredColorTheme
(
type
:
ThemeType
):
Promise
<
ColorThemeData
|
undefined
>
{
private
async
applyPreferredColorTheme
(
type
:
ThemeType
):
Promise
<
IColorTheme
|
null
>
{
const
settingId
=
type
===
DARK
?
PREFERRED_DARK_THEME_SETTING
:
type
===
LIGHT
?
PREFERRED_LIGHT_THEME_SETTING
:
PREFERRED_HC_THEME_SETTING
;
const
themeSettingId
=
this
.
configurationService
.
getValue
<
string
>
(
settingId
);
if
(
themeSettingId
)
{
return
this
.
colorThemeStore
.
findThemeDataBySettingsId
(
themeSettingId
,
undefined
);
const
theme
=
await
this
.
colorThemeStore
.
findThemeDataBySettingsId
(
themeSettingId
,
undefined
);
if
(
theme
)
{
return
this
.
setColorTheme
(
theme
.
id
,
'
auto
'
);
}
}
return
Promise
.
resolve
(
undefined
);
return
Promise
.
resolve
(
null
);
}
public
getColorTheme
():
IColorTheme
{
...
...
@@ -736,7 +741,7 @@ const preferredHCThemeSettingSchema: IConfigurationPropertySchema = {
};
const
detectColorSchemeSettingSchema
:
IConfigurationPropertySchema
=
{
type
:
'
boolean
'
,
description
:
nls
.
localize
(
'
detectColorScheme
'
,
'
If set,
use the prefe
red color theme based on the OS appearance.
'
),
description
:
nls
.
localize
(
'
detectColorScheme
'
,
'
If set,
automatically switch to the prefer
red color theme based on the OS appearance.
'
),
default
:
true
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录