1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

fix: 解决 node.js 运行环境模块页面打开失败的问题 (#2498)

This commit is contained in:
zhengkunwang 2023-10-10 22:22:29 -05:00 committed by GitHub
parent 153fe5c1db
commit 8f713c0eda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -191,7 +191,7 @@ func (b *BaseApi) GetNodeModules(c *gin.Context) {
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /runtimes/node/modules/operate [post] // @Router /runtimes/node/modules/operate [post]
func (b *BaseApi) OperateNodeModules(c *gin.Context) { func (b *BaseApi) OperateNodeModules(c *gin.Context) {
var req request.NodeModuleReq var req request.NodeModuleOperateReq
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }

View File

@ -54,9 +54,13 @@ type RuntimeOperate struct {
ID uint `json:"ID"` ID uint `json:"ID"`
} }
type NodeModuleReq struct { type NodeModuleOperateReq struct {
Operate string `json:"operate" validate:"oneof=install uninstall update"` Operate string `json:"operate" validate:"oneof=install uninstall update"`
ID uint `json:"ID" validate:"required"` ID uint `json:"ID" validate:"required"`
Module string `json:"module"` Module string `json:"module"`
PkgManager string `json:"pkgManager" validate:"oneof=npm yarn"` PkgManager string `json:"pkgManager" validate:"oneof=npm yarn"`
} }
type NodeModuleReq struct {
ID uint `json:"ID" validate:"required"`
}

View File

@ -37,7 +37,7 @@ type IRuntimeService interface {
GetNodePackageRunScript(req request.NodePackageReq) ([]response.PackageScripts, error) GetNodePackageRunScript(req request.NodePackageReq) ([]response.PackageScripts, error)
OperateRuntime(req request.RuntimeOperate) error OperateRuntime(req request.RuntimeOperate) error
GetNodeModules(req request.NodeModuleReq) ([]response.NodeModule, error) GetNodeModules(req request.NodeModuleReq) ([]response.NodeModule, error)
OperateNodeModules(req request.NodeModuleReq) error OperateNodeModules(req request.NodeModuleOperateReq) error
} }
func NewRuntimeService() IRuntimeService { func NewRuntimeService() IRuntimeService {
@ -482,7 +482,7 @@ func (r *RuntimeService) GetNodeModules(req request.NodeModuleReq) ([]response.N
return res, nil return res, nil
} }
func (r *RuntimeService) OperateNodeModules(req request.NodeModuleReq) error { func (r *RuntimeService) OperateNodeModules(req request.NodeModuleOperateReq) error {
runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.ID)) runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.ID))
if err != nil { if err != nil {
return err return err