fix: add detection version files

This commit is contained in:
xion 2025-04-03 21:22:46 +08:00
parent 9add82dc7e
commit 7ca06de217
4 changed files with 36 additions and 3 deletions

View File

@ -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"
}

View File

@ -91,5 +91,6 @@
"Tips": "提示",
"Check username introduction": "查看是否可以取名,如果当前用户名已存在,请更换其他用户名。其中用户名以@开头",
"Delete and remove file": "删除并删除文件",
"Delete App Introduce": "删除应用, 当点击同时删除文件,会把文件管理中,应用相关的存储的资源同步删除。"
"Delete App Introduce": "删除应用, 当点击同时删除文件,会把文件管理中,应用相关的存储的资源同步删除。",
"Detect Files": "检测文件"
}

View File

@ -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 (
<div className='card w-[300px]' key={index}>
<div className={'flex items-center justify-between'}>
@ -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 (
<>
<div>version: {versionStore.formData.version}</div>
@ -272,6 +291,9 @@ export const AppVersionFile = () => {
<div className='flex gap-2 items-center border-b border-b-gray-200 py-2 px-2'>
Files
<FileUpload />
<Tooltip title='从同文件目录下检测已经上传的文件内容'>
<Button onClick={onDetect}>{t('Detect Files')}</Button>
</Tooltip>
</div>
<div
className='mt-2 '

View File

@ -25,6 +25,7 @@ type AppVersionStore = {
*/
deleteData: (id: string, deleteFile?: boolean) => Promise<void>;
publishVersion: (data: { id?: string; appKey?: string; version?: string }, opts?: { showToast?: boolean }) => Promise<any>;
detectVersionList: (data: { appKey: string; version: string }) => Promise<any>;
};
export const useAppVersionStore = create<AppVersionStore>((set, get) => {
return {
@ -134,5 +135,13 @@ export const useAppVersionStore = create<AppVersionStore>((set, get) => {
}
return res;
},
detectVersionList: async (data) => {
const res = await query.post({
path: 'app',
key: 'detectVersionList',
data,
});
return res;
},
};
});