|
|
@@ -1,5 +1,5 @@
|
|
|
import React, { useState } from 'react';
|
|
|
-import { Table, Card, Tabs, Button, Space, Tag, Switch, Popconfirm, message, Modal, Form, Input, Image } from 'antd';
|
|
|
+import { Table, Card, Tabs, Button, Space, Tag, Switch, Popconfirm, Modal, Form, Input, App } from 'antd';
|
|
|
import { PlusOutlined, EditOutlined, DeleteOutlined, EyeOutlined, LinkOutlined } from '@ant-design/icons';
|
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
import { homeIconClient } from '@/client/api';
|
|
|
@@ -17,6 +17,7 @@ type CreateHomeIconRequest = InferRequestType<typeof homeIconClient.$post>['json
|
|
|
type UpdateHomeIconRequest = InferRequestType<typeof homeIconClient[":id"]["$put"]>['json'];
|
|
|
|
|
|
const HomeIconsPage: React.FC = () => {
|
|
|
+ const { message } = App.useApp();
|
|
|
const [activeTab, setActiveTab] = useState<'banner' | 'category'>('banner');
|
|
|
const [modalOpen, setModalOpen] = useState(false);
|
|
|
const [editingRecord, setEditingRecord] = useState<HomeIcon | null>(null);
|
|
|
@@ -43,7 +44,7 @@ const HomeIconsPage: React.FC = () => {
|
|
|
const createMutation = useMutation({
|
|
|
mutationFn: async (data: CreateHomeIconRequest) => {
|
|
|
const response = await homeIconClient.$post({ json: data });
|
|
|
- if (response.status !== 200) throw new Error('创建图标失败');
|
|
|
+ if (response.status !== 201) throw new Error('创建图标失败');
|
|
|
return response.json();
|
|
|
},
|
|
|
onSuccess: () => {
|
|
|
@@ -84,8 +85,7 @@ const HomeIconsPage: React.FC = () => {
|
|
|
const response = await homeIconClient[":id"].$delete({
|
|
|
param: { id: id.toString() }
|
|
|
});
|
|
|
- if (response.status !== 200) throw new Error('删除图标失败');
|
|
|
- return response.json();
|
|
|
+ if (response.status !== 204) throw new Error('删除图标失败');
|
|
|
},
|
|
|
onSuccess: () => {
|
|
|
message.success('删除成功');
|
|
|
@@ -175,7 +175,7 @@ const HomeIconsPage: React.FC = () => {
|
|
|
width: 80,
|
|
|
render: (file: FileType) => (
|
|
|
<img
|
|
|
- src={file.path}
|
|
|
+ src={file.fullUrl}
|
|
|
alt={file.name}
|
|
|
style={{ width: 60, height: 60, objectFit: 'cover', borderRadius: 4 }}
|
|
|
/>
|