From b1fbdcc566f5df739522659018ec1660825ef14b Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Tue, 31 Dec 2024 17:57:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(appstore):=20Add=20Synchronization=20of=20?= =?UTF-8?q?Main=20Node=20Application=20Store=20Pa=E2=80=A6=20(#7612)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/app/task/task.go | 10 +++--- core/buserr/errors.go | 11 +++++++ core/utils/files/files.go | 8 +++++ frontend/src/api/interface/app.ts | 5 +++ frontend/src/api/modules/app.ts | 4 +++ frontend/src/components/backup/index.vue | 4 ++- frontend/src/components/dialog-pro/index.vue | 2 +- frontend/src/components/log-file/index.vue | 4 ++- frontend/src/lang/modules/zh.ts | 1 + frontend/src/store/modules/global.ts | 1 + frontend/src/utils/util.ts | 31 ++++++++++++++++--- frontend/src/views/app-store/apps/index.vue | 12 +++++-- .../src/views/app-store/setting/index.vue | 19 ++++++++++-- frontend/src/views/cronjob/backup/index.vue | 4 ++- .../src/views/host/file-management/index.vue | 4 +-- 15 files changed, 100 insertions(+), 20 deletions(-) diff --git a/agent/app/task/task.go b/agent/app/task/task.go index 749387941..ce0bc4332 100644 --- a/agent/app/task/task.go +++ b/agent/app/task/task.go @@ -251,22 +251,22 @@ func (t *Task) Logf(format string, v ...any) { } func (t *Task) LogFailed(msg string) { - t.Logger.Printf(msg + i18n.GetMsgByKey("Failed")) + t.Logger.Println(msg + i18n.GetMsgByKey("Failed")) } func (t *Task) LogFailedWithErr(msg string, err error) { - t.Logger.Printf(fmt.Sprintf("%s %s : %s", msg, i18n.GetMsgByKey("Failed"), err.Error())) + t.Logger.Println(fmt.Sprintf("%s %s : %s", msg, i18n.GetMsgByKey("Failed"), err.Error())) } func (t *Task) LogSuccess(msg string) { - t.Logger.Printf(msg + i18n.GetMsgByKey("Success")) + t.Logger.Println(msg + i18n.GetMsgByKey("Success")) } func (t *Task) LogSuccessF(format string, v ...any) { - t.Logger.Printf(fmt.Sprintf(format, v...) + i18n.GetMsgByKey("Success")) + t.Logger.Println(fmt.Sprintf(format, v...) + i18n.GetMsgByKey("Success")) } func (t *Task) LogStart(msg string) { - t.Logger.Printf(fmt.Sprintf("%s%s", i18n.GetMsgByKey("Start"), msg)) + t.Logger.Println(fmt.Sprintf("%s%s", i18n.GetMsgByKey("Start"), msg)) } func (t *Task) LogWithOps(operate, msg string) { diff --git a/core/buserr/errors.go b/core/buserr/errors.go index d4805eedc..5015ff84b 100644 --- a/core/buserr/errors.go +++ b/core/buserr/errors.go @@ -65,3 +65,14 @@ func WithMap(Key string, maps map[string]interface{}, err error) BusinessError { Err: err, } } + +func WithName(Key string, name string) BusinessError { + paramMap := map[string]interface{}{} + if name != "" { + paramMap["name"] = name + } + return BusinessError{ + Msg: Key, + Map: paramMap, + } +} diff --git a/core/utils/files/files.go b/core/utils/files/files.go index 0aab25873..f0cab6e8a 100644 --- a/core/utils/files/files.go +++ b/core/utils/files/files.go @@ -161,3 +161,11 @@ func DownloadFileWithProxy(url, dst string) error { } return nil } + +func Stat(path string) bool { + _, err := os.Stat(path) + if err != nil && os.IsNotExist(err) { + return false + } + return true +} diff --git a/frontend/src/api/interface/app.ts b/frontend/src/api/interface/app.ts index 81ff75521..3b2acc535 100644 --- a/frontend/src/api/interface/app.ts +++ b/frontend/src/api/interface/app.ts @@ -268,4 +268,9 @@ export namespace App { export interface AppStoreConfig { defaultDomain: string; } + + export interface CustomAppStoreConfig { + status: string; + imagePrefix: string; + } } diff --git a/frontend/src/api/modules/app.ts b/frontend/src/api/modules/app.ts index a7a6c6cfa..6183c28ec 100644 --- a/frontend/src/api/modules/app.ts +++ b/frontend/src/api/modules/app.ts @@ -122,3 +122,7 @@ export const UpdateAppStoreConfig = (req: App.AppStoreConfig) => { export const SyncCutomAppStore = (req: App.AppStoreSync) => { return http.post(`/custom/app/sync`, req); }; + +export const getCurrentNodeCustomAppConfig = () => { + return http.get(`/custom/app/config`); +}; diff --git a/frontend/src/components/backup/index.vue b/frontend/src/components/backup/index.vue index d68eeb893..64fe839ee 100644 --- a/frontend/src/components/backup/index.vue +++ b/frontend/src/components/backup/index.vue @@ -114,6 +114,8 @@ import { Backup } from '@/api/interface/backup'; import router from '@/routers'; import { MsgSuccess } from '@/utils/message'; import TaskLog from '@/components/task-log/index.vue'; +import { GlobalStore } from '@/store'; +const globalStore = GlobalStore(); const selects = ref([]); const loading = ref(); @@ -306,7 +308,7 @@ const onDownload = async (row: Backup.RecordInfo) => { fileName: row.fileName, }; await downloadBackupRecord(params).then(async (res) => { - downloadFile(res.data); + downloadFile(res.data, globalStore.currentNode); }); }; diff --git a/frontend/src/components/dialog-pro/index.vue b/frontend/src/components/dialog-pro/index.vue index 087af7103..6ddf6f86d 100644 --- a/frontend/src/components/dialog-pro/index.vue +++ b/frontend/src/components/dialog-pro/index.vue @@ -28,7 +28,7 @@ diff --git a/frontend/src/views/cronjob/backup/index.vue b/frontend/src/views/cronjob/backup/index.vue index 42db0724b..a450207fd 100644 --- a/frontend/src/views/cronjob/backup/index.vue +++ b/frontend/src/views/cronjob/backup/index.vue @@ -54,6 +54,8 @@ import i18n from '@/lang'; import { downloadBackupRecord, searchBackupRecordsByCronjob } from '@/api/modules/backup'; import { Backup } from '@/api/interface/backup'; import { MsgError } from '@/utils/message'; +import { GlobalStore } from '@/store'; +const globalStore = GlobalStore(); const selects = ref([]); const loading = ref(); @@ -116,7 +118,7 @@ const onDownload = async (row: Backup.RecordInfo) => { await downloadBackupRecord(params) .then(async (res) => { loading.value = false; - downloadFile(res.data); + downloadFile(res.data, globalStore.currentNode); }) .catch(() => { loading.value = false; diff --git a/frontend/src/views/host/file-management/index.vue b/frontend/src/views/host/file-management/index.vue index be6646314..8628febe1 100644 --- a/frontend/src/views/host/file-management/index.vue +++ b/frontend/src/views/host/file-management/index.vue @@ -311,7 +311,7 @@ import { RemoveFavorite, SearchFavorite, } from '@/api/modules/files'; -import { computeSize, copyText, dateFormat, downloadFile, getFileType, getIcon, getRandomStr } from '@/utils/util'; +import { computeSize, copyText, dateFormat, getFileType, getIcon, getRandomStr, downloadFile } from '@/utils/util'; import { StarFilled, Star, Top, Right, Close } from '@element-plus/icons-vue'; import { File } from '@/api/interface/file'; import { Mimetypes, Languages } from '@/global/mimetype'; @@ -810,7 +810,7 @@ const openPaste = () => { }; const openDownload = (file: File.File) => { - downloadFile(file.path); + downloadFile(file.path, globalStore.currentNode); }; const openDetail = (row: File.File) => {