修复bug
This commit is contained in:
@@ -70,7 +70,7 @@ const MqttCommunicationLogPage: React.FC = () => {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [form, pagination.current, pagination.pageSize]); // 恢复原来的依赖,以避免循环依赖
|
||||
}, [form, pagination.current, pagination.pageSize]);
|
||||
|
||||
useEffect(() => {
|
||||
if (user?.role === 'admin') {
|
||||
|
||||
@@ -154,7 +154,7 @@ export default function AdminRobotsPage() {
|
||||
// 获取机器人状态类型
|
||||
const fetchRobotStatusTypes = useCallback(async () => {
|
||||
try {
|
||||
const response = await api.get<BaseResponse<string[]>>('/admin/robot/status/types');
|
||||
const response = await api.get<BaseResponse<string[]>>('/api/admin/robot/status/types');
|
||||
if (response.data && response.data.code === 0 && Array.isArray(response.data.data)) {
|
||||
setRobotStatusTypes(response.data.data);
|
||||
// If newRobotData.status is default and status types are loaded, set to the first available status
|
||||
@@ -192,7 +192,7 @@ export default function AdminRobotsPage() {
|
||||
|
||||
try {
|
||||
// Correctly expect BaseResponse wrapping Page<ChargingRobot>
|
||||
const response = await api.post<BaseResponse<Page<ChargingRobot>>>('/admin/robot/list/page', queryParams);
|
||||
const response = await api.post<BaseResponse<Page<ChargingRobot>>>('/api/admin/robot/list/page', queryParams);
|
||||
|
||||
if (response.data && response.data.code === 0 && response.data.data) {
|
||||
const pageData = response.data.data; // This is the Page<ChargingRobot> object
|
||||
@@ -274,7 +274,7 @@ export default function AdminRobotsPage() {
|
||||
|
||||
setIsLoading(true); // Or a specific loading state like setIsAddingRobot(true)
|
||||
try {
|
||||
const response = await api.post<BaseResponse<ChargingRobot>>('/admin/robot/add', newRobotData);
|
||||
const response = await api.post<BaseResponse<ChargingRobot>>('/api/admin/robot/add', newRobotData);
|
||||
if (response.data && response.data.code === 0) {
|
||||
setIsAddModalOpen(false);
|
||||
fetchRobots(pageInfo.current, pageInfo.size, filters); // Refresh list
|
||||
@@ -306,7 +306,7 @@ export default function AdminRobotsPage() {
|
||||
setDeleteError(null);
|
||||
try {
|
||||
const deletePayload: DeleteRobotRequest = { id: robotToDelete.id };
|
||||
const response = await api.post<BaseResponse<boolean>>('/admin/robot/delete', deletePayload);
|
||||
const response = await api.post<BaseResponse<boolean>>('/api/admin/robot/delete', deletePayload);
|
||||
if (response.data && response.data.code === 0 && response.data.data === true) {
|
||||
setIsDeleteModalOpen(false);
|
||||
setRobotToDelete(null);
|
||||
@@ -374,7 +374,7 @@ export default function AdminRobotsPage() {
|
||||
batteryLevel: robotToEditData.batteryLevel,
|
||||
currentLocation: robotToEditData.currentLocation,
|
||||
};
|
||||
const response = await api.post<BaseResponse<null>>('/admin/robot/update', payload);
|
||||
const response = await api.post<BaseResponse<null>>('/api/admin/robot/update', payload);
|
||||
if (response.data && response.data.code === 0) {
|
||||
setIsEditModalOpen(false);
|
||||
fetchRobots(pageInfo.current, pageInfo.size, filters); // Refresh list
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:7529/api',
|
||||
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user