From a987370657a638beb823f838cfef2c314bea8a4b Mon Sep 17 00:00:00 2001 From: CityFun <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 17 Sep 2025 17:49:59 +0800 Subject: [PATCH] feat: Add support for offline version. (#10395) --- agent/global/config.go | 1 + core/app/api/v2/auth.go | 1 + core/app/dto/setting.go | 1 + core/app/service/upgrade.go | 3 +++ core/global/config.go | 1 + core/init/viper/viper.go | 1 + frontend/src/components/system-upgrade/index.vue | 12 ++++++++++-- frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/ja.ts | 1 + frontend/src/lang/modules/ko.ts | 1 + frontend/src/lang/modules/ms.ts | 1 + frontend/src/lang/modules/pt-br.ts | 1 + frontend/src/lang/modules/ru.ts | 1 + frontend/src/lang/modules/tr.ts | 1 + frontend/src/lang/modules/zh-Hant.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + frontend/src/store/interface/index.ts | 11 ++++++----- frontend/src/store/modules/global.ts | 1 + frontend/src/views/app-store/apps/index.vue | 14 +++++++------- frontend/src/views/app-store/detail/form/index.vue | 5 +++++ frontend/src/views/app-store/setting/index.vue | 8 ++++---- frontend/src/views/login/components/login-form.vue | 1 + frontend/src/views/setting/index.vue | 8 ++++++++ 23 files changed, 59 insertions(+), 18 deletions(-) diff --git a/agent/global/config.go b/agent/global/config.go index f2a492510..b2c62b138 100644 --- a/agent/global/config.go +++ b/agent/global/config.go @@ -14,6 +14,7 @@ type Base struct { Mode string `mapstructure:"mode"` // xpack [ Enable / Disable ] IsDemo bool `mapstructure:"is_demo"` InstallDir string `mapstructure:"install_dir"` + IsOffLine bool `mapstructure:"is_offline"` } type RemoteURL struct { diff --git a/core/app/api/v2/auth.go b/core/app/api/v2/auth.go index d1eb03a71..79817cd30 100644 --- a/core/app/api/v2/auth.go +++ b/core/app/api/v2/auth.go @@ -137,6 +137,7 @@ func (b *BaseApi) GetLoginSetting(c *gin.Context) { res := &dto.LoginSetting{ IsDemo: global.CONF.Base.IsDemo, IsIntl: global.CONF.Base.IsIntl, + IsOffLine: global.CONF.Base.IsOffLine, Language: settingInfo.Language, MenuTabs: settingInfo.MenuTabs, PanelName: settingInfo.PanelName, diff --git a/core/app/dto/setting.go b/core/app/dto/setting.go index 3ab501c4b..1afc810e3 100644 --- a/core/app/dto/setting.go +++ b/core/app/dto/setting.go @@ -232,6 +232,7 @@ type AppstoreConfig struct { type LoginSetting struct { IsDemo bool `json:"isDemo"` IsIntl bool `json:"isIntl"` + IsOffLine bool `json:"isOffLine"` Language string `json:"language"` MenuTabs string `json:"menuTabs"` PanelName string `json:"panelName"` diff --git a/core/app/service/upgrade.go b/core/app/service/upgrade.go index 9e03f7450..5505105e5 100644 --- a/core/app/service/upgrade.go +++ b/core/app/service/upgrade.go @@ -38,6 +38,9 @@ func NewIUpgradeService() IUpgradeService { } func (u *UpgradeService) SearchUpgrade() (*dto.UpgradeInfo, error) { + if global.CONF.Base.IsOffLine { + return &dto.UpgradeInfo{}, nil + } var upgrade dto.UpgradeInfo currentVersion, err := settingRepo.Get(repo.WithByKey("SystemVersion")) if err != nil { diff --git a/core/global/config.go b/core/global/config.go index 5b97e506c..9f0ebb8bd 100644 --- a/core/global/config.go +++ b/core/global/config.go @@ -14,6 +14,7 @@ type Base struct { Language string `mapstructure:"language"` IsDemo bool `mapstructure:"is_demo"` IsIntl bool `mapstructure:"is_intl"` + IsOffLine bool `mapstructure:"is_offline"` Version string `mapstructure:"version"` InstallDir string `mapstructure:"install_dir"` ChangeUserInfo string `mapstructure:"change_user_info"` diff --git a/core/init/viper/viper.go b/core/init/viper/viper.go index 99a697b25..ae872f2a7 100644 --- a/core/init/viper/viper.go +++ b/core/init/viper/viper.go @@ -91,6 +91,7 @@ func Init() { global.CONF.Base.InstallDir = baseDir global.CONF.Base.IsDemo = v.GetBool("base.is_demo") global.CONF.Base.IsIntl = v.GetBool("base.is_intl") + global.CONF.Base.IsOffLine = v.GetBool("base.is_offline") global.CONF.Base.Version = version global.CONF.Base.Username = username global.CONF.Base.Password = password diff --git a/frontend/src/components/system-upgrade/index.vue b/frontend/src/components/system-upgrade/index.vue index 3f19e7cad..3219236e6 100644 --- a/frontend/src/components/system-upgrade/index.vue +++ b/frontend/src/components/system-upgrade/index.vue @@ -18,7 +18,15 @@
- {{ $t(!isMasterPro ? 'license.community' : 'license.pro') }} + + {{ $t('license.pro') }} + + + {{ $t('license.offLine') }} + + + {{ $t('license.community') }} + { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 37e540920..95b4699bf 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1994,6 +1994,7 @@ const message = { backupRecoverMessage: 'Please enter the compression or decompression password (leave blank to not set)', }, license: { + offLine: 'Offline', community: 'OSS', oss: 'Open Source Software', pro: 'Pro', diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 2e8ca11e5..c2e5eee0f 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -1911,6 +1911,7 @@ const message = { backupRecoverMessage: '圧縮または減圧パスワードを入力してください(設定しないように空白のままにしてください)', }, license: { + offLine: 'オフライン版', community: '無料', oss: '無料', pro: '専門', diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index 984c54534..cbd7b47d0 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -1882,6 +1882,7 @@ const message = { backupRecoverMessage: '압축 또는 압축 해제 비밀번호를 입력하세요 (설정하지 않으려면 비워 두세요)', }, license: { + offLine: '오프라인 버전', community: 'OSS', oss: '오픈 소스 소프트웨어', pro: 'Pro', diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index 9c60d56f0..1e3355d7b 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -1970,6 +1970,7 @@ const message = { 'Sila masukkan kata laluan mampatan atau nyahmampatan (biarkan kosong jika tidak menetapkan)', }, license: { + offLine: 'Versi Luar Talian', community: 'OSS', oss: 'Perisian Sumber Terbuka', pro: 'Pro', diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index ea32c0ca5..c340598b3 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -1958,6 +1958,7 @@ const message = { 'Por favor, insira a senha de compressão ou descompressão (deixe em branco para não definir)', }, license: { + offLine: 'Versão Offline', community: 'Gratuito', oss: 'Open Source Software', pro: 'Pro', diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index 4277c8788..312005b20 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -1957,6 +1957,7 @@ const message = { 'Пожалуйста, введите пароль для сжатия или распаковки (оставьте пустым, чтобы не устанавливать)', }, license: { + offLine: 'Офлайн версия', community: 'OSS', oss: 'Open Source Software', pro: 'Pro', diff --git a/frontend/src/lang/modules/tr.ts b/frontend/src/lang/modules/tr.ts index ae1a3c6c2..88f8f8155 100644 --- a/frontend/src/lang/modules/tr.ts +++ b/frontend/src/lang/modules/tr.ts @@ -2011,6 +2011,7 @@ const message = { backupRecoverMessage: 'Lütfen sıkıştırma veya sıkıştırma açma parolasını girin (ayarlamamak için boş bırakın)', }, license: { + offLine: 'Çevrimdışı Sürüm', community: 'OSS', oss: 'Açık Kaynak Yazılım', pro: 'Pro', diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts index 3e518cac3..9dd34273d 100644 --- a/frontend/src/lang/modules/zh-Hant.ts +++ b/frontend/src/lang/modules/zh-Hant.ts @@ -1867,6 +1867,7 @@ const message = { backupRecoverMessage: '請輸入壓縮或解壓縮密碼(留空則不設定)', }, license: { + offLine: '離線版', community: '社區版', oss: '社區版', pro: '專業版:', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index d910c6bf5..9cc5ab159 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1860,6 +1860,7 @@ const message = { backupRecoverMessage: '请输入压缩或解压缩密码(留空则不设置)', }, license: { + offLine: '离线版', community: '社区版', oss: '社区版', pro: '专业版', diff --git a/frontend/src/store/interface/index.ts b/frontend/src/store/interface/index.ts index 0d761c2a4..9013fadf2 100644 --- a/frontend/src/store/interface/index.ts +++ b/frontend/src/store/interface/index.ts @@ -18,11 +18,11 @@ export interface ThemeConfigProp { } export interface Watermark { - color: string, - fontSize: number, - content: string, - rotate: number, - gap: number, + color: string; + fontSize: number; + content: string; + rotate: number; + gap: number; } export interface GlobalState { @@ -50,6 +50,7 @@ export interface GlobalState { isIntl: boolean; productProExpires: number; isMasterProductPro: boolean; + isOffLine: boolean; currentNode: string; currentNodeAddr: string; diff --git a/frontend/src/store/modules/global.ts b/frontend/src/store/modules/global.ts index 1d50572e5..fc4f2018d 100644 --- a/frontend/src/store/modules/global.ts +++ b/frontend/src/store/modules/global.ts @@ -45,6 +45,7 @@ const GlobalStore = defineStore({ isIntl: false, productProExpires: 0, isMasterProductPro: false, + isOffLine: false, currentNode: 'local', currentNodeAddr: '', diff --git a/frontend/src/views/app-store/apps/index.vue b/frontend/src/views/app-store/apps/index.vue index 4f4e45c23..9595ad65f 100644 --- a/frontend/src/views/app-store/apps/index.vue +++ b/frontend/src/views/app-store/apps/index.vue @@ -7,7 +7,7 @@