feat: Adapt script library for offline mode. (#10436)

This commit is contained in:
CityFun 2025-09-22 18:00:05 +08:00 committed by wanghe-fit2cloud
parent dfaa6e3694
commit 1a963f9dab
4 changed files with 20 additions and 7 deletions

View file

@ -20,6 +20,9 @@ func Init() {
}
func syncApp() {
if global.CONF.Base.IsOffLine {
return
}
_ = service.NewISettingService().Update("AppStoreSyncStatus", constant.StatusSyncSuccess)
if err := service.NewIAppService().SyncAppListFromRemote(""); err != nil {
global.LOG.Errorf("App Store synchronization failed")

View file

@ -168,6 +168,9 @@ func LoadScriptInfo(id uint) (model.ScriptLibrary, error) {
}
func (u *ScriptService) Sync(req dto.OperateByTaskID) error {
if global.CONF.Base.IsOffLine {
return nil
}
syncTask, err := task.NewTaskWithOps(i18n.GetMsgByKey("ScriptLibrary"), task.TaskSync, task.TaskScopeScript, req.TaskID, 0)
if err != nil {
global.LOG.Errorf("create sync task failed %v", err)

View file

@ -19,9 +19,12 @@ func Init() {
global.LOG.Errorf("[core] can not add backup token refresh corn job: %s", err.Error())
}
scriptJob := job.NewScriptJob()
if _, err := global.Cron.AddJob(fmt.Sprintf("%v %v * * *", mathRand.Intn(60), mathRand.Intn(3)), scriptJob); err != nil {
global.LOG.Errorf("[core] can not add script sync corn job: %s", err.Error())
if !global.CONF.Base.IsOffLine {
scriptJob := job.NewScriptJob()
if _, err := global.Cron.AddJob(fmt.Sprintf("%v %v * * *", mathRand.Intn(60), mathRand.Intn(3)), scriptJob); err != nil {
global.LOG.Errorf("[core] can not add script sync corn job: %s", err.Error())
}
}
global.Cron.Start()
}

View file

@ -37,13 +37,17 @@
{{ version }}
</el-link>
<el-badge is-dot class="-mt-0.5" :hidden="version === 'Waiting' || !globalStore.hasNewVersion">
<el-link class="ml-2" underline="never" type="primary" @click="onLoadUpgradeInfo">
<el-link
class="ml-2"
underline="never"
type="primary"
@click="onLoadUpgradeInfo"
v-if="!globalStore.isOffLine"
>
{{ $t('commons.button.update') }}
</el-link>
</el-badge>
<el-tag v-if="version === 'Waiting'" round class="ml-2.5">
{{ $t('setting.upgrading') }}
</el-tag>
<el-tag v-if="version === 'Waiting'" round class="ml-2.5">{{ $t('setting.upgrading') }}</el-tag>
</div>
</div>
</div>