diff --git a/backend/app/repo/website.go b/backend/app/repo/website.go index ef24838ef..d3784cf8e 100644 --- a/backend/app/repo/website.go +++ b/backend/app/repo/website.go @@ -26,6 +26,7 @@ type IWebsiteRepo interface { SaveWithoutCtx(app *model.Website) error DeleteBy(ctx context.Context, opts ...DBOption) error Create(ctx context.Context, app *model.Website) error + DeleteAll(ctx context.Context) error } func NewIWebsiteRepo() IWebsiteRepo { @@ -131,3 +132,7 @@ func (w *WebsiteRepo) SaveWithoutCtx(website *model.Website) error { func (w *WebsiteRepo) DeleteBy(ctx context.Context, opts ...DBOption) error { return getTx(ctx, opts...).Delete(&model.Website{}).Error } + +func (w *WebsiteRepo) DeleteAll(ctx context.Context) error { + return getTx(ctx).Where("1 = 1 ").Delete(&model.Website{}).Error +} diff --git a/backend/app/repo/website_domain.go b/backend/app/repo/website_domain.go index 0b3ad5b63..6624a2108 100644 --- a/backend/app/repo/website_domain.go +++ b/backend/app/repo/website_domain.go @@ -21,6 +21,7 @@ type IWebsiteDomainRepo interface { Create(ctx context.Context, app *model.WebsiteDomain) error Save(ctx context.Context, app *model.WebsiteDomain) error DeleteBy(ctx context.Context, opts ...DBOption) error + DeleteAll(ctx context.Context) error } func NewIWebsiteDomainRepo() IWebsiteDomainRepo { @@ -85,3 +86,7 @@ func (w WebsiteDomainRepo) Save(ctx context.Context, app *model.WebsiteDomain) e func (w WebsiteDomainRepo) DeleteBy(ctx context.Context, opts ...DBOption) error { return getTx(ctx, opts...).Delete(&model.WebsiteDomain{}).Error } + +func (w WebsiteDomainRepo) DeleteAll(ctx context.Context) error { + return getTx(ctx).Where("1 = 1 ").Delete(&model.WebsiteDomain{}).Error +} diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 04dff20a9..14ede64db 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -197,6 +197,10 @@ func deleteAppInstall(install model.AppInstall, deleteBackup bool, forceDelete b if err := deleteLink(ctx, &install, deleteDB, forceDelete); err != nil && !forceDelete { return err } + if install.App.Key == constant.AppOpenresty { + _ = websiteRepo.DeleteAll(ctx) + _ = websiteDomainRepo.DeleteAll(ctx) + } _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("app"), commonRepo.WithByName(install.App.Key), backupRepo.WithByDetailName(install.Name)) _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType(install.App.Key)) if install.App.Key == constant.AppMysql { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 200cbd421..6a4d31ffd 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1238,6 +1238,8 @@ const message = { backupApp: 'Backup application before upgrade', backupAppHelper: 'If the upgrade fails, you can use the application backup to roll back', delete: 'Delete', + openrestyDeleteHelper: + 'Forcibly deleting OpenResty will delete all websites, please confirm the risk before operation', }, website: { website: 'Website', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 71deff2fb..82ba995c6 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1179,6 +1179,7 @@ const message = { backupApp: '升級前備份應用', backupAppHelper: '升級失敗可以使用應用備份回滾', delete: '刪除', + openrestyDeleteHelper: '強制刪除 OpenResty 會刪除所有的網站,請確認風險後操作', }, website: { website: '網站', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 0dc3e03c9..75eca3143 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1179,6 +1179,7 @@ const message = { backupApp: '升级前备份应用', backupAppHelper: '升级失败可以使用应用备份回滚', delete: '删除', + openrestyDeleteHelper: '强制删除 OpenResty 会删除所有的网站,请确认风险之后操作', }, website: { website: '网站', diff --git a/frontend/src/views/app-store/installed/check/index.vue b/frontend/src/views/app-store/installed/check/index.vue index d347ba233..e36cec98f 100644 --- a/frontend/src/views/app-store/installed/check/index.vue +++ b/frontend/src/views/app-store/installed/check/index.vue @@ -1,46 +1,80 @@ + + diff --git a/frontend/src/views/app-store/installed/index.vue b/frontend/src/views/app-store/installed/index.vue index ca0aa2b51..da2b045ea 100644 --- a/frontend/src/views/app-store/installed/index.vue +++ b/frontend/src/views/app-store/installed/index.vue @@ -255,7 +255,7 @@ - + @@ -379,7 +379,7 @@ const openOperate = (row: any, op: string) => { AppInstalledDeleteCheck(row.id).then(async (res) => { const items = res.data; if (res.data && res.data.length > 0) { - checkRef.value.acceptParams({ items: items }); + checkRef.value.acceptParams({ items: items, key: row.app.key, installID: row.id }); } else { deleteRef.value.acceptParams(row); }