做了个 vscode 的下载 mirror 站

353 天前
 zhenruyan

房东的网下载 vscode 50k 60k 慢慢蹦。,。急坏我了。。。 搜了搜原来微软有国内 cdn

写了个脚本抓 vscode 的 github hash 拼上微软自己的的国内 cdn 直接强制走国内 cdn 下载 vscode

https://code.visualstudiocn.com/

3352 次点击
所在节点    Visual Studio Code
27 条回复
CodeCodeStudy
352 天前
vscode 源码地址
https://github.com/microsoft/vscode/tree/main/src/vs/platform/update/electron-main/abstractUpdateService.ts#L17

可以看到更新地址为
${productService.updateUrl}/api/update/${platform}/${quality}/${productService.commit}

${productService} 是接口 IProductConfiguration , 接口源码在 https://github.com/microsoft/vscode/blob/main/src/vs/base/common/product.ts#L57 ,实际的值在安装目录的 resources/app/product.json 里找到,github 源码根目录的 product.json 并不完整

${productService.updateUrl} 为 https://update.code.visualstudio.com

${platform} 为 win32-x64
x64 是 node.js 的 process.arch 的值,可以是'arm', 'arm64', 'ia32', 'mips','mipsel', 'ppc', 'ppc64', 's390', 's390x', and 'x64',如果是 ia32 的话则只需要 win32
值还可以是 win32-${process.arch}-archive ,win32-${process.arch}-user ,archive 就是下载 zip ,user 就是安装到用户目录,跟官方下载页的下载按钮对应。
如果是 linux 的话就是 linux-${process.arch}
如果是 mac 的话就是 darwin 或 darwin-arm64

${quality} 为 stable
${productService.commit} 为任意一个有效的 commit 即可,在 vscode 程序的帮助-关于那里看得到,也可以在安装目录的 resources/app/product.json 里找到

比如
https://update.code.visualstudio.com/api/update/win32-x64/stable/b380da4ef1ee00e224a15c1d4d9793e27c2b6302

该地址会输出
{"url":"https://vscode.cdn.azure.cn/stable/4cb974a7aed77a74c7813bdccd99ee0d04901215/VSCodeSetup-x64-1.79.1.exe?1","name":"1.79.1","version":"4cb974a7aed77a74c7813bdccd99ee0d04901215","productVersion":"1.79.1","hash":"1750c77f3be2691111239ba466b6d025ed8cd068","timestamp":1686586079352,"sha256hash":"bd3efa6bb9d76166142443b76c54ed934cdb6d5a8b1a6e839fa5068eed609150","supportsFastUpdate":true}

如果在外网的话会输出
{"url":"https://az764295.vo.msecnd.net/stable/4cb974a7aed77a74c7813bdccd99ee0d04901215/VSCodeSetup-x64-1.79.1.exe","name":"1.79.1","version":"4cb974a7aed77a74c7813bdccd99ee0d04901215","productVersion":"1.79.1","hash":"1750c77f3be2691111239ba466b6d025ed8cd068","timestamp":1686586079352,"sha256hash":"bd3efa6bb9d76166142443b76c54ed934cdb6d5a8b1a6e839fa5068eed609150","supportsFastUpdate":true}

这个 json 的 url 就是下载地址了
CodeCodeStudy
352 天前
CodeCodeStudy
351 天前
https://code.visualstudio.com/docs/supporting/faq#_previous-release-versions

这里有各个平台的下载地址,比如 https://update.code.visualstudio.com/{version}/win32-x64/stable ,{version} 换成版本号,比如 1.79.1 ,也可以用 latest 下载最新版本,会自动跳转到国内的 cdn ,也就是 vscode.cdn.azure.cn
CodeCodeStudy
347 天前
更新页面 https://code.visualstudio.com/updates 顶部的下载链接就是国内的 CDN ,非常快
zhenruyan
333 天前
@CodeCodeStudy hahhh 我就是这么搞的 想搞个脚本自动化 一直拖拖拉拉还没做完
CodeCodeStudy
147 天前
@zhenruyan 你怎么不更新了,现在是 1.85 了,你的镜像站还是 1.79
CodeCodeStudy
147 天前

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/948166

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX