feat: download 模块到本地
This commit is contained in:
@@ -7,7 +7,16 @@ import copy from 'copy-to-clipboard';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { useToCodeEditor } from '@/pages/code-editor';
|
||||
import { CardBlank } from '@/components/card/CardBlank';
|
||||
import { CloudUploadOutlined, DeleteOutlined, EditOutlined, ForkOutlined, GoldOutlined, PlusOutlined, ToolOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
CloudDownloadOutlined,
|
||||
CloudUploadOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
ForkOutlined,
|
||||
GoldOutlined,
|
||||
PlusOutlined,
|
||||
ToolOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { isObjectNull } from '@/utils/is-null';
|
||||
import { PublishFormModal } from './modal/PublishFormModal';
|
||||
|
||||
@@ -100,6 +109,7 @@ export const List = () => {
|
||||
getList: state.getList,
|
||||
loading: state.loading,
|
||||
setShowPublishModal: state.setShowPublishModal,
|
||||
downloadData: state.downloadData,
|
||||
};
|
||||
}),
|
||||
);
|
||||
@@ -108,11 +118,10 @@ export const List = () => {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className='w-full h-full flex'>
|
||||
<div className='w-full h-full flex bg-gray-200'>
|
||||
<div className='p-2 bg-white rounded-r-lg'>
|
||||
<Button
|
||||
className='w-10 '
|
||||
type='primary'
|
||||
icon={<PlusOutlined />}
|
||||
onClick={() => {
|
||||
editStore.setFormData({});
|
||||
@@ -172,6 +181,14 @@ export const List = () => {
|
||||
icon={<CloudUploadOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title='Download'>
|
||||
<Button
|
||||
onClick={() => {
|
||||
editStore.downloadData(item.id);
|
||||
}}
|
||||
icon={<CloudDownloadOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title='delete'>
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
|
||||
@@ -16,6 +16,7 @@ type EditStore = {
|
||||
showPublishModal: boolean;
|
||||
setShowPublishModal: (showPublishModal: boolean) => void;
|
||||
publishData: (data: any) => Promise<void>;
|
||||
downloadData: (data: any) => Promise<void>;
|
||||
};
|
||||
export const useEditStore = create<EditStore>((set, get) => {
|
||||
return {
|
||||
@@ -73,6 +74,20 @@ export const useEditStore = create<EditStore>((set, get) => {
|
||||
message.error(res.message || 'Request failed');
|
||||
}
|
||||
},
|
||||
downloadData: async (id) => {
|
||||
const res = await query.post({
|
||||
path: 'page',
|
||||
key: 'download',
|
||||
id: id,
|
||||
});
|
||||
if (res.code === 200) {
|
||||
message.success('Success');
|
||||
const url = new URL('resources/' + res.data, window.location.origin);
|
||||
window.open(url.href, '_blank');
|
||||
} else {
|
||||
message.error(res.message || 'Request failed');
|
||||
}
|
||||
},
|
||||
deleteData: async (id) => {
|
||||
const { getList } = get();
|
||||
const res = await query.post({
|
||||
|
||||
Reference in New Issue
Block a user