Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/internal/extension/repo/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ func (e *ExtensionRepo) Save(ctx context.Context, ext *db.Extension) (*db.Extens
}

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)
}

return e.Latest(ctx)
}
return e.db.Extension.Query().Where(extension.Version(version)).Only(ctx)
}
1 change: 1 addition & 0 deletions backend/internal/user/handler/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func NewUserHandler(
}

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))

w.POST("/api/v1/vscode/init-auth", web.BindHandler(u.VSCodeAuthInit))

// admin
Expand Down
Loading