2022-09-22 08:16:04 +00:00
|
|
|
package model
|
|
|
|
|
2023-12-12 02:36:12 +00:00
|
|
|
import (
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2022-09-22 08:16:04 +00:00
|
|
|
type App struct {
|
|
|
|
BaseModel
|
2023-05-15 14:40:05 +00:00
|
|
|
Name string `json:"name" gorm:"type:varchar(64);not null"`
|
2023-05-16 09:31:47 +00:00
|
|
|
Key string `json:"key" gorm:"type:varchar(64);not null;"`
|
|
|
|
ShortDescZh string `json:"shortDescZh" yaml:"shortDescZh" gorm:"type:longtext;"`
|
|
|
|
ShortDescEn string `json:"shortDescEn" yaml:"shortDescEn" gorm:"type:longtext;"`
|
2023-05-15 14:40:05 +00:00
|
|
|
Icon string `json:"icon" gorm:"type:longtext;"`
|
|
|
|
Type string `json:"type" gorm:"type:varchar(64);not null"`
|
|
|
|
Status string `json:"status" gorm:"type:varchar(64);not null"`
|
2023-05-16 09:31:47 +00:00
|
|
|
Required string `json:"required" gorm:"type:varchar(64);"`
|
2024-06-03 09:55:46 +00:00
|
|
|
CrossVersionUpdate bool `json:"crossVersionUpdate" yaml:"crossVersionUpdate"`
|
2023-05-15 14:40:05 +00:00
|
|
|
Limit int `json:"limit" gorm:"type:Integer;not null"`
|
|
|
|
Website string `json:"website" gorm:"type:varchar(64);not null"`
|
|
|
|
Github string `json:"github" gorm:"type:varchar(64);not null"`
|
|
|
|
Document string `json:"document" gorm:"type:varchar(64);not null"`
|
|
|
|
Recommend int `json:"recommend" gorm:"type:Integer;not null"`
|
|
|
|
Resource string `json:"resource" gorm:"type:varchar;not null;default:remote"`
|
|
|
|
ReadMe string `json:"readMe" gorm:"type:varchar;"`
|
|
|
|
LastModified int `json:"lastModified" gorm:"type:Integer;"`
|
|
|
|
|
|
|
|
Details []AppDetail `json:"-" gorm:"-:migration"`
|
2023-05-16 09:31:47 +00:00
|
|
|
TagsKey []string `json:"tags" yaml:"tags" gorm:"-"`
|
2023-05-15 14:40:05 +00:00
|
|
|
AppTags []AppTag `json:"-" gorm:"-:migration"`
|
2022-09-22 08:16:04 +00:00
|
|
|
}
|
2023-12-12 02:36:12 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|