mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/1Panel-dev/1Panel.git
synced 2026-09-20 08:03:55 +08:00
feat: Add default external port access to application settings. (#12426)
This commit is contained in:
@@ -238,13 +238,14 @@ type TerminalInfo struct {
|
||||
}
|
||||
|
||||
type AppstoreUpdate struct {
|
||||
Scope string `json:"scope" validate:"required,oneof=UninstallDeleteImage UpgradeBackup UninstallDeleteBackup"`
|
||||
Scope string `json:"scope" validate:"required,oneof=UninstallDeleteImage UpgradeBackup UninstallDeleteBackup InstallAllowPort"`
|
||||
Status string `json:"status" validate:"required,oneof=Disable Enable"`
|
||||
}
|
||||
type AppstoreConfig struct {
|
||||
UninstallDeleteImage string `json:"uninstallDeleteImage"`
|
||||
UpgradeBackup string `json:"upgradeBackup"`
|
||||
UninstallDeleteBackup string `json:"uninstallDeleteBackup"`
|
||||
InstallAllowPort string `json:"installAllowPort"`
|
||||
}
|
||||
|
||||
type LoginSetting struct {
|
||||
|
||||
@@ -719,15 +719,19 @@ func (u *SettingService) GetAppstoreConfig() (*dto.AppstoreConfig, error) {
|
||||
res := &dto.AppstoreConfig{}
|
||||
res.UninstallDeleteImage, _ = settingRepo.GetValueByKey("UninstallDeleteImage")
|
||||
if res.UninstallDeleteImage == "" {
|
||||
res.UninstallDeleteImage = "False"
|
||||
res.UninstallDeleteImage = constant.StatusDisable
|
||||
}
|
||||
res.UpgradeBackup, _ = settingRepo.GetValueByKey("UpgradeBackup")
|
||||
if res.UpgradeBackup == "" {
|
||||
res.UpgradeBackup = "False"
|
||||
res.UpgradeBackup = constant.StatusDisable
|
||||
}
|
||||
res.UninstallDeleteBackup, _ = settingRepo.GetValueByKey("UninstallDeleteBackup")
|
||||
if res.UninstallDeleteBackup == "" {
|
||||
res.UninstallDeleteBackup = "False"
|
||||
res.UninstallDeleteBackup = constant.StatusDisable
|
||||
}
|
||||
res.InstallAllowPort, _ = settingRepo.GetValueByKey("InstallAllowPort")
|
||||
if res.InstallAllowPort == "" {
|
||||
res.InstallAllowPort = constant.StatusDisable
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,7 @@ func Init() {
|
||||
migrations.UpdateAiAgentsHideMenuTitle,
|
||||
migrations.UpdateAiModelMenuStructure,
|
||||
migrations.AddDocSourceSetting,
|
||||
migrations.AddAppStoreInstallAllowPortSetting,
|
||||
})
|
||||
if err := m.Migrate(); err != nil {
|
||||
global.LOG.Error(err)
|
||||
|
||||
@@ -193,6 +193,9 @@ var InitSetting = &gormigrate.Migration{
|
||||
if err := tx.Create(&model.Setting{Key: "UninstallDeleteBackup", Value: constant.StatusDisable}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Create(&model.Setting{Key: "InstallAllowPort", Value: constant.StatusDisable}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -854,6 +857,23 @@ var AddDocSourceSetting = &gormigrate.Migration{
|
||||
},
|
||||
}
|
||||
|
||||
var AddAppStoreInstallAllowPortSetting = &gormigrate.Migration{
|
||||
ID: "20260407-add-app-store-install-allow-port-setting",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
var setting model.Setting
|
||||
if err := tx.Where("key = ?", "InstallAllowPort").First(&setting).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return tx.Create(&model.Setting{Key: "InstallAllowPort", Value: constant.StatusDisable}).Error
|
||||
}
|
||||
return err
|
||||
}
|
||||
if setting.Value == "" {
|
||||
return tx.Model(&model.Setting{}).Where("key = ?", "InstallAllowPort").Update("value", constant.StatusDisable).Error
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var UpdateAiLocalModelMenuTitle = &gormigrate.Migration{
|
||||
ID: "20260307-update-ai-local-model-menu-title",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
|
||||
@@ -344,6 +344,7 @@ export namespace App {
|
||||
uninstallDeleteImage: string;
|
||||
uninstallDeleteBackup: string;
|
||||
upgradeBackup: string;
|
||||
installAllowPort: string;
|
||||
}
|
||||
|
||||
export interface AppStoreConfigUpdate {
|
||||
|
||||
@@ -2665,6 +2665,7 @@ const message = {
|
||||
uninstallDeleteBackup: 'Uninstall App - Delete Backup',
|
||||
uninstallDeleteImage: 'Uninstall App - Delete Image',
|
||||
upgradeBackup: 'Backup App Before Upgrade',
|
||||
installAllowPort: 'Open external port access by default when installing apps',
|
||||
noAppHelper: 'No application detected, go to the task center to view the app store sync log',
|
||||
isEdirWarn: 'Detected modification to docker-compose.yml file, please check the comparison',
|
||||
},
|
||||
|
||||
@@ -2645,6 +2645,7 @@ const message = {
|
||||
uninstallDeleteBackup: 'Desinstalar - Eliminar respaldo',
|
||||
uninstallDeleteImage: 'Desinstalar - Eliminar imagen',
|
||||
upgradeBackup: 'Respaldar app antes de actualizar',
|
||||
installAllowPort: 'Abrir el acceso externo al puerto por defecto al instalar apps',
|
||||
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',
|
||||
|
||||
@@ -2617,6 +2617,7 @@ const message = {
|
||||
uninstallDeleteBackup: 'アプリをアンインストール - バックアップを削除',
|
||||
uninstallDeleteImage: 'アプリをアンインストール - イメージを削除',
|
||||
upgradeBackup: 'アプリのアップグレード前にアプリをバックアップ',
|
||||
installAllowPort: 'アプリインストール時に外部アクセスを既定で有効化',
|
||||
noAppHelper: 'アプリケーションが検出されませんでした。タスクセンターでアプリストアの同期ログを確認してください',
|
||||
isEdirWarn: 'docker-compose.yml ファイルが変更されたことを検出しました。比較を確認してください',
|
||||
},
|
||||
|
||||
@@ -2551,6 +2551,7 @@ const message = {
|
||||
uninstallDeleteBackup: '앱 제거 - 백업 삭제',
|
||||
uninstallDeleteImage: '앱 제거 - 이미지 삭제',
|
||||
upgradeBackup: '앱 업그레이드 전 앱 백업',
|
||||
installAllowPort: '앱 설치 시 기본으로 외부 포트 접근 허용',
|
||||
noAppHelper: '애플리케이션이 감지되지 않았습니다. 작업 센터에서 앱 스토어 동기화 로그를 확인해 주세요',
|
||||
isEdirWarn: 'docker-compose.yml 파일이 수정된 것을 감지했습니다. 비교를 확인해 주세요',
|
||||
},
|
||||
|
||||
@@ -2647,6 +2647,7 @@ const message = {
|
||||
uninstallDeleteBackup: 'Cop Terhapus Semasa Nyahpasang Aplikasi',
|
||||
uninstallDeleteImage: 'Imej Terhapus Semasa Nyahpasang Aplikasi',
|
||||
upgradeBackup: 'Sandaran Aplikasi Sebelum Naik Taraf',
|
||||
installAllowPort: 'Buka akses port luaran secara lalai semasa memasang aplikasi',
|
||||
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',
|
||||
},
|
||||
|
||||
@@ -2784,6 +2784,7 @@ const message = {
|
||||
uninstallDeleteBackup: 'Desinstalar Aplicativo - Excluir Backup',
|
||||
uninstallDeleteImage: 'Desinstalar Aplicativo - Excluir Imagem',
|
||||
upgradeBackup: 'Fazer Backup do Aplicativo Antes de Atualizar',
|
||||
installAllowPort: 'Abrir acesso externo à porta por padrão ao instalar aplicativos',
|
||||
noAppHelper:
|
||||
'Nenhuma aplicação detectada, por favor vá 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',
|
||||
|
||||
@@ -2645,6 +2645,7 @@ const message = {
|
||||
uninstallDeleteBackup: 'Деинсталляция приложения - Удаление резервной копии',
|
||||
uninstallDeleteImage: 'Деинсталляция приложения - Удаление образа',
|
||||
upgradeBackup: 'Резервное копирование приложения перед обновлением',
|
||||
installAllowPort: 'По умолчанию открывать внешний доступ к порту при установке приложения',
|
||||
noAppHelper:
|
||||
'Приложения не обнаружены, пожалуйста, перейдите в центр задач для просмотра журнала синхронизации магазина приложений',
|
||||
isEdirWarn: 'Обнаружено изменение файла docker-compose.yml, пожалуйста, проверьте сравнение',
|
||||
|
||||
@@ -2647,6 +2647,7 @@ const message = {
|
||||
uninstallDeleteBackup: 'Uygulamayı Kaldır - Yedeği Sil',
|
||||
uninstallDeleteImage: 'Uygulamayı Kaldır - Görüntüyü Sil',
|
||||
upgradeBackup: 'Yükseltmeden Önce Uygulamayı Yedekle',
|
||||
installAllowPort: 'Uygulama kurulurken varsayılan olarak dış port erişimini aç',
|
||||
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',
|
||||
|
||||
@@ -2397,6 +2397,7 @@ const message = {
|
||||
uninstallDeleteBackup: '移除應用-刪除備份',
|
||||
uninstallDeleteImage: '移除應用-刪除映像',
|
||||
upgradeBackup: '應用升級前備份應用',
|
||||
installAllowPort: '安裝應用預設開啟埠外部存取',
|
||||
noAppHelper: '未偵測到應用程式,請前往任務中心檢視應用商店同步日誌',
|
||||
isEdirWarn: '偵測到 docker-compose.yml 檔案被修改,請檢視對比',
|
||||
},
|
||||
|
||||
@@ -2463,6 +2463,7 @@ const message = {
|
||||
uninstallDeleteBackup: '卸载应用-删除备份',
|
||||
uninstallDeleteImage: '卸载应用-删除镜像',
|
||||
upgradeBackup: '应用升级前备份应用',
|
||||
installAllowPort: '安装应用默认打开端口外部访问',
|
||||
noAppHelper: '未检测到应用,请前往任务中心查看应用商店同步日志',
|
||||
isEdirWarn: '检测到 docker-compose.yml 文件被修改,请查看对比',
|
||||
},
|
||||
|
||||
@@ -147,6 +147,7 @@
|
||||
<script lang="ts" setup name="AppInstallForm">
|
||||
import { App } from '@/api/interface/app';
|
||||
import { getAppByKey, getAppDetail, getAppInstalledByID } from '@/api/modules/app';
|
||||
import { getAppStoreConfig } from '@/api/modules/setting';
|
||||
import { Rules, checkNumberRange } from '@/global/form-rules';
|
||||
import { FormInstance, FormRules } from 'element-plus';
|
||||
import { ref, watch } from 'vue';
|
||||
@@ -298,8 +299,21 @@ const getVersionDetail = async (version: string) => {
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const loadInstallDefaultConfig = async () => {
|
||||
try {
|
||||
const res = await getAppStoreConfig(operateNode.value);
|
||||
formData.value.allowPort = res.data.installAllowPort === 'Enable';
|
||||
} catch (error) {
|
||||
formData.value.allowPort = false;
|
||||
}
|
||||
};
|
||||
|
||||
const initForm = async (appKey: string) => {
|
||||
operateNode.value = undefined;
|
||||
env.value = undefined;
|
||||
masterNodeAddr.value = undefined;
|
||||
formData.value.name = appKey.replace(/^local/, '');
|
||||
await loadInstallDefaultConfig();
|
||||
const res = await getAppByKey(appKey);
|
||||
currentApp.value = res.data;
|
||||
appVersions.value = currentApp.value.versions;
|
||||
@@ -353,6 +367,7 @@ const initClusterForm = async (props: ClusterProps) => {
|
||||
}
|
||||
masterNodeAddr.value = props.masterNodeAddr;
|
||||
operateNode.value = props.node;
|
||||
await loadInstallDefaultConfig();
|
||||
const res = await getAppByKey(props.key, props.node);
|
||||
currentApp.value = res.data;
|
||||
appVersions.value = currentApp.value.versions;
|
||||
|
||||
@@ -39,6 +39,15 @@
|
||||
@change="updateConfig('UpgradeBackup', config.upgradeBackup)"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('app.installAllowPort')" prop="installAllowPort">
|
||||
<el-switch
|
||||
v-model="config.installAllowPort"
|
||||
active-value="Enable"
|
||||
inactive-value="Disable"
|
||||
:loading="loading"
|
||||
@change="updateConfig('InstallAllowPort', config.installAllowPort)"
|
||||
/>
|
||||
</el-form-item>
|
||||
<CustomSetting v-if="isProductPro" />
|
||||
<span class="input-help logText" v-else>
|
||||
{{ $t('xpack.customApp.licenseHelper') }}
|
||||
@@ -78,6 +87,7 @@ const config = ref({
|
||||
uninstallDeleteImage: '',
|
||||
uninstallDeleteBackup: '',
|
||||
upgradeBackup: '',
|
||||
installAllowPort: '',
|
||||
});
|
||||
const loading = ref(false);
|
||||
const configForm = ref();
|
||||
|
||||
Reference in New Issue
Block a user