From 5ef011b61913808370f3229c0fd813f479e6d4db Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Fri, 17 Feb 2023 16:21:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BA=94=E7=94=A8=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=8B=B1=E6=96=87=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 +++ backend/app/dto/app.go | 3 ++- backend/app/model/app.go | 3 ++- backend/app/service/app.go | 4 ++-- backend/app/service/app_utils.go | 3 ++- backend/init/business/business.go | 3 +-- cmd/server/main.go | 1 + frontend/src/api/interface/app.ts | 3 ++- frontend/src/views/app-store/apps/index.vue | 9 ++++++--- frontend/src/views/app-store/detail/index.vue | 5 +++-- frontend/src/views/home/app/index.vue | 4 +++- 11 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index ec892815f..c49aac79e 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ GOCLEAN=$(GOCMD) clean GOARCH=amd64 GOOS=linux +GOARCH=$(shell go env GOARCH) +GOOS=$(shell go env GOOS ) + BASE_PAH := $(shell pwd) BUILD_PATH = $(BASE_PAH)/build WEB_PATH=$(BASE_PAH)/frontend diff --git a/backend/app/dto/app.go b/backend/app/dto/app.go index 654243566..fb77ec31d 100644 --- a/backend/app/dto/app.go +++ b/backend/app/dto/app.go @@ -42,7 +42,8 @@ type AppDefine struct { Name string `json:"name"` Tags []string `json:"tags"` Versions []string `json:"versions"` - ShortDesc string `json:"shortDesc"` + ShortDescZh string `json:"shortDescZh"` + ShortDescEn string `json:"shortDescEn"` Type string `json:"type"` Required []string `json:"Required"` CrossVersionUpdate bool `json:"crossVersionUpdate"` diff --git a/backend/app/model/app.go b/backend/app/model/app.go index 4f408b1b8..c892cc7da 100644 --- a/backend/app/model/app.go +++ b/backend/app/model/app.go @@ -4,7 +4,8 @@ type App struct { BaseModel Name string `json:"name" gorm:"type:varchar(64);not null"` Key string `json:"key" gorm:"type:varchar(64);not null;uniqueIndex"` - ShortDesc string `json:"shortDesc" gorm:"type:longtext;"` + ShortDescZh string `json:"shortDescZh" gorm:"type:longtext;"` + ShortDescEn string `json:"shortDescEn" gorm:"type:longtext;"` Icon string `json:"icon" gorm:"type:longtext;"` Type string `json:"type" gorm:"type:varchar(64);not null"` Status string `json:"status" gorm:"type:varchar(64);not null"` diff --git a/backend/app/service/app.go b/backend/app/service/app.go index a4989dc72..f48624933 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -359,12 +359,12 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) { return nil, err } res.Version = list.Version - if common.CompareVersion(list.Version, setting.AppStoreVersion) { + if setting.AppStoreVersion == "" || common.CompareVersion(list.Version, setting.AppStoreVersion) { res.CanUpdate = true res.DownloadPath = fmt.Sprintf("%s/%s/%s/appstore/apps-%s.tar.gz", global.CONF.System.RepoUrl, global.CONF.System.Mode, setting.SystemVersion, list.Version) return res, err } - return nil, err + return res, nil } func (a AppService) SyncAppList() error { diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 213e1e762..4a58d45be 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -474,7 +474,8 @@ func getApps(oldApps []model.App, items []dto.AppDefine) map[string]model.App { app.Name = item.Name app.Limit = item.Limit app.Key = item.Key - app.ShortDesc = item.ShortDesc + app.ShortDescZh = item.ShortDescZh + app.ShortDescEn = item.ShortDescEn app.Website = item.Website app.Document = item.Document app.Github = item.Github diff --git a/backend/init/business/business.go b/backend/init/business/business.go index a25cc6a33..daa87bbe8 100644 --- a/backend/init/business/business.go +++ b/backend/init/business/business.go @@ -3,7 +3,6 @@ package business import ( "github.com/1Panel-dev/1Panel/backend/app/service" "github.com/1Panel-dev/1Panel/backend/global" - "github.com/1Panel-dev/1Panel/backend/utils/common" ) func Init() { @@ -11,7 +10,7 @@ func Init() { if err != nil { global.LOG.Errorf("sync app error: %s", err.Error()) } - if common.CompareVersion(setting.AppStoreVersion, "0.0") { + if setting.AppStoreVersion != "" { return } if err := service.NewIAppService().SyncAppList(); err != nil { diff --git a/cmd/server/main.go b/cmd/server/main.go index 222ef6b54..d0aefa1b5 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -6,6 +6,7 @@ import ( "github.com/1Panel-dev/1Panel/cmd/server/cmd" _ "github.com/1Panel-dev/1Panel/cmd/server/docs" + _ "net/http/pprof" ) // @title 1Panel diff --git a/frontend/src/api/interface/app.ts b/frontend/src/api/interface/app.ts index c5b3527d2..3d6b4cdd4 100644 --- a/frontend/src/api/interface/app.ts +++ b/frontend/src/api/interface/app.ts @@ -6,7 +6,8 @@ export namespace App { icon: string; key: string; tags: Tag[]; - shortDesc: string; + shortDescZh: string; + shortDescEn: string; author: string; source: string; type: string; diff --git a/frontend/src/views/app-store/apps/index.vue b/frontend/src/views/app-store/apps/index.vue index c21e32a49..04e77f5ab 100644 --- a/frontend/src/views/app-store/apps/index.vue +++ b/frontend/src/views/app-store/apps/index.vue @@ -20,7 +20,7 @@ :type="activeTag === item.key ? 'primary' : ''" :plain="activeTag !== item.key" > - {{ item.name }} + {{ language == 'zh' ? item.name : item.key }} @@ -71,12 +71,12 @@
- {{ app.shortDesc }} + {{ language == 'zh' ? app.shortDescZh : app.shortDescEn }}
- {{ tag.name }} + {{ language == 'zh' ? tag.name : tag.key }}
@@ -100,6 +100,9 @@ import i18n from '@/lang'; import Detail from '../detail/index.vue'; import router from '@/routers'; import { MsgSuccess } from '@/utils/message'; +import { useI18n } from 'vue-i18n'; + +const language = useI18n().locale.value; let req = reactive({ name: '', diff --git a/frontend/src/views/app-store/detail/index.vue b/frontend/src/views/app-store/detail/index.vue index c03ebf5a8..c8dfec3fa 100644 --- a/frontend/src/views/app-store/detail/index.vue +++ b/frontend/src/views/app-store/detail/index.vue @@ -15,7 +15,7 @@
- {{ app.shortDesc }} + {{ language == 'zh' ? app.shortDescZh : app.shortDescEn }}
@@ -94,10 +94,11 @@ import { GetApp, GetAppDetail } from '@/api/modules/app'; import LayoutContent from '@/layout/layout-content.vue'; import { onMounted, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; import Install from './install/index.vue'; +const language = useI18n().locale.value; interface OperateProps { - // id: number; appKey: string; } diff --git a/frontend/src/views/home/app/index.vue b/frontend/src/views/home/app/index.vue index 90886ec5a..d9334e150 100644 --- a/frontend/src/views/home/app/index.vue +++ b/frontend/src/views/home/app/index.vue @@ -15,7 +15,7 @@
- {{ app.shortDesc }} + {{ language == 'zh' ? app.shortDescZh : app.shortDescEn }}
@@ -43,8 +43,10 @@ import { App } from '@/api/interface/app'; import { Dashboard } from '@/api/interface/dashboard'; import { SearchApp } from '@/api/modules/app'; import { reactive, ref } from 'vue'; +import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; const router = useRouter(); +const language = useI18n().locale.value; let req = reactive({ name: '',