Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
e3c3d7c3
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
e3c3d7c3
编写于
6月 30, 2017
作者:
J
João Moreno
提交者:
GitHub
6月 30, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #29859 from Microsoft/update-notification
Fixes #29729
上级
7e293723
a16f6591
变更
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
浏览文件 @
e3c3d7c3
...
...
@@ -8,8 +8,6 @@
import
*
as
nls
from
'
vs/nls
'
;
import
'
vs/css!./media/update.contribution
'
;
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
{
ReleaseNotesEditor
}
from
'
vs/workbench/parts/update/electron-browser/releaseNotesEditor
'
;
import
{
ReleaseNotesInput
}
from
'
vs/workbench/parts/update/electron-browser/releaseNotesInput
'
;
...
...
@@ -20,18 +18,13 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
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
)
.
registerWorkbenchContribution
(
ProductContribution
);
if
(
isMacintosh
||
product
.
quality
!==
'
stable
'
)
{
Registry
.
as
<
IGlobalActivityRegistry
>
(
GlobalActivityExtensions
)
.
registerActivity
(
LightUpdateContribution
);
}
else
{
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
)
.
registerWorkbenchContribution
(
UpdateContribution
);
}
Registry
.
as
<
IGlobalActivityRegistry
>
(
GlobalActivityExtensions
)
.
registerActivity
(
UpdateContribution
);
// Editor
const
editorDescriptor
=
new
EditorDescriptor
(
...
...
src/vs/workbench/parts/update/electron-browser/update.ts
浏览文件 @
e3c3d7c3
...
...
@@ -9,6 +9,8 @@ import nls = require('vs/nls');
import
severity
from
'
vs/base/common/severity
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
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
{
IMessageService
,
CloseAction
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
pkg
from
'
vs/platform/node/package
'
;
...
...
@@ -236,48 +238,18 @@ export class ProductContribution implements IWorkbenchContribution {
}
}
export
class
UpdateContribution
implements
IWorkbenchContribution
{
getId
()
{
return
'
vs.update
'
;
}
class
CommandAction
extends
Action
{
constructor
(
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IMessageService
messageService
:
IMessageService
,
@
I
UpdateService
updateService
:
IUpdate
Service
commandId
:
string
,
label
:
string
,
@
I
CommandService
private
commandService
:
ICommand
Service
)
{
updateService
.
onUpdateReady
(
update
=>
{
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
));
super
(
`command-action:
${
commandId
}
`
,
label
,
undefined
,
true
,
()
=>
commandService
.
executeCommand
(
commandId
));
}
}
export
class
Light
UpdateContribution
implements
IGlobalActivity
{
export
class
UpdateContribution
implements
IGlobalActivity
{
private
static
readonly
showCommandsId
=
'
workbench.action.showCommands
'
;
private
static
readonly
openSettingsId
=
'
workbench.action.openGlobalSettings
'
;
...
...
@@ -288,48 +260,111 @@ export class LightUpdateContribution implements IGlobalActivity {
get
id
()
{
return
'
vs.update
'
;
}
get
name
()
{
return
''
;
}
get
cssClass
()
{
return
'
update-activity
'
;
}
private
disposables
:
IDisposable
[]
=
[];
constructor
(
@
IStorageService
storageService
:
IStorageService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
ICommandService
private
commandService
:
ICommandService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IMessageService
messageService
:
IMessageService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IMessageService
private
messageService
:
IMessageService
,
@
IUpdateService
private
updateService
:
IUpdateService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IActivityBarService
activityBarService
:
IActivityBarService
@
IActivityBarService
private
activityBarService
:
IActivityBarService
)
{
const
addBadge
=
()
=>
{
const
badge
=
new
NumberBadge
(
1
,
()
=>
nls
.
localize
(
'
updateIsReady
'
,
"
New update available.
"
));
activityBarService
.
showGlobalActivity
(
this
.
id
,
badge
);
};
const
onUpdateAvailable
=
isLinux
?
mapEvent
(
updateService
.
onUpdateAvailable
,
e
=>
e
.
version
)
:
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
)
{
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
{
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
=>
{
if
(
!
explicit
)
{
return
;
}
this
.
messageService
.
show
(
severity
.
Info
,
nls
.
localize
(
'
noUpdatesAvailable
'
,
"
There are no updates currently available.
"
));
}
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
[]
{
const
updateAction
=
this
.
getUpdateAction
();
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
Action
(
LightUpdateContribution
.
openSettingsId
,
nls
.
localize
(
'
settings
'
,
"
Settings
"
),
null
,
true
,
()
=>
this
.
commandService
.
executeCommand
(
LightUpdateContribution
.
openSettingsId
)
),
new
Action
(
LightUpdateContribution
.
openKeybindingsId
,
nls
.
localize
(
'
keyboardShortcuts
'
,
"
Keyboard Shortcuts
"
),
null
,
true
,
()
=>
this
.
commandService
.
executeCommand
(
LightUpdateContribution
.
openKeybindingsId
)
),
new
CommandAction
(
UpdateContribution
.
openSettingsId
,
nls
.
localize
(
'
settings
'
,
"
Settings
"
),
this
.
commandService
),
new
CommandAction
(
UpdateContribution
.
openKeybindingsId
,
nls
.
localize
(
'
keyboardShortcuts
'
,
"
Keyboard Shortcuts
"
),
this
.
commandService
),
new
Separator
(),
new
Action
(
LightUpdateContribution
.
selectColorThemeId
,
nls
.
localize
(
'
selectTheme.label
'
,
"
Color Theme
"
),
null
,
true
,
()
=>
this
.
commandService
.
executeCommand
(
LightUpdateContribution
.
selectColorThemeId
)
),
new
Action
(
LightUpdateContribution
.
selectIconThemeId
,
nls
.
localize
(
'
themes.selectIconTheme.label
'
,
"
File Icon Theme
"
),
null
,
true
,
()
=>
this
.
commandService
.
executeCommand
(
LightUpdateContribution
.
selectIconThemeId
)
),
new
CommandAction
(
UpdateContribution
.
selectColorThemeId
,
nls
.
localize
(
'
selectTheme.label
'
,
"
Color Theme
"
),
this
.
commandService
),
new
CommandAction
(
UpdateContribution
.
selectIconThemeId
,
nls
.
localize
(
'
themes.selectIconTheme.label
'
,
"
File Icon Theme
"
),
this
.
commandService
),
new
Separator
(),
this
.
getUpdateAction
()
updateAction
];
}
...
...
@@ -362,4 +397,8 @@ export class LightUpdateContribution implements IGlobalActivity {
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录