Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
1bf88815
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,发现更多精彩内容 >>
提交
1bf88815
编写于
10月 03, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #12982
上级
3e9dc784
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
108 addition
and
18 deletion
+108
-18
src/vs/workbench/electron-browser/update.ts
src/vs/workbench/electron-browser/update.ts
+92
-7
src/vs/workbench/parts/update/electron-browser/update.contribution.ts
...ench/parts/update/electron-browser/update.contribution.ts
+16
-11
未找到文件。
src/vs/workbench/electron-browser/update.ts
浏览文件 @
1bf88815
...
...
@@ -13,9 +13,16 @@ import {ipcRenderer as ipc, shell} from 'electron';
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
pkg
from
'
vs/platform/package
'
;
import
product
from
'
vs/platform/product
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ReleaseNotesInput
}
from
'
vs/workbench/parts/update/electron-browser/releaseNotesInput
'
;
import
{
IRequestService
}
from
'
vs/platform/request/common/request
'
;
import
{
asText
}
from
'
vs/base/node/request
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
Keybinding
}
from
'
vs/base/common/keybinding
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
interface
IUpdate
{
releaseNotes
:
string
;
...
...
@@ -39,6 +46,70 @@ const NotNowAction = new Action(
()
=>
TPromise
.
as
(
true
)
);
export
function
loadReleaseNotes
(
accessor
:
ServicesAccessor
,
version
:
string
):
TPromise
<
string
>
{
const
requestService
=
accessor
.
get
(
IRequestService
);
const
keybindingService
=
accessor
.
get
(
IKeybindingService
);
const
match
=
/^
(\d
+
\.\d)\.
/
.
exec
(
version
);
if
(
!
match
)
{
return
TPromise
.
as
(
null
);
}
const
versionLabel
=
match
[
1
].
replace
(
/
\.
/g
,
'
_
'
);
const
baseUrl
=
'
https://code.visualstudio.com/raw
'
;
const
url
=
`
${
baseUrl
}
/v
${
versionLabel
}
.md`
;
const
patchKeybindings
=
(
text
:
string
):
string
=>
{
const
kb
=
(
match
:
string
,
kb
:
string
)
=>
{
const
keybinding
=
keybindingService
.
lookupKeybindings
(
kb
)[
0
];
if
(
!
keybinding
)
{
return
match
;
}
return
keybindingService
.
getLabelFor
(
keybinding
);
};
const
kbstyle
=
(
match
:
string
,
kb
:
string
)
=>
{
const
code
=
Keybinding
.
fromUserSettingsLabel
(
kb
);
if
(
!
code
)
{
return
match
;
}
const
keybinding
=
new
Keybinding
(
code
);
if
(
!
keybinding
)
{
return
match
;
}
return
keybindingService
.
getLabelFor
(
keybinding
);
};
return
text
.
replace
(
/kb
\(([
a-z.
\d\-]
+
)\)
/gi
,
kb
)
.
replace
(
/kbstyle
\(([^\)]
+
)\)
/gi
,
kbstyle
);
};
return
requestService
.
request
({
url
})
.
then
(
asText
)
.
then
(
text
=>
patchKeybindings
(
text
));
}
export
class
OpenLatestReleaseNotesInBrowserAction
extends
Action
{
constructor
(
@
IOpenerService
private
openerService
:
IOpenerService
)
{
super
(
'
update.openLatestReleaseNotes
'
,
nls
.
localize
(
'
releaseNotes
'
,
"
Release Notes
"
),
null
,
true
);
}
run
():
TPromise
<
any
>
{
const
uri
=
URI
.
parse
(
product
.
releaseNotesUrl
);
return
this
.
openerService
.
open
(
uri
);
}
}
export
abstract
class
AbstractShowReleaseNotesAction
extends
Action
{
constructor
(
...
...
@@ -47,14 +118,26 @@ export abstract class AbstractShowReleaseNotesAction extends Action {
private
returnValue
:
boolean
,
private
version
:
string
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IOpenerService
private
openerService
:
IOpenerService
)
{
super
(
id
,
label
,
null
,
true
);
}
run
():
TPromise
<
boolean
>
{
return
this
.
editorService
.
openEditor
(
this
.
instantiationService
.
createInstance
(
ReleaseNotesInput
,
this
.
version
))
.
then
(()
=>
this
.
returnValue
);
if
(
!
this
.
enabled
)
{
return
TPromise
.
as
(
false
);
}
this
.
enabled
=
false
;
return
this
.
instantiationService
.
invokeFunction
(
loadReleaseNotes
,
this
.
version
)
.
then
(
text
=>
this
.
editorService
.
openEditor
(
this
.
instantiationService
.
createInstance
(
ReleaseNotesInput
,
this
.
version
,
text
)))
.
then
(()
=>
true
)
.
then
(
null
,
()
=>
{
const
action
=
this
.
instantiationService
.
createInstance
(
OpenLatestReleaseNotesInBrowserAction
);
return
action
.
run
().
then
(()
=>
false
);
});
}
}
...
...
@@ -64,9 +147,10 @@ export class ShowReleaseNotesAction extends AbstractShowReleaseNotesAction {
returnValue
:
boolean
,
version
:
string
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IOpenerService
openerService
:
IOpenerService
)
{
super
(
'
update.showReleaseNotes
'
,
nls
.
localize
(
'
releaseNotes
'
,
"
Release Notes
"
),
returnValue
,
version
,
editorService
,
instantiationService
);
super
(
'
update.showReleaseNotes
'
,
nls
.
localize
(
'
releaseNotes
'
,
"
Release Notes
"
),
returnValue
,
version
,
editorService
,
instantiationService
,
openerService
);
}
}
...
...
@@ -79,9 +163,10 @@ export class ShowCurrentReleaseNotesAction extends AbstractShowReleaseNotesActio
id
=
ShowCurrentReleaseNotesAction
.
ID
,
label
=
ShowCurrentReleaseNotesAction
.
LABEL
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IOpenerService
openerService
:
IOpenerService
)
{
super
(
id
,
label
,
true
,
pkg
.
version
,
editorService
,
instantiationService
);
super
(
id
,
label
,
true
,
pkg
.
version
,
editorService
,
instantiationService
,
openerService
);
}
}
...
...
src/vs/workbench/parts/update/electron-browser/update.contribution.ts
浏览文件 @
1bf88815
...
...
@@ -15,7 +15,8 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } f
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IMessageService
,
CloseAction
}
from
'
vs/platform/message/common/message
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
ShowReleaseNotesAction
,
ShowCurrentReleaseNotesAction
}
from
'
vs/workbench/electron-browser/update
'
;
import
{
loadReleaseNotes
,
OpenLatestReleaseNotesInBrowserAction
,
ShowCurrentReleaseNotesAction
}
from
'
vs/workbench/electron-browser/update
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
shell
}
from
'
electron
'
;
...
...
@@ -42,22 +43,26 @@ export class UpdateContribution implements IWorkbenchContribution {
constructor
(
@
IStorageService
storageService
:
IStorageService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IMessageService
messageService
:
IMessageService
@
IMessageService
messageService
:
IMessageService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
)
{
const
lastVersion
=
storageService
.
get
(
UpdateContribution
.
KEY
,
StorageScope
.
GLOBAL
,
''
);
// was there an update?
if
(
product
.
releaseNotesUrl
&&
lastVersion
&&
pkg
.
version
!==
lastVersion
)
{
setTimeout
(()
=>
{
const
releaseNotesAction
=
this
.
instantiationService
.
createInstance
(
ShowReleaseNotesAction
,
true
,
pkg
.
version
);
messageService
.
show
(
Severity
.
Info
,
{
message
:
nls
.
localize
(
'
read the release notes
'
,
"
Welcome to {0} v{1}! Would you like to read the Release Notes?
"
,
product
.
nameLong
,
pkg
.
version
),
actions
:
[
releaseNotesAction
,
CloseAction
]
});
this
.
instantiationService
.
invokeFunction
(
loadReleaseNotes
,
pkg
.
version
)
.
then
(
text
=>
this
.
editorService
.
openEditor
(
this
.
instantiationService
.
createInstance
(
ReleaseNotesInput
,
pkg
.
version
,
text
)),
()
=>
{
messageService
.
show
(
Severity
.
Info
,
{
message
:
nls
.
localize
(
'
read the release notes
'
,
"
Welcome to {0} v{1}! Would you like to read the Release Notes?
"
,
product
.
nameLong
,
pkg
.
version
),
actions
:
[
this
.
instantiationService
.
createInstance
(
OpenLatestReleaseNotesInBrowserAction
),
CloseAction
]
});
});
},
0
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录