2024-07-23 14:48:37 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
|
|
|
)
|
|
|
|
|
|
|
|
type App struct {
|
|
|
|
BaseModel
|
2024-08-14 10:43:32 +08:00
|
|
|
Name string `json:"name" gorm:"not null"`
|
|
|
|
Key string `json:"key" gorm:"not null;"`
|
|
|
|
ShortDescZh string `json:"shortDescZh" yaml:"shortDescZh"`
|
|
|
|
ShortDescEn string `json:"shortDescEn" yaml:"shortDescEn"`
|
|
|
|
Icon string `json:"icon"`
|
|
|
|
Type string `json:"type" gorm:"not null"`
|
|
|
|
Status string `json:"status" gorm:"not null"`
|
|
|
|
Required string `json:"required"`
|
2024-07-23 14:48:37 +08:00
|
|
|
CrossVersionUpdate bool `json:"crossVersionUpdate" yaml:"crossVersionUpdate"`
|
2024-08-14 10:43:32 +08:00
|
|
|
Limit int `json:"limit" gorm:"not null"`
|
|
|
|
Website string `json:"website" gorm:"not null"`
|
|
|
|
Github string `json:"github" gorm:"not null"`
|
|
|
|
Document string `json:"document" gorm:"not null"`
|
|
|
|
Recommend int `json:"recommend" gorm:"not null"`
|
|
|
|
Resource string `json:"resource" gorm:"not null;default:remote"`
|
|
|
|
ReadMe string `json:"readMe"`
|
|
|
|
LastModified int `json:"lastModified"`
|
2024-08-22 15:08:55 +08:00
|
|
|
Architectures string `json:"architectures"`
|
|
|
|
MemoryLimit int `json:"memoryLimit"`
|
2024-07-23 14:48:37 +08:00
|
|
|
|
|
|
|
Details []AppDetail `json:"-" gorm:"-:migration"`
|
|
|
|
TagsKey []string `json:"tags" yaml:"tags" gorm:"-"`
|
|
|
|
AppTags []AppTag `json:"-" gorm:"-:migration"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *App) IsLocalApp() bool {
|
|
|
|
return i.Resource == constant.ResourceLocal
|
|
|
|
}
|
|
|
|
func (i *App) GetAppResourcePath() string {
|
|
|
|
if i.IsLocalApp() {
|
|
|
|
//这里要去掉本地应用的local前缀
|
|
|
|
return filepath.Join(constant.LocalAppResourceDir, strings.TrimPrefix(i.Key, "local"))
|
|
|
|
}
|
|
|
|
return filepath.Join(constant.RemoteAppResourceDir, i.Key)
|
|
|
|
}
|