From 7ca06de217f47b7cf9be6c512a88989a2f246897 Mon Sep 17 00:00:00 2001 From: xion Date: Thu, 3 Apr 2025 21:22:46 +0800 Subject: [PATCH] fix: add detection version files --- public/locales/en/translation.json | 3 ++- public/locales/zh/translation.json | 3 ++- src/pages/app/edit/AppVersionList.tsx | 24 +++++++++++++++++++++++- src/pages/app/store/app-version.ts | 9 +++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index d8e3c61..49b6922 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -91,5 +91,6 @@ "Tips": "Tips", "Check username introduction": "Check your username, if the username is not available, you can contact the customer service to modify.", "Delete and remove file": "Delete and remove file", - "Delete App Introduce": "Delete App, when you click the delete button, the file will be deleted from the file management system." + "Delete App Introduce": "Delete App, when you click the delete button, the file will be deleted from the file management system.", + "Detect Files": "Detect Files" } \ No newline at end of file diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index 5649116..fb7a1b0 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -91,5 +91,6 @@ "Tips": "提示", "Check username introduction": "查看是否可以取名,如果当前用户名已存在,请更换其他用户名。其中用户名以@开头", "Delete and remove file": "删除并删除文件", - "Delete App Introduce": "删除应用, 当点击同时删除文件,会把文件管理中,应用相关的存储的资源同步删除。" + "Delete App Introduce": "删除应用, 当点击同时删除文件,会把文件管理中,应用相关的存储的资源同步删除。", + "Detect Files": "检测文件" } \ No newline at end of file diff --git a/src/pages/app/edit/AppVersionList.tsx b/src/pages/app/edit/AppVersionList.tsx index 9151f87..f38261a 100644 --- a/src/pages/app/edit/AppVersionList.tsx +++ b/src/pages/app/edit/AppVersionList.tsx @@ -22,6 +22,7 @@ import { useForm, Controller } from 'react-hook-form'; import { TextField } from '@mui/material'; import { pick } from 'lodash-es'; import { useAppDeleteModalStore, AppDeleteModal } from '../modules/AppDeleteModal'; +import { toast } from 'react-toastify'; const FormModal = () => { const { t } = useTranslation(); @@ -159,7 +160,6 @@ export const AppVersionList = () => { const isPublish = item.version === appVersion; const color = isPublish ? 'bg-green-500' : ''; const isRunning = item.status === 'running'; - console.log('appVersion', item, appVersion, versionStore.app); return (
@@ -257,6 +257,7 @@ export const AppVersionFile = () => { useShallow((state) => { return { formData: state.formData, + detectVersionList: state.detectVersionList, }; }), ); @@ -265,6 +266,24 @@ export const AppVersionFile = () => { const files = versionStore.formData.data.files || []; return files; }, [versionStore.formData]); + const onDetect = useCallback(async () => { + console.log('formData', versionStore.formData); + if (!versionStore.formData.key || !versionStore.formData.version) { + toast.error('请先选择应用和版本'); + return; + } + const res = await versionStore.detectVersionList({ + appKey: versionStore.formData.key, + version: versionStore.formData.version, + }); + console.log('res', res); + if (res.code === 200) { + toast.success('检测实际文件成功'); + } else { + toast.error(res.message || 'Detect failed'); + } + }, [versionStore.formData]); + const { t } = useTranslation(); return ( <>
version: {versionStore.formData.version}
@@ -272,6 +291,9 @@ export const AppVersionFile = () => {
Files + + +
Promise; publishVersion: (data: { id?: string; appKey?: string; version?: string }, opts?: { showToast?: boolean }) => Promise; + detectVersionList: (data: { appKey: string; version: string }) => Promise; }; export const useAppVersionStore = create((set, get) => { return { @@ -134,5 +135,13 @@ export const useAppVersionStore = create((set, get) => { } return res; }, + detectVersionList: async (data) => { + const res = await query.post({ + path: 'app', + key: 'detectVersionList', + data, + }); + return res; + }, }; });