diff --git a/backend/app/api/v1/app.go b/backend/app/api/v1/app.go index 850dfaf0c..4e2d1ffe2 100644 --- a/backend/app/api/v1/app.go +++ b/backend/app/api/v1/app.go @@ -128,3 +128,18 @@ func (b *BaseApi) GetAppTags(c *gin.Context) { } helper.SuccessWithData(c, tags) } + +// @Tags App +// @Summary Get app list update +// @Description 获取应用更新版本 +// @Success 200 +// @Security ApiKeyAuth +// @Router /apps/checkupdate [get] +func (b *BaseApi) GetAppListUpdate(c *gin.Context) { + res, err := appService.GetAppUpdate() + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, res) +} diff --git a/backend/app/service/app.go b/backend/app/service/app.go index 4c08a1a64..1d5e52ef8 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -34,6 +34,7 @@ type IAppService interface { GetAppDetail(appId uint, version string) (response.AppDetailDTO, error) Install(ctx context.Context, req request.AppInstallCreate) (*model.AppInstall, error) SyncAppList() error + GetAppUpdate() (*response.AppUpdateRes, error) } func NewIAppService() IAppService { diff --git a/backend/router/ro_app.go b/backend/router/ro_app.go index fa87527c9..1278e341a 100644 --- a/backend/router/ro_app.go +++ b/backend/router/ro_app.go @@ -16,6 +16,7 @@ func (a *AppRouter) InitAppRouter(Router *gin.RouterGroup) { baseApi := v1.ApiGroupApp.BaseApi { appRouter.POST("/sync", baseApi.SyncApp) + appRouter.POST("/checkupdate", baseApi.GetAppListUpdate) appRouter.POST("/search", baseApi.SearchApp) appRouter.GET("/:key", baseApi.GetApp) appRouter.GET("/detail/:appId/:version", baseApi.GetAppDetail) diff --git a/frontend/src/api/interface/app.ts b/frontend/src/api/interface/app.ts index 925e81473..87d731c9c 100644 --- a/frontend/src/api/interface/app.ts +++ b/frontend/src/api/interface/app.ts @@ -27,6 +27,11 @@ export namespace App { items: App.App[]; } + export interface AppUpdateRes { + version: string; + canUpdate: boolean; + } + export interface AppDetail extends CommonModel { appId: string; icon: string; diff --git a/frontend/src/api/modules/app.ts b/frontend/src/api/modules/app.ts index bf40e4d4b..3d1a01492 100644 --- a/frontend/src/api/modules/app.ts +++ b/frontend/src/api/modules/app.ts @@ -6,6 +6,10 @@ export const SyncApp = () => { return http.post('apps/sync', {}); }; +export const GetAppListUpdate = () => { + return http.post('apps/checkupdate', {}); +}; + export const SearchApp = (req: App.AppReq) => { return http.post('apps/search', req); }; diff --git a/frontend/src/views/app-store/apps/index.vue b/frontend/src/views/app-store/apps/index.vue index 8221e8385..0b7ce3e7d 100644 --- a/frontend/src/views/app-store/apps/index.vue +++ b/frontend/src/views/app-store/apps/index.vue @@ -95,7 +95,7 @@ import LayoutContent from '@/layout/layout-content.vue'; import { App } from '@/api/interface/app'; import { onMounted, reactive, ref } from 'vue'; -import { GetAppTags, SearchApp, SyncApp } from '@/api/modules/app'; +import { GetAppListUpdate, GetAppTags, SearchApp, SyncApp } from '@/api/modules/app'; import i18n from '@/lang'; import Detail from '../detail/index.vue'; import router from '@/routers'; @@ -147,6 +147,7 @@ const sync = () => { SyncApp() .then(() => { MsgSuccess(i18n.global.t('app.syncSuccess')); + canUpdate.value = false; search(req); }) .finally(() => { @@ -154,6 +155,11 @@ const sync = () => { }); }; +const getAppListUpdate = async () => { + const res = await GetAppListUpdate(); + canUpdate.value = res.data.canUpdate; +}; + const changeTag = (key: string) => { req.tags = []; activeTag.value = key; @@ -169,6 +175,7 @@ const searchByName = (name: string) => { }; onMounted(() => { + getAppListUpdate(); search(req); }); diff --git a/frontend/src/views/website/website/index.vue b/frontend/src/views/website/website/index.vue index 0c14edba9..033d30495 100644 --- a/frontend/src/views/website/website/index.vue +++ b/frontend/src/views/website/website/index.vue @@ -75,17 +75,6 @@ >