From f9bf6b69fb404ef9bfc1abe085bb4e694323e05b Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:42:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E5=88=A0=E9=99=A4=20openresty=20=E5=8A=9F=E8=83=BD=20(#2030)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/repo/website.go | 5 + backend/app/repo/website_domain.go | 5 + backend/app/service/app_utils.go | 4 + frontend/src/lang/modules/en.ts | 2 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + .../views/app-store/installed/check/index.vue | 95 ++++++++++++++++--- .../src/views/app-store/installed/index.vue | 4 +- 8 files changed, 102 insertions(+), 15 deletions(-) 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 @@ - + {{ $t('app.' + item[0]) }} - + {{ map.get(item[0]).toString() }} + + {{ $t('app.forceDelete') }} + + + + + + + {{ $t('commons.button.cancel') }} + + + {{ $t('commons.button.confirm') }} + + + + + 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); }