Skip to content

fix(extensions): 修复插件内容下载地址#62

Merged
yokowu merged 1 commit intochaitin:mainfrom
yokowu:fix-extensions
Jul 9, 2025
Merged

fix(extensions): 修复插件内容下载地址#62
yokowu merged 1 commit intochaitin:mainfrom
yokowu:fix-extensions

Conversation

@yokowu
Copy link
Copy Markdown
Collaborator

@yokowu yokowu commented Jul 9, 2025

No description provided.

@yokowu yokowu merged commit 550d401 into chaitin:main Jul 9, 2025
2 checks passed
@yokowu yokowu deleted the fix-extensions branch July 9, 2025 02:44
@safe1ine
Copy link
Copy Markdown
Collaborator

@MonkeyCode-AI 来 review

Copy link
Copy Markdown
Contributor

@MonkeyCode-AI MonkeyCode-AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request 概述

  • 这个PR主要做了两处修改:一是为ExtensionRepo的GetByVersion方法添加了对空版本号的处理,当版本号为空时会返回最新的扩展;二是在用户相关的API路由中增加了一个新的VSIX下载接口,允许不指定版本号直接下载。

Pull Request 变更详情

文件路径 变更类型 变更内容
backend/internal/extension/repo/extension.go 修改 为GetByVersion方法添加了对空版本号的处理逻辑
backend/internal/user/handler/v1/user.go 添加 增加了一个新的VSIX下载路由,不指定版本号

}

func (e *ExtensionRepo) GetByVersion(ctx context.Context, version string) (*db.Extension, error) {
if version == "" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在ExtensionRepo.GetByVersion中添加空版本号检查是个不错的改进,增强了函数的健壮性。但需要注意的是,这里的Latest()方法是否也会处理版本号为空的情况?建议添加注释说明这样处理的原因和预期行为。

Suggested change
if version == "" {
// 当版本号为空时,返回最新的扩展
if version == "" {
return e.Latest(ctx)
}

}

w.GET("/api/v1/static/vsix/:version", web.BaseHandler(u.VSIXDownload))
w.GET("/api/v1/static/vsix", web.BaseHandler(u.VSIXDownload))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增的不带版本号的VSIX下载路由是个有用的功能扩展。不过需要确保VSIXDownload处理器方法能够正确处理没有版本号参数的情况,包括返回适当的错误信息或默认行为。

Suggested change
w.GET("/api/v1/static/vsix", web.BaseHandler(u.VSIXDownload))
// 添加注释说明该路由的作用和处理逻辑
// 支持不指定版本号下载最新的VSIX文件
w.GET("/api/v1/static/vsix", web.BaseHandler(u.VSIXDownload))

@MonkeyCode-AI
Copy link
Copy Markdown
Contributor

⏳ MonkeyCode-AI 正在分析,请稍等片刻...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants