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

fix: 解决创建网站应用没有关联的 BUG

This commit is contained in:
zhengkunwang223 2023-02-27 17:22:14 +08:00 committed by zhengkunwang223
parent 52dd0da4f8
commit f2b0eeb1f7
13 changed files with 33 additions and 37 deletions

View File

@ -4,6 +4,7 @@ import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/app/dto/request"
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -37,10 +38,13 @@ func (b *BaseApi) SearchApp(c *gin.Context) {
// @Router /apps/sync [post] // @Router /apps/sync [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFuntions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"} // @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFuntions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"}
func (b *BaseApi) SyncApp(c *gin.Context) { func (b *BaseApi) SyncApp(c *gin.Context) {
global.LOG.Infof("sync app list start ...")
if err := appService.SyncAppList(); err != nil { if err := appService.SyncAppList(); err != nil {
global.LOG.Errorf("sync app list error [%s]", err.Error())
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }
global.LOG.Infof("sync app list success!")
helper.SuccessWithData(c, "") helper.SuccessWithData(c, "")
} }

View File

@ -16,7 +16,7 @@ type App struct {
Github string `json:"github" 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"` Document string `json:"document" gorm:"type:varchar(64);not null"`
Recommend int `json:"recommend" gorm:"type:Integer;not null"` Recommend int `json:"recommend" gorm:"type:Integer;not null"`
Details []AppDetail `json:"-"` Details []AppDetail `json:"-" gorm:"-:migration"`
TagsKey []string `json:"-" gorm:"-"` TagsKey []string `json:"-" gorm:"-"`
AppTags []AppTag `json:"-" ` AppTags []AppTag `json:"-" gorm:"-:migration"`
} }

View File

@ -21,8 +21,8 @@ type AppInstall struct {
ServiceName string `json:"serviceName" gorm:"type:varchar(256);not null"` ServiceName string `json:"serviceName" gorm:"type:varchar(256);not null"`
HttpPort int `json:"httpPort" gorm:"type:integer;not null"` HttpPort int `json:"httpPort" gorm:"type:integer;not null"`
HttpsPort int `json:"httpsPort" gorm:"type:integer;not null"` HttpsPort int `json:"httpsPort" gorm:"type:integer;not null"`
App App `json:"app"` App App `json:"app" gorm:"-:migration"`
Backups []AppInstallBackup `json:"backups"` Backups []AppInstallBackup `json:"backups" gorm:"-:migration"`
} }
func (i *AppInstall) GetPath() string { func (i *AppInstall) GetPath() string {

View File

@ -7,5 +7,5 @@ type AppInstallBackup struct {
Param string `gorm:"type:longtext;" json:"param"` Param string `gorm:"type:longtext;" json:"param"`
AppDetailId uint `gorm:"type:integer;not null" json:"app_detail_id"` AppDetailId uint `gorm:"type:integer;not null" json:"app_detail_id"`
AppInstallId uint `gorm:"type:integer;not null" json:"app_install_id"` AppInstallId uint `gorm:"type:integer;not null" json:"app_install_id"`
AppDetail AppDetail `json:"-"` AppDetail AppDetail `json:"-" gorm:"-:migration"`
} }

View File

@ -19,8 +19,8 @@ type Website struct {
ErrorLog bool `json:"errorLog"` ErrorLog bool `json:"errorLog"`
AccessLog bool `json:"accessLog"` AccessLog bool `json:"accessLog"`
DefaultServer bool `json:"defaultServer"` DefaultServer bool `json:"defaultServer"`
Domains []WebsiteDomain `json:"domains"` Domains []WebsiteDomain `json:"domains" gorm:"-:migration"`
WebsiteSSL WebsiteSSL `json:"webSiteSSL"` WebsiteSSL WebsiteSSL `json:"webSiteSSL" gorm:"-:migration"`
} }
func (w Website) TableName() string { func (w Website) TableName() string {

View File

@ -18,8 +18,8 @@ type WebsiteSSL struct {
ExpireDate time.Time `json:"expireDate"` ExpireDate time.Time `json:"expireDate"`
StartDate time.Time `json:"startDate"` StartDate time.Time `json:"startDate"`
AcmeAccount WebsiteAcmeAccount `json:"acmeAccount"` AcmeAccount WebsiteAcmeAccount `json:"acmeAccount" gorm:"-:migration"`
Websites []Website `json:"websites"` Websites []Website `json:"websites" gorm:"-:migration"`
} }
func (w WebsiteSSL) TableName() string { func (w WebsiteSSL) TableName() string {

View File

@ -356,7 +356,9 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
versionRes, err := http.Get(fmt.Sprintf("%s/%s/%s/appstore/apps.json", global.CONF.System.RepoUrl, global.CONF.System.Mode, setting.SystemVersion)) versionUrl := fmt.Sprintf("%s/%s/%s/appstore/apps.json", global.CONF.System.RepoUrl, global.CONF.System.Mode, setting.SystemVersion)
versionRes, err := http.Get(versionUrl)
global.LOG.Infof("get current version from [%s]", versionUrl)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -384,6 +386,7 @@ func (a AppService) SyncAppList() error {
return err return err
} }
if !updateRes.CanUpdate { if !updateRes.CanUpdate {
global.LOG.Infof("The latest version is [%s] The app store is already up to date", updateRes.Version)
return nil return nil
} }
if err := getAppFromRepo(updateRes.DownloadPath, updateRes.Version); err != nil { if err := getAppFromRepo(updateRes.DownloadPath, updateRes.Version); err != nil {

View File

@ -143,7 +143,7 @@ func (w WebsiteService) CreateWebsite(ctx context.Context, create request.Websit
return err return err
} }
appInstall = &install appInstall = &install
website.AppInstallID = 0 website.AppInstallID = appInstall.ID
} }
} }

View File

@ -21,7 +21,9 @@ func Init() {
panic(fmt.Errorf("init db file falied, err: %v", err)) panic(fmt.Errorf("init db file falied, err: %v", err))
} }
} }
db, err := gorm.Open(sqlite.Open(fullPath), &gorm.Config{}) db, err := gorm.Open(sqlite.Open(fullPath), &gorm.Config{
DisableForeignKeyConstraintWhenMigrating: true,
})
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -8,32 +8,27 @@ import (
func Up(filePath string) (string, error) { func Up(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s up -d", filePath) stdout, err := cmd.Execf("docker-compose -f %s up -d", filePath)
return string(stdout), err return stdout, err
} }
func Down(filePath string) (string, error) { func Down(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s down", filePath) stdout, err := cmd.Execf("docker-compose -f %s down", filePath)
return string(stdout), err return stdout, err
} }
func Stop(filePath string) (string, error) { func Stop(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s stop", filePath) stdout, err := cmd.Execf("docker-compose -f %s stop", filePath)
return string(stdout), err return stdout, err
} }
func Restart(filePath string) (string, error) { func Restart(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s restart", filePath) stdout, err := cmd.Execf("docker-compose -f %s restart", filePath)
return string(stdout), err return stdout, err
} }
func Operate(filePath, operation string) (string, error) { func Operate(filePath, operation string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s %s", filePath, operation) stdout, err := cmd.Execf("docker-compose -f %s %s", filePath, operation)
return string(stdout), err return stdout, err
}
func Rmf(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s rm -f", filePath)
return string(stdout), err
} }
func GetComposeProject(yml []byte, env map[string]string) (*types.Project, error) { func GetComposeProject(yml []byte, env map[string]string) (*types.Project, error) {

View File

@ -1,4 +0,0 @@
@font-face {
font-family: 'pingFangSC-Regular';
src: url('./PingFang-SC-Regular.ttf');
}

View File

@ -1,12 +1,8 @@
import { createApp } from 'vue'; import { createApp } from 'vue';
import App from './App.vue'; import App from './App.vue';
// import 'element-plus/dist/index.css';
// import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/styles/index.scss'; import '@/styles/index.scss';
// import '@/styles/reset.scss';
import '@/styles/common.scss'; import '@/styles/common.scss';
import '@/assets/fonts/font.scss';
import '@/assets/iconfont/iconfont.css'; import '@/assets/iconfont/iconfont.css';
import '@/assets/iconfont/iconfont.js'; import '@/assets/iconfont/iconfont.js';

View File

@ -4,44 +4,44 @@
<el-row type="flex" style="margin-left: 50px" justify="center"> <el-row type="flex" style="margin-left: 50px" justify="center">
<el-form-item style="width: 25%"> <el-form-item style="width: 25%">
<template #label> <template #label>
<span class="status-label">{{ $t('database.connections') }}</span> <span class="status-label">{{ $t('nginx.connections') }}</span>
</template> </template>
<span class="status-count">{{ data.active }}</span> <span class="status-count">{{ data.active }}</span>
</el-form-item> </el-form-item>
<el-form-item style="width: 25%"> <el-form-item style="width: 25%">
<template #label> <template #label>
<span class="status-label">{{ $t('database.accepts') }}</span> <span class="status-label">{{ $t('nginx.accepts') }}</span>
</template> </template>
<span class="status-count">{{ data.accepts }}</span> <span class="status-count">{{ data.accepts }}</span>
</el-form-item> </el-form-item>
<el-form-item style="width: 25%"> <el-form-item style="width: 25%">
<template #label> <template #label>
<span class="status-label">{{ $t('database.handled') }}</span> <span class="status-label">{{ $t('nginx.handled') }}</span>
</template> </template>
<span class="status-count">{{ data.handled }}</span> <span class="status-count">{{ data.handled }}</span>
</el-form-item> </el-form-item>
<el-form-item style="width: 25%"> <el-form-item style="width: 25%">
<template #label> <template #label>
<span class="status-label">{{ $t('database.requests') }}</span> <span class="status-label">{{ $t('nginx.requests') }}</span>
</template> </template>
<span class="status-count">{{ data.requests }}</span> <span class="status-count">{{ data.requests }}</span>
</el-form-item> </el-form-item>
<el-form-item style="width: 25%"> <el-form-item style="width: 25%">
<template #label> <template #label>
<span class="status-label">{{ $t('database.reading') }}</span> <span class="status-label">{{ $t('nginx.reading') }}</span>
</template> </template>
<span class="status-count">{{ data.reading }}</span> <span class="status-count">{{ data.reading }}</span>
</el-form-item> </el-form-item>
<el-form-item style="width: 25%"> <el-form-item style="width: 25%">
<template #label> <template #label>
<span class="status-label">{{ $t('database.writing') }}</span> <span class="status-label">{{ $t('nginx.writing') }}</span>
</template> </template>
<span class="status-count">{{ data.writing }}</span> <span class="status-count">{{ data.writing }}</span>
</el-form-item> </el-form-item>
<el-form-item style="width: 25%"> <el-form-item style="width: 25%">
<template #label> <template #label>
<span class="status-label">{{ $t('database.waiting') }}</span> <span class="status-label">{{ $t('nginx.waiting') }}</span>
</template> </template>
<span class="status-count">{{ data.waiting }}</span> <span class="status-count">{{ data.waiting }}</span>
</el-form-item> </el-form-item>