feat: 应用商店增加更新提示

This commit is contained in:
zhengkunwang223 2023-02-13 11:46:14 +04:00 committed by zhengkunwang223
parent eefec2560c
commit d1dc8c6a50
4 changed files with 19 additions and 4 deletions

View File

@ -12,7 +12,7 @@ var (
authService = service.ServiceGroupApp.AuthService
dashboardService = service.ServiceGroupApp.DashboardService
appService = service.ServiceGroupApp.AppService
appService = service.NewIAppService()
appInstallService = service.ServiceGroupApp.AppInstallService
containerService = service.ServiceGroupApp.ContainerService

View File

@ -5,6 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"github.com/1Panel-dev/1Panel/backend/buserr"
"github.com/1Panel-dev/1Panel/backend/utils/git"
"os"
"path"
"strings"
@ -103,6 +104,17 @@ func (a AppService) PageApp(req request.AppSearch) (interface{}, error) {
}
res.Tags = tags
setting, err := NewISettingService().GetSettingInfo()
if err != nil {
return nil, err
}
repoInfo, err := git.CheckAndGetInfo(global.CONF.System.AppRepoOwner, global.CONF.System.AppRepoName)
if err != nil {
return nil, err
}
if common.CompareVersion(repoInfo.Version, setting.AppStoreVersion) {
res.CanUpdate = true
}
return res, nil
}

View File

@ -14,8 +14,7 @@ func Init() {
if common.CompareVersion(setting.AppStoreVersion, "0.0") {
return
}
appService := service.AppService{}
if err := appService.SyncAppList(); err != nil {
if err := service.NewIAppService().SyncAppList(); err != nil {
global.LOG.Errorf("sync app error: %s", err.Error())
}
}

View File

@ -40,7 +40,9 @@
</el-row>
</template>
<template #rightButton>
<el-button @click="sync" type="primary" link :plain="true">{{ $t('app.syncAppList') }}</el-button>
<el-badge is-dot class="item" :hidden="!canUpdate">
<el-button @click="sync" type="primary" link :plain="true">{{ $t('app.syncAppList') }}</el-button>
</el-badge>
</template>
<template #main>
<el-row :gutter="5">
@ -113,6 +115,7 @@ let loading = ref(false);
let activeTag = ref('all');
let showDetail = ref(false);
let appId = ref(0);
let canUpdate = ref(false);
const getColor = (index: number) => {
return colorArr[index];
@ -123,6 +126,7 @@ const search = async (req: App.AppReq) => {
await SearchApp(req)
.then((res) => {
apps.value = res.data.items;
canUpdate.value = res.data.canUpdate;
})
.finally(() => {
loading.value = false;