feat: Add a check during upgrade to detect whether the Compose file has been modified. (#10863)

This commit is contained in:
CityFun 2025-11-04 22:53:33 +08:00 committed by GitHub
parent a7d4c4ebec
commit 62f59eb1c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 50 additions and 17 deletions

View file

@ -128,6 +128,7 @@ type AppInstallDTO struct {
Favorite bool `json:"favorite"`
App AppDetail `json:"app"`
Container string `json:"container"`
IsEdit bool `json:"isEdit"`
}
type AppInstallInfo struct {

View file

@ -1568,7 +1568,12 @@ func handleInstalled(appInstallList []model.AppInstall, updated bool, sync bool)
Container: installed.ContainerName,
}
if updated {
detail, _ := appDetailRepo.GetFirst(repo.WithByID(installed.AppDetailId))
installDTO.DockerCompose = installed.DockerCompose
rawCompose, _ := getUpgradeCompose(installed, detail)
if rawCompose != installed.DockerCompose {
installDTO.IsEdit = true
}
}
app, err := appRepo.GetFirst(repo.WithByID(installed.AppId))
if err != nil {

View file

@ -184,6 +184,9 @@ export namespace App {
appKey: string;
appType: string;
appStatus: string;
isEdit: boolean;
dockerCompose: string;
app: App.AppDetail;
}
export interface AppInstalledInfo {

View file

@ -2302,6 +2302,8 @@ const message = {
uninstallDeleteBackup: 'Uninstall App - Delete Backup',
uninstallDeleteImage: 'Uninstall App - Delete Image',
upgradeBackup: 'Backup App Before Upgrade',
noAppHelper: 'No application detected, please go to the task center to view the app store sync log',
isEdirWarn: 'Detected modification to docker-compose.yml file, please check the comparison',
},
website: {
primaryDomain: 'Primary domain',

View file

@ -2297,6 +2297,9 @@ const message = {
uninstallDeleteBackup: 'Desinstalar - Eliminar respaldo',
uninstallDeleteImage: 'Desinstalar - Eliminar imagen',
upgradeBackup: 'Respaldar app antes de actualizar',
noAppHelper:
'No se detectó ninguna aplicación, por favor vaya al centro de tareas para ver el registro de sincronización de la tienda de aplicaciones',
isEdirWarn: 'Se detectó modificación en el archivo docker-compose.yml, por favor revise la comparación',
},
website: {
primaryDomain: 'Dominio principal',

View file

@ -2218,6 +2218,8 @@ const message = {
uninstallDeleteBackup: 'アプリをアンインストール - バックアップを削除',
uninstallDeleteImage: 'アプリをアンインストール - イメージを削除',
upgradeBackup: 'アプリのアップグレード前にアプリをバックアップ',
noAppHelper: 'アプリケーションが検出されませんでしたタスクセンターでアプリストアの同期ログを確認してください',
isEdirWarn: 'docker-compose.yml ファイルが変更されたことを検出しました比較を確認してください',
},
website: {
primaryDomain: 'プライマリドメイン',

View file

@ -2181,6 +2181,8 @@ const message = {
uninstallDeleteBackup: ' 제거 - 백업 삭제',
uninstallDeleteImage: ' 제거 - 이미지 삭제',
upgradeBackup: ' 업그레이드 백업',
noAppHelper: '애플리케이션이 감지되지 않았습니다. 작업 센터에서 스토어 동기화 로그를 확인해 주세요',
isEdirWarn: 'docker-compose.yml 파일이 수정된 것을 감지했습니다. 비교를 확인해 주세요',
},
website: {
primaryDomain: '기본 도메인',

View file

@ -2277,6 +2277,8 @@ const message = {
uninstallDeleteBackup: 'Cop Terhapus Semasa Nyahpasang Aplikasi',
uninstallDeleteImage: 'Imej Terhapus Semasa Nyahpasang Aplikasi',
upgradeBackup: 'Sandaran Aplikasi Sebelum Naik Taraf',
noAppHelper: 'Tiada aplikasi dikesan, sila pergi ke pusat tugas untuk melihat log penyegerakan kedai aplikasi',
isEdirWarn: 'Mengesan pengubahsuaian pada fail docker-compose.yml, sila semak perbandingan',
},
website: {
primaryDomain: 'Domain Utama',

View file

@ -2276,6 +2276,9 @@ const message = {
uninstallDeleteBackup: 'Desinstalar Aplicativo - Excluir Backup',
uninstallDeleteImage: 'Desinstalar Aplicativo - Excluir Imagem',
upgradeBackup: 'Fazer Backup do Aplicativo Antes de Atualizar',
noAppHelper:
'Nenhuma aplicação detectada, por favor ao centro de tarefas para visualizar o log de sincronização da loja de aplicativos',
isEdirWarn: 'Detectada modificação no arquivo docker-compose.yml, por favor verifique a comparação',
},
website: {
primaryDomain: 'Domínio principal',

View file

@ -2274,6 +2274,9 @@ const message = {
uninstallDeleteBackup: 'Деинсталляция приложения - Удаление резервной копии',
uninstallDeleteImage: 'Деинсталляция приложения - Удаление образа',
upgradeBackup: 'Резервное копирование приложения перед обновлением',
noAppHelper:
'Приложения не обнаружены, пожалуйста, перейдите в центр задач для просмотра журнала синхронизации магазина приложений',
isEdirWarn: 'Обнаружено изменение файла docker-compose.yml, пожалуйста, проверьте сравнение',
},
website: {
primaryDomain: 'Основной домен',

View file

@ -2332,6 +2332,9 @@ const message = {
uninstallDeleteBackup: 'Uygulamayı Kaldır - Yedeği Sil',
uninstallDeleteImage: 'Uygulamayı Kaldır - Görüntüyü Sil',
upgradeBackup: 'Yükseltmeden Önce Uygulamayı Yedekle',
noAppHelper:
'Uygulama tespit edilmedi, lütfen uygulama mağazası senkronizasyon günlüğünü görüntülemek için görev merkezine gidin',
isEdirWarn: 'docker-compose.yml dosyasında değişiklik tespit edildi, lütfen karşılaştırmayı kontrol edin',
},
website: {
primaryDomain: 'Birincil alan adı',

View file

@ -2137,6 +2137,8 @@ const message = {
uninstallDeleteBackup: '移除應用-刪除備份',
uninstallDeleteImage: '移除應用-刪除鏡像',
upgradeBackup: '應用升級前備份應用',
noAppHelper: '未檢測到應用程式請前往任務中心查看應用商店同步日誌',
isEdirWarn: '檢測到 docker-compose.yml 檔案被修改請查看對比',
},
website: {
primaryDomain: '主域名',

View file

@ -2130,6 +2130,7 @@ const message = {
uninstallDeleteImage: '卸载应用-删除镜像',
upgradeBackup: '应用升级前备份应用',
noAppHelper: '未检测到应用请前往任务中心查看应用商店同步日志',
isEdirWarn: '检测到 docker-compose.yml 文件被修改请查看对比',
},
website: {
primaryDomain: '主域名',

View file

@ -550,7 +550,7 @@ const openOperate = (row: any, op: string) => {
operateReq.installId = row.id;
operateReq.operate = op;
if (op == 'upgrade') {
upgradeRef.value.acceptParams(row.id, row.name, row.dockerCompose, op, row.app);
upgradeRef.value.acceptParams(row, op);
} else if (op == 'delete') {
appInstalledDeleteCheck(row.id).then(async (res) => {
const items = res.data;

View file

@ -53,20 +53,19 @@
<span class="input-help">{{ $t('app.pullImageHelper') }}</span>
</el-form-item>
</el-form>
<div v-if="operateReq.operate === 'upgrade'">
<el-text type="warning">{{ $t('app.upgradeWarn') }}</el-text>
<br />
<el-button @click="openDiff()" type="primary" class="mt-2">
{{ $t('app.showDiff') }}
</el-button>
<el-text type="danger" v-if="isEdit">{{ $t('app.isEdirWarn') }}</el-text>
<el-text type="warning" v-else>{{ $t('app.upgradeWarn') }}</el-text>
<div>
<el-checkbox v-model="useNewCompose" :label="$t('app.useCustom')" size="large" />
<el-button @click="openDiff()" :type="isEdit ? 'warning' : 'primary'">
{{ $t('app.showDiff') }}
</el-button>
</div>
<el-checkbox v-model="useNewCompose" :label="$t('app.useCustom')" size="large" />
<div v-if="useNewCompose">
<el-text type="danger">{{ $t('app.useCustomHelper') }}</el-text>
<el-text type="danger" v-if="!isEdit">{{ $t('app.useCustomHelper') }}</el-text>
<CodemirrorPro v-model="newCompose" mode="yaml"></CodemirrorPro>
</div>
<CodemirrorPro v-if="useNewCompose" v-model="newCompose" mode="yaml"></CodemirrorPro>
</div>
</div>
<template #footer>
@ -131,6 +130,7 @@ const ignoreAppReq = reactive({
appDetailID: 0,
scope: 'app',
});
const isEdit = ref(false);
const toLink = (link: string) => {
window.open(link, '_blank');
@ -162,16 +162,17 @@ const initData = async () => {
operateReq.dockerCompose = '';
};
const acceptParams = (id: number, name: string, dockerCompose: string, op: string, appDetail: App.AppDetail) => {
const acceptParams = (appInstall: App.AppInstallDto, op: string) => {
initData();
operateReq.installId = id;
isEdit.value = appInstall.isEdit;
operateReq.installId = appInstall.id;
operateReq.operate = op;
resourceName.value = name;
app.value = appDetail;
oldContent.value = dockerCompose;
appInstallID.value = id;
resourceName.value = appInstall.name;
app.value = appInstall.app;
oldContent.value = appInstall.dockerCompose;
appInstallID.value = appInstall.id;
getVersions('');
ignoreAppReq.appID = appDetail.appId;
ignoreAppReq.appID = appInstall.app.id;
if (op === 'ignore') {
operateReq.detailId = -1;
}