mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
feat(website): Fix Issue with Creating Reverse Proxy Website (#7633)
This commit is contained in:
parent
6122aa3a3d
commit
8e4b162b59
@ -32,6 +32,7 @@ type IAppRepo interface {
|
|||||||
Save(ctx context.Context, app *model.App) error
|
Save(ctx context.Context, app *model.App) error
|
||||||
BatchDelete(ctx context.Context, apps []model.App) error
|
BatchDelete(ctx context.Context, apps []model.App) error
|
||||||
DeleteByIDs(ctx context.Context, ids []uint) error
|
DeleteByIDs(ctx context.Context, ids []uint) error
|
||||||
|
DeleteBy(opts ...DBOption) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIAppRepo() IAppRepo {
|
func NewIAppRepo() IAppRepo {
|
||||||
@ -79,7 +80,7 @@ func (a AppRepo) WithResource(resource string) DBOption {
|
|||||||
|
|
||||||
func (a AppRepo) WithNotLocal() DBOption {
|
func (a AppRepo) WithNotLocal() DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("resource != local")
|
return g.Where("resource != 'local'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,3 +150,7 @@ func (a AppRepo) BatchDelete(ctx context.Context, apps []model.App) error {
|
|||||||
func (a AppRepo) DeleteByIDs(ctx context.Context, ids []uint) error {
|
func (a AppRepo) DeleteByIDs(ctx context.Context, ids []uint) error {
|
||||||
return getTx(ctx).Where("id in (?)", ids).Delete(&model.App{}).Error
|
return getTx(ctx).Where("id in (?)", ids).Delete(&model.App{}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a AppRepo) DeleteBy(opts ...DBOption) error {
|
||||||
|
return getDb().Delete(&model.App{}, opts).Error
|
||||||
|
}
|
||||||
|
@ -24,6 +24,12 @@ func WithByIDs(ids []uint) DBOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithByIDNotIn(ids []uint) DBOption {
|
||||||
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
|
return g.Where("id not in (?)", ids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func WithByName(name string) DBOption {
|
func WithByName(name string) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("name = ?", name)
|
return g.Where("name = ?", name)
|
||||||
|
@ -842,6 +842,28 @@ var InitTypes = map[string]struct{}{
|
|||||||
"node": {},
|
"node": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteCustomApp() {
|
||||||
|
var appIDS []uint
|
||||||
|
installs, _ := appInstallRepo.ListBy()
|
||||||
|
for _, install := range installs {
|
||||||
|
appIDS = append(appIDS, install.AppId)
|
||||||
|
}
|
||||||
|
var ops []repo.DBOption
|
||||||
|
ops = append(ops, repo.WithByIDNotIn(appIDS))
|
||||||
|
if len(appIDS) > 0 {
|
||||||
|
ops = append(ops, repo.WithByIDNotIn(appIDS))
|
||||||
|
}
|
||||||
|
apps, _ := appRepo.GetBy(ops...)
|
||||||
|
var deleteIDS []uint
|
||||||
|
for _, app := range apps {
|
||||||
|
if app.Resource == constant.AppResourceCustom {
|
||||||
|
deleteIDS = append(deleteIDS, app.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ = appRepo.DeleteByIDs(context.Background(), deleteIDS)
|
||||||
|
_ = appDetailRepo.DeleteByAppIds(context.Background(), deleteIDS)
|
||||||
|
}
|
||||||
|
|
||||||
func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
|
func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
|
||||||
if xpack.IsUseCustomApp() {
|
if xpack.IsUseCustomApp() {
|
||||||
return nil
|
return nil
|
||||||
@ -891,7 +913,8 @@ func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
|
|||||||
Sort: t.Sort,
|
Sort: t.Sort,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
oldApps, err := appRepo.GetBy(appRepo.WithResource(constant.AppResourceRemote))
|
deleteCustomApp()
|
||||||
|
oldApps, err := appRepo.GetBy(appRepo.WithNotLocal())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1104,6 +1127,7 @@ func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err = syncTask.Execute(); err != nil {
|
if err = syncTask.Execute(); err != nil {
|
||||||
|
_ = NewISettingService().Update("AppStoreLastModified", "0")
|
||||||
_ = NewISettingService().Update("AppStoreSyncStatus", constant.Error)
|
_ = NewISettingService().Update("AppStoreSyncStatus", constant.Error)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -91,11 +91,13 @@ func createIndexFile(website *model.Website, runtime *model.Runtime) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createProxyFile(website *model.Website) error {
|
func createProxyFile(website *model.Website) error {
|
||||||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
//nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
//}
|
||||||
proxyFolder := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.Alias, "proxy")
|
//
|
||||||
|
//proxyFolder := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", website.Alias, "proxy")
|
||||||
|
proxyFolder := GetSitePath(*website, SiteProxyDir)
|
||||||
filePath := path.Join(proxyFolder, "root.conf")
|
filePath := path.Join(proxyFolder, "root.conf")
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
if !fileOp.Stat(proxyFolder) {
|
if !fileOp.Stat(proxyFolder) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-loading="initLog && isLoading">
|
<div v-loading="firstLoading">
|
||||||
<div v-if="defaultButton">
|
<div v-if="defaultButton">
|
||||||
<el-checkbox border v-model="tailLog" class="float-left" @change="changeTail(false)" v-if="showTail">
|
<el-checkbox border v-model="tailLog" class="float-left" @change="changeTail(false)" v-if="showTail">
|
||||||
{{ $t('commons.button.watch') }}
|
{{ $t('commons.button.watch') }}
|
||||||
@ -110,7 +110,6 @@ const maxPage = ref(0);
|
|||||||
const minPage = ref(0);
|
const minPage = ref(0);
|
||||||
let timer: NodeJS.Timer | null = null;
|
let timer: NodeJS.Timer | null = null;
|
||||||
const logPath = ref('');
|
const logPath = ref('');
|
||||||
const initLog = ref(false);
|
|
||||||
|
|
||||||
const firstLoading = ref(false);
|
const firstLoading = ref(false);
|
||||||
const logs = ref<string[]>([]);
|
const logs = ref<string[]>([]);
|
||||||
@ -273,7 +272,6 @@ const onCloseLog = async () => {
|
|||||||
timer = null;
|
timer = null;
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
emit('update:isReading', false);
|
emit('update:isReading', false);
|
||||||
initLog.value = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@ -284,7 +282,6 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
initLog.value = true;
|
|
||||||
if (props.config.tail) {
|
if (props.config.tail) {
|
||||||
tailLog.value = props.config.tail;
|
tailLog.value = props.config.tail;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user