Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a16f6591
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,发现更多精彩内容 >>
提交
a16f6591
编写于
6月 29, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #29729
上级
f00d4f73
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
101 addition
and
69 deletion
+101
-69
src/vs/workbench/parts/update/electron-browser/update.contribution.ts
...ench/parts/update/electron-browser/update.contribution.ts
+3
-10
src/vs/workbench/parts/update/electron-browser/update.ts
src/vs/workbench/parts/update/electron-browser/update.ts
+98
-59
未找到文件。
src/vs/workbench/parts/update/electron-browser/update.contribution.ts
浏览文件 @
a16f6591
...
@@ -8,8 +8,6 @@
...
@@ -8,8 +8,6 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
'
vs/css!./media/update.contribution
'
;
import
'
vs/css!./media/update.contribution
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
product
from
'
vs/platform/node/product
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
ReleaseNotesEditor
}
from
'
vs/workbench/parts/update/electron-browser/releaseNotesEditor
'
;
import
{
ReleaseNotesEditor
}
from
'
vs/workbench/parts/update/electron-browser/releaseNotesEditor
'
;
import
{
ReleaseNotesInput
}
from
'
vs/workbench/parts/update/electron-browser/releaseNotesInput
'
;
import
{
ReleaseNotesInput
}
from
'
vs/workbench/parts/update/electron-browser/releaseNotesInput
'
;
...
@@ -20,18 +18,13 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
...
@@ -20,18 +18,13 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IConfigurationRegistry
,
Extensions
as
ConfigurationExtensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
IConfigurationRegistry
,
Extensions
as
ConfigurationExtensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
ShowCurrentReleaseNotesAction
,
ProductContribution
,
UpdateContribution
,
LightUpdateContribution
}
from
'
./update
'
;
import
{
ShowCurrentReleaseNotesAction
,
ProductContribution
,
UpdateContribution
}
from
'
./update
'
;
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
)
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
)
.
registerWorkbenchContribution
(
ProductContribution
);
.
registerWorkbenchContribution
(
ProductContribution
);
if
(
isMacintosh
||
product
.
quality
!==
'
stable
'
)
{
Registry
.
as
<
IGlobalActivityRegistry
>
(
GlobalActivityExtensions
)
Registry
.
as
<
IGlobalActivityRegistry
>
(
GlobalActivityExtensions
)
.
registerActivity
(
UpdateContribution
);
.
registerActivity
(
LightUpdateContribution
);
}
else
{
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
)
.
registerWorkbenchContribution
(
UpdateContribution
);
}
// Editor
// Editor
const
editorDescriptor
=
new
EditorDescriptor
(
const
editorDescriptor
=
new
EditorDescriptor
(
...
...
src/vs/workbench/parts/update/electron-browser/update.ts
浏览文件 @
a16f6591
...
@@ -9,6 +9,8 @@ import nls = require('vs/nls');
...
@@ -9,6 +9,8 @@ import nls = require('vs/nls');
import
severity
from
'
vs/base/common/severity
'
;
import
severity
from
'
vs/base/common/severity
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IAction
,
Action
}
from
'
vs/base/common/actions
'
;
import
{
IAction
,
Action
}
from
'
vs/base/common/actions
'
;
import
{
mapEvent
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
Separator
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
Separator
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IMessageService
,
CloseAction
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
IMessageService
,
CloseAction
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
pkg
from
'
vs/platform/node/package
'
;
import
pkg
from
'
vs/platform/node/package
'
;
...
@@ -236,48 +238,18 @@ export class ProductContribution implements IWorkbenchContribution {
...
@@ -236,48 +238,18 @@ export class ProductContribution implements IWorkbenchContribution {
}
}
}
}
export
class
UpdateContribution
implements
IWorkbenchContribution
{
class
CommandAction
extends
Action
{
getId
()
{
return
'
vs.update
'
;
}
constructor
(
constructor
(
@
IInstantiationService
instantiationService
:
IInstantiationService
,
commandId
:
string
,
@
IMessageService
messageService
:
IMessageService
,
label
:
string
,
@
I
UpdateService
updateService
:
IUpdate
Service
@
I
CommandService
private
commandService
:
ICommand
Service
)
{
)
{
updateService
.
onUpdateReady
(
update
=>
{
super
(
`command-action:
${
commandId
}
`
,
label
,
undefined
,
true
,
()
=>
commandService
.
executeCommand
(
commandId
));
const
applyUpdateAction
=
instantiationService
.
createInstance
(
ApplyUpdateAction
);
const
releaseNotesAction
=
instantiationService
.
createInstance
(
ShowReleaseNotesAction
,
false
,
update
.
version
);
messageService
.
show
(
severity
.
Info
,
{
message
:
nls
.
localize
(
'
updateAvailable
'
,
"
{0} will be updated after it restarts.
"
,
product
.
nameLong
),
actions
:
[
applyUpdateAction
,
NotNowAction
,
releaseNotesAction
]
});
});
updateService
.
onUpdateAvailable
(
update
=>
{
const
downloadAction
=
instantiationService
.
createInstance
(
DownloadAction
,
update
.
version
);
const
releaseNotesAction
=
instantiationService
.
createInstance
(
ShowReleaseNotesAction
,
false
,
update
.
version
);
messageService
.
show
(
severity
.
Info
,
{
message
:
nls
.
localize
(
'
thereIsUpdateAvailable
'
,
"
There is an available update.
"
),
actions
:
[
downloadAction
,
NotNowAction
,
releaseNotesAction
]
});
});
updateService
.
onUpdateNotAvailable
(
explicit
=>
{
if
(
!
explicit
)
{
return
;
}
messageService
.
show
(
severity
.
Info
,
nls
.
localize
(
'
noUpdatesAvailable
'
,
"
There are no updates currently available.
"
));
});
updateService
.
onError
(
err
=>
messageService
.
show
(
severity
.
Error
,
err
));
}
}
}
}
export
class
Light
UpdateContribution
implements
IGlobalActivity
{
export
class
UpdateContribution
implements
IGlobalActivity
{
private
static
readonly
showCommandsId
=
'
workbench.action.showCommands
'
;
private
static
readonly
showCommandsId
=
'
workbench.action.showCommands
'
;
private
static
readonly
openSettingsId
=
'
workbench.action.openGlobalSettings
'
;
private
static
readonly
openSettingsId
=
'
workbench.action.openGlobalSettings
'
;
...
@@ -288,48 +260,111 @@ export class LightUpdateContribution implements IGlobalActivity {
...
@@ -288,48 +260,111 @@ export class LightUpdateContribution implements IGlobalActivity {
get
id
()
{
return
'
vs.update
'
;
}
get
id
()
{
return
'
vs.update
'
;
}
get
name
()
{
return
''
;
}
get
name
()
{
return
''
;
}
get
cssClass
()
{
return
'
update-activity
'
;
}
get
cssClass
()
{
return
'
update-activity
'
;
}
private
disposables
:
IDisposable
[]
=
[];
constructor
(
constructor
(
@
IStorageService
storageService
:
IStorageService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
ICommandService
private
commandService
:
ICommandService
,
@
ICommandService
private
commandService
:
ICommandService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IMessageService
messageService
:
IMessageService
,
@
IMessageService
private
messageService
:
IMessageService
,
@
IUpdateService
private
updateService
:
IUpdateService
,
@
IUpdateService
private
updateService
:
IUpdateService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IActivityBarService
activityBarService
:
IActivityBarService
@
IActivityBarService
private
activityBarService
:
IActivityBarService
)
{
)
{
const
addBadge
=
()
=>
{
const
onUpdateAvailable
=
isLinux
const
badge
=
new
NumberBadge
(
1
,
()
=>
nls
.
localize
(
'
updateIsReady
'
,
"
New update available.
"
));
?
mapEvent
(
updateService
.
onUpdateAvailable
,
e
=>
e
.
version
)
activityBarService
.
showGlobalActivity
(
this
.
id
,
badge
);
:
mapEvent
(
updateService
.
onUpdateReady
,
e
=>
e
.
version
);
};
onUpdateAvailable
(
this
.
onUpdateAvailable
,
this
,
this
.
disposables
);
updateService
.
onError
(
this
.
onError
,
this
,
this
.
disposables
);
updateService
.
onUpdateNotAvailable
(
this
.
onUpdateNotAvailable
,
this
,
this
.
disposables
);
/*
The `update/lastKnownVersion` and `update/updateNotificationTime` storage keys are used in
combination to figure out when to show a message to the user that he should update.
This message should appear if the user has received an update notification but hasn't
updated since 5 days.
*/
const
currentVersion
=
product
.
commit
;
const
lastKnownVersion
=
this
.
storageService
.
get
(
'
update/lastKnownVersion
'
,
StorageScope
.
GLOBAL
);
// if current version != stored version, clear both fields
if
(
currentVersion
!==
lastKnownVersion
)
{
this
.
storageService
.
remove
(
'
update/lastKnownVersion
'
,
StorageScope
.
GLOBAL
);
this
.
storageService
.
remove
(
'
update/updateNotificationTime
'
,
StorageScope
.
GLOBAL
);
}
}
private
onUpdateAvailable
(
version
:
string
):
void
{
const
badge
=
new
NumberBadge
(
1
,
()
=>
nls
.
localize
(
'
updateIsReady
'
,
"
New update available.
"
));
this
.
activityBarService
.
showGlobalActivity
(
this
.
id
,
badge
);
const
currentVersion
=
product
.
commit
;
const
currentMillis
=
new
Date
().
getTime
();
const
lastKnownVersion
=
this
.
storageService
.
get
(
'
update/lastKnownVersion
'
,
StorageScope
.
GLOBAL
);
// if version != stored version, save version and date
if
(
currentVersion
!==
lastKnownVersion
)
{
this
.
storageService
.
store
(
'
update/lastKnownVersion
'
,
currentVersion
,
StorageScope
.
GLOBAL
);
this
.
storageService
.
store
(
'
update/updateNotificationTime
'
,
currentMillis
,
StorageScope
.
GLOBAL
);
}
const
updateNotificationMillis
=
this
.
storageService
.
getInteger
(
'
update/updateNotificationTime
'
,
StorageScope
.
GLOBAL
,
currentMillis
);
const
diffDays
=
(
currentMillis
-
updateNotificationMillis
)
/
(
1000
*
60
*
60
*
24
);
// if 5 days have passed from stored date, show message service
if
(
diffDays
>
5
)
{
this
.
showUpdateNotification
(
version
);
}
}
private
showUpdateNotification
(
version
:
string
):
void
{
const
releaseNotesAction
=
this
.
instantiationService
.
createInstance
(
ShowReleaseNotesAction
,
false
,
version
);
if
(
isLinux
)
{
if
(
isLinux
)
{
this
.
updateService
.
onUpdateAvailable
(()
=>
addBadge
());
const
downloadAction
=
this
.
instantiationService
.
createInstance
(
DownloadAction
,
version
);
this
.
messageService
.
show
(
severity
.
Info
,
{
message
:
nls
.
localize
(
'
thereIsUpdateAvailable
'
,
"
There is an available update.
"
),
actions
:
[
downloadAction
,
NotNowAction
,
releaseNotesAction
]
});
}
else
{
}
else
{
this
.
updateService
.
onUpdateReady
(()
=>
addBadge
());
const
applyUpdateAction
=
this
.
instantiationService
.
createInstance
(
ApplyUpdateAction
);
this
.
messageService
.
show
(
severity
.
Info
,
{
message
:
nls
.
localize
(
'
updateAvailable
'
,
"
{0} will be updated after it restarts.
"
,
product
.
nameLong
),
actions
:
[
applyUpdateAction
,
NotNowAction
,
releaseNotesAction
]
});
}
}
}
this
.
updateService
.
onError
(
err
=>
messageService
.
show
(
severity
.
Error
,
err
));
private
onUpdateNotAvailable
(
explicit
:
boolean
):
void
{
if
(
!
explicit
)
{
return
;
}
this
.
updateService
.
onUpdateNotAvailable
(
explicit
=>
{
this
.
messageService
.
show
(
severity
.
Info
,
nls
.
localize
(
'
noUpdatesAvailable
'
,
"
There are no updates currently available.
"
));
if
(
!
explicit
)
{
}
return
;
}
messageService
.
show
(
severity
.
Info
,
nls
.
localize
(
'
noUpdatesAvailable
'
,
"
There are no updates currently available.
"
));
private
onError
(
err
:
any
):
void
{
}
);
this
.
messageService
.
show
(
severity
.
Error
,
err
);
}
}
getActions
():
IAction
[]
{
getActions
():
IAction
[]
{
const
updateAction
=
this
.
getUpdateAction
();
return
[
return
[
new
Action
(
LightUpdateContribution
.
showCommandsId
,
nls
.
localize
(
'
commandPalette
'
,
"
Command Palette...
"
),
undefined
,
true
,
()
=>
this
.
commandService
.
executeCommand
(
LightUpdateContribution
.
showCommandsId
)
),
new
CommandAction
(
UpdateContribution
.
showCommandsId
,
nls
.
localize
(
'
commandPalette
'
,
"
Command Palette...
"
),
this
.
commandService
),
new
Separator
(),
new
Separator
(),
new
Action
(
LightUpdateContribution
.
openSettingsId
,
nls
.
localize
(
'
settings
'
,
"
Settings
"
),
null
,
true
,
()
=>
this
.
commandService
.
executeCommand
(
LightUpdateContribution
.
openSettingsId
)
),
new
CommandAction
(
UpdateContribution
.
openSettingsId
,
nls
.
localize
(
'
settings
'
,
"
Settings
"
),
this
.
commandService
),
new
Action
(
LightUpdateContribution
.
openKeybindingsId
,
nls
.
localize
(
'
keyboardShortcuts
'
,
"
Keyboard Shortcuts
"
),
null
,
true
,
()
=>
this
.
commandService
.
executeCommand
(
LightUpdateContribution
.
openKeybindingsId
)
),
new
CommandAction
(
UpdateContribution
.
openKeybindingsId
,
nls
.
localize
(
'
keyboardShortcuts
'
,
"
Keyboard Shortcuts
"
),
this
.
commandService
),
new
Separator
(),
new
Separator
(),
new
Action
(
LightUpdateContribution
.
selectColorThemeId
,
nls
.
localize
(
'
selectTheme.label
'
,
"
Color Theme
"
),
null
,
true
,
()
=>
this
.
commandService
.
executeCommand
(
LightUpdateContribution
.
selectColorThemeId
)
),
new
CommandAction
(
UpdateContribution
.
selectColorThemeId
,
nls
.
localize
(
'
selectTheme.label
'
,
"
Color Theme
"
),
this
.
commandService
),
new
Action
(
LightUpdateContribution
.
selectIconThemeId
,
nls
.
localize
(
'
themes.selectIconTheme.label
'
,
"
File Icon Theme
"
),
null
,
true
,
()
=>
this
.
commandService
.
executeCommand
(
LightUpdateContribution
.
selectIconThemeId
)
),
new
CommandAction
(
UpdateContribution
.
selectIconThemeId
,
nls
.
localize
(
'
themes.selectIconTheme.label
'
,
"
File Icon Theme
"
),
this
.
commandService
),
new
Separator
(),
new
Separator
(),
this
.
getUpdateAction
()
updateAction
];
];
}
}
...
@@ -362,4 +397,8 @@ export class LightUpdateContribution implements IGlobalActivity {
...
@@ -362,4 +397,8 @@ export class LightUpdateContribution implements IGlobalActivity {
this
.
updateService
.
checkForUpdates
(
true
));
this
.
updateService
.
checkForUpdates
(
true
));
}
}
}
}
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录