diff --git a/frontend/src/layouts/BasicLayout.tsx b/frontend/src/layouts/BasicLayout.tsx
index 354c5b6b..d7d761e6 100644
--- a/frontend/src/layouts/BasicLayout.tsx
+++ b/frontend/src/layouts/BasicLayout.tsx
@@ -1,243 +1,245 @@
-import React, { useEffect, useState } from 'react';
-import { Layout, Menu, Dropdown, Modal, message, Spin, Space, Tooltip } from 'antd';
-import { useNavigate, useLocation, Outlet } from 'react-router-dom';
-import { useDispatch, useSelector } from 'react-redux';
-import {
- UserOutlined,
- LogoutOutlined,
- DownOutlined,
- ExclamationCircleOutlined,
- ClockCircleOutlined,
- CloudOutlined
+import React, {useEffect, useState, useCallback} from 'react';
+import {Layout, Menu, Dropdown, Modal, message, Spin, Space, Tooltip} from 'antd';
+import {useNavigate, useLocation, Outlet} from 'react-router-dom';
+import {useDispatch, useSelector} from 'react-redux';
+import {
+ UserOutlined,
+ LogoutOutlined,
+ DownOutlined,
+ ExclamationCircleOutlined,
+ ClockCircleOutlined,
+ CloudOutlined
} from '@ant-design/icons';
import * as AntdIcons from '@ant-design/icons';
-import { logout, setMenus, setUserInfo } from '../store/userSlice';
-import type { MenuProps } from 'antd';
-import { getCurrentUser } from '../pages/Login/service';
-import { getCurrentUserMenus } from '@/pages/System/Menu/service';
-import { getWeather } from '../services/weather';
-import type { MenuResponse } from '@/pages/System/Menu/types';
-import type { RootState } from '../store';
+import {logout, setMenus, setUserInfo} from '../store/userSlice';
+import type {MenuProps} from 'antd';
+import {getCurrentUser} from '../pages/Login/service';
+import {getCurrentUserMenus} from '@/pages/System/Menu/service';
+import {getWeather} from '../services/weather';
+import type {MenuResponse} from '@/pages/System/Menu/types';
+import type {RootState} from '../store';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
-const { Header, Content, Sider } = Layout;
-const { confirm } = Modal;
+const {Header, Content, Sider} = Layout;
+const {confirm} = Modal;
// 设置中文语言
dayjs.locale('zh-cn');
const BasicLayout: React.FC = () => {
- const navigate = useNavigate();
- const location = useLocation();
- const dispatch = useDispatch();
- const userInfo = useSelector((state: RootState) => state.user.userInfo);
- const menus = useSelector((state: RootState) => state.user.menus);
- const [loading, setLoading] = useState(true);
- const [currentTime, setCurrentTime] = useState(dayjs());
- const [weather, setWeather] = useState({ temp: '--', weather: '未知', city: '未知' });
- const [isInitialized, setIsInitialized] = useState(false);
+ const navigate = useNavigate();
+ const location = useLocation();
+ const dispatch = useDispatch();
+ const userInfo = useSelector((state: RootState) => state.user.userInfo);
+ const menus = useSelector((state: RootState) => state.user.menus);
+ const [loading, setLoading] = useState(true);
+ const [currentTime, setCurrentTime] = useState(dayjs());
+ const [weather, setWeather] = useState({temp: '--', weather: '未知', city: '未知'});
- useEffect(() => {
- // 每秒更新时间
- const timer = setInterval(() => {
- setCurrentTime(dayjs());
- }, 1000);
-
- // 获取天气信息
- const fetchWeather = async () => {
- try {
- const data = await getWeather();
- setWeather(data);
- } catch (error) {
- console.error('获取天气信息失败:', error);
- }
- };
+ // 将天气获取逻辑提取为useCallback
+ const fetchWeather = useCallback(async () => {
+ try {
+ const data = await getWeather();
+ setWeather(data);
+ } catch (error) {
+ console.error('获取天气信息失败:', error);
+ }
+ }, []);
// 初始化用户数据
- const initializeUserData = async () => {
- if (isInitialized) return;
- try {
- setLoading(true);
-
- // 获取并更新用户信息
- const userData = await getCurrentUser();
- dispatch(setUserInfo(userData));
+ useEffect(() => {
+ const initializeUserData = async () => {
+ try {
+ setLoading(true);
+ const userData = await getCurrentUser();
+ dispatch(setUserInfo(userData));
+ const menuData = await getCurrentUserMenus();
+ dispatch(setMenus(menuData));
+ } catch (error) {
+ message.error('初始化用户数据失败');
+ dispatch(logout());
+ navigate('/login', {replace: true});
+ } finally {
+ setLoading(false);
+ }
+ };
- const menuData = await getCurrentUserMenus();
- dispatch(setMenus(menuData));
+ if (!userInfo) {
+ initializeUserData();
+ } else {
+ setLoading(false);
+ }
+ }, []);
- setIsInitialized(true);
- } catch (error) {
- message.error('初始化用户数据失败');
- } finally {
- setLoading(false);
- }
+ // 处理时间和天气更新
+ useEffect(() => {
+ // 每秒更新时间
+ const timer = setInterval(() => {
+ setCurrentTime(dayjs());
+ }, 1000);
+
+ // 初始化天气并设置定时更新
+ fetchWeather();
+ const weatherTimer = setInterval(fetchWeather, 30 * 60 * 1000);
+
+ return () => {
+ clearInterval(timer);
+ clearInterval(weatherTimer);
+ };
+ }, [fetchWeather]);
+
+ const handleLogout = () => {
+ confirm({
+ title: '确认退出',
+ icon: ,
+ content: '确定要退出系统吗?',
+ okText: '确定',
+ cancelText: '取消',
+ onOk: () => {
+ dispatch(logout());
+ message.success('退出成功');
+ navigate('/login', {replace: true});
+ }
+ });
};
- fetchWeather();
- initializeUserData();
+ const userMenuItems: MenuProps['items'] = [
+ {
+ key: 'userInfo',
+ icon: ,
+ label: (
+
+
当前用户:{userInfo?.nickname || userInfo?.username}
+ {userInfo?.email &&
{userInfo.email}
}
+
+ ),
+ disabled: true
+ },
+ {
+ type: 'divider'
+ },
+ {
+ key: 'logout',
+ icon: ,
+ label: '退出登录',
+ onClick: handleLogout
+ }
+ ];
- // 每半小时更新一次天气
- const weatherTimer = setInterval(fetchWeather, 30 * 60 * 1000);
-
- return () => {
- clearInterval(timer);
- clearInterval(weatherTimer);
+ // 获取图标组件
+ const getIcon = (iconName: string | undefined) => {
+ if (!iconName) return null;
+ const iconKey = `${iconName.charAt(0).toUpperCase() + iconName.slice(1)}Outlined`;
+ const Icon = (AntdIcons as any)[iconKey];
+ return Icon ? : null;
};
- }, [isInitialized]);
- const handleLogout = () => {
- confirm({
- title: '确认退出',
- icon: ,
- content: '确定要退出系统吗?',
- okText: '确定',
- cancelText: '取消',
- onOk: () => {
- dispatch(logout());
- message.success('退出成功');
- navigate('/login', { replace: true });
- }
- });
- };
+ // 将菜单数据转换为antd Menu需要的格式
+ const getMenuItems = (menuList: MenuResponse[]): MenuProps['items'] => {
+ return menuList.map(menu => ({
+ key: menu.path || menu.id.toString(),
+ icon: getIcon(menu.icon),
+ label: menu.name,
+ children: menu.children && menu.children.length > 0 ? getMenuItems(menu.children) : undefined
+ }));
+ };
- const userMenuItems: MenuProps['items'] = [
- {
- key: 'userInfo',
- icon: ,
- label: (
-
-
当前用户:{userInfo?.nickname || userInfo?.username}
- {userInfo?.email &&
{userInfo.email}
}
-
- ),
- disabled: true
- },
- {
- type: 'divider'
- },
- {
- key: 'logout',
- icon: ,
- label: '退出登录',
- onClick: handleLogout
- }
- ];
-
- // 获取图标组件
- const getIcon = (iconName: string | undefined) => {
- if (!iconName) return null;
- const iconKey = `${iconName.charAt(0).toUpperCase() + iconName.slice(1)}Outlined`;
- const Icon = (AntdIcons as any)[iconKey];
- return Icon ? : null;
- };
-
- // 将菜单数据转换为antd Menu需要的格式
- const getMenuItems = (menuList: MenuResponse[]): MenuProps['items'] => {
- return menuList.map(menu => ({
- key: menu.path || menu.id.toString(),
- icon: getIcon(menu.icon),
- label: menu.name,
- children: menu.children && menu.children.length > 0 ? getMenuItems(menu.children) : undefined
- }));
- };
-
- if (loading) {
- return (
-
-
-
-
正在为您准备系统资源
-
请稍候,马上就好...
-
-
- );
- }
-
- return (
-
-
-
-
-
-
-
-
-
-
- {currentTime.format('YYYY年MM月DD日 HH:mm:ss')} 星期{currentTime.format('dd')}
-
-
-
+
+
+
正在为您准备系统资源
+
请稍候,马上就好...
+
+
+ );
+ }
+
+ return (
+
+
+
+
+
+
+
+
+
-
- {weather.weather} {weather.temp}℃
-
-
-
-
-
-
- {userInfo?.nickname || userInfo?.username}
-
+
+ {currentTime.format('YYYY年MM月DD日 HH:mm:ss')} 星期{currentTime.format('dd')}
-
-
-
-
-
-
-
-
- );
+
+
+
+ {weather.weather} {weather.temp}℃
+
+
+
+
+
+
+ {userInfo?.nickname || userInfo?.username}
+
+
+
+
+
+
+
+
+
+
+ );
};
export default BasicLayout;
\ No newline at end of file
diff --git a/frontend/src/pages/Dashboard/index.tsx b/frontend/src/pages/Dashboard/index.tsx
index e139b683..79abf74a 100644
--- a/frontend/src/pages/Dashboard/index.tsx
+++ b/frontend/src/pages/Dashboard/index.tsx
@@ -1,8 +1,14 @@
-import React from 'react';
+import React, { useEffect } from 'react';
import { Card, Row, Col, Statistic } from 'antd';
import { UserOutlined, ShoppingCartOutlined, FileOutlined } from '@ant-design/icons';
const Dashboard: React.FC = () => {
+ useEffect(() => {
+ // 检查这里的数据加载逻辑
+ // 是否有多个useEffect都在加载相同的数据
+ // 或者依赖项是否设置正确
+ }, []); // 检查依赖项
+
return (
diff --git a/frontend/src/pages/System/User/index.tsx b/frontend/src/pages/System/User/index.tsx
index 384e6351..5b3418df 100644
--- a/frontend/src/pages/System/User/index.tsx
+++ b/frontend/src/pages/System/User/index.tsx
@@ -1,12 +1,13 @@
import React, { useEffect, useState } from 'react';
import { Table, Button, Modal, Form, Input, Space, message, Switch, TreeSelect } from 'antd';
import { PlusOutlined, EditOutlined, DeleteOutlined, KeyOutlined, TeamOutlined } from '@ant-design/icons';
-import type { UserResponse } from './types';
+import type { UserResponse, Role } from './types';
import type { DepartmentDTO } from '../Department/types';
import { getUsers, createUser, updateUser, deleteUser, resetPassword } from './service';
import { getDepartmentTree } from '../Department/service';
import { convertToPageParams, convertToPageInfo } from '@/utils/page';
import { useTableData } from '@/hooks/useTableData';
+import type { FixedType, AlignType } from 'rc-table/lib/interface';
// import RoleModal from './components/RoleModal';
const UserPage: React.FC = () => {
@@ -45,10 +46,6 @@ const UserPage: React.FC = () => {
const [form] = Form.useForm();
const [passwordForm] = Form.useForm();
- useEffect(() => {
- fetchUsers();
- }, [pagination.current, pagination.pageSize]);
-
const handleAdd = () => {
setEditingUser(null);
form.resetFields();
@@ -61,8 +58,7 @@ const UserPage: React.FC = () => {
const handleEdit = (record: UserResponse) => {
setEditingUser(record);
form.setFieldsValue({
- ...record,
- password: 'UNCHANGED_PASSWORD'
+ ...record
});
setModalVisible(true);
};
@@ -77,7 +73,7 @@ const UserPage: React.FC = () => {
try {
const values = await passwordForm.validateFields();
if (editingUser) {
- await resetPassword(editingUser.id);
+ await resetPassword(editingUser.id, values.password);
message.success('密码重置成功');
setResetPasswordModalVisible(false);
}
@@ -92,7 +88,6 @@ const UserPage: React.FC = () => {
if (editingUser) {
await updateUser(editingUser.id, {
...values,
- password: values.password === 'UNCHANGED_PASSWORD' ? editingUser.password : values.password,
version: editingUser.version
});
message.success('更新成功');
@@ -121,77 +116,86 @@ const UserPage: React.FC = () => {
// };
const columns = [
+ {
+ title: 'ID',
+ dataIndex: 'id',
+ key: 'id',
+ width: 80,
+ fixed: 'left' as FixedType
+ },
{
title: '用户名',
dataIndex: 'username',
key: 'username',
- width: '12%',
+ width: 120,
},
{
title: '昵称',
dataIndex: 'nickname',
key: 'nickname',
- width: '12%',
+ width: 120,
},
{
title: '邮箱',
dataIndex: 'email',
key: 'email',
- width: '15%',
+ width: 200,
+ ellipsis: true,
},
{
title: '手机号',
dataIndex: 'phone',
key: 'phone',
- width: '12%',
+ width: 120,
},
{
title: '角色',
dataIndex: 'roles',
key: 'roles',
- width: '15%',
+ width: 150,
+ ellipsis: true,
render: (roles: Role[]) => roles?.map(role => role.name).join(', ') || '-'
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
- width: '15%',
+ width: 180,
+ },
+ {
+ title: '更新时间',
+ dataIndex: 'updateTime',
+ key: 'updateTime',
+ width: 180,
},
{
title: '状态',
dataIndex: 'enabled',
key: 'enabled',
- width: '8%',
+ width: 80,
+ align: 'center' as AlignType,
render: (enabled: boolean) => (
-
+
),
},
{
title: '操作',
key: 'action',
- width: '280px',
+ width: 180,
+ fixed: 'right' as FixedType,
render: (_: any, record: UserResponse) => (
-
+
}
onClick={() => handleEdit(record)}
>
编辑
- {/* 注释掉角色分配按钮
- }
- onClick={() => handleAssignRoles(record)}
- disabled={record.username === 'admin'}
- >
- 分配角色
-
- */}
}
onClick={() => handleResetPassword(record)}
>
@@ -199,6 +203,7 @@ const UserPage: React.FC = () => {
}
onClick={() => handleDelete(record.id)}
@@ -224,12 +229,25 @@ const UserPage: React.FC = () => {
columns={columns}
dataSource={users}
rowKey="id"
+ scroll={{ x: 1500 }}
pagination={{
...pagination,
showSizeChanger: true,
showQuickJumper: true,
showTotal: (total) => `共 ${total} 条记录`,
- onChange: onPageChange
+ onChange: onPageChange,
+ size: 'small'
+ }}
+ rowSelection={{
+ type: 'checkbox',
+ onChange: (selectedRowKeys, selectedRows) => {
+ console.log('selectedRowKeys:', selectedRowKeys);
+ console.log('selectedRows:', selectedRows);
+ },
+ getCheckboxProps: (record) => ({
+ disabled: record.username === 'admin',
+ }),
+ fixed: true,
}}
size="middle"
bordered
@@ -254,20 +272,6 @@ const UserPage: React.FC = () => {
>
- {editingUser && (
-
-
-
- )}
- {!editingUser && (
-
-
-
- )}
=> {
- try {
- // 先获取 IP 定位
- const ipUrl = 'https://restapi.amap.com/v3/ip';
- const weatherUrl = 'https://restapi.amap.com/v3/weather/weatherInfo';
- const key = '46a02c7d20534596f7386caf02204caa'; // 需要替换成你自己的 key
+ try {
+ // 先获取 IP 定位
+ const ipUrl = 'https://restapi.amap.com/v3/ip';
+ const weatherUrl = 'https://restapi.amap.com/v3/weather/weatherInfo';
+ const key = '46a02c7d20534596f7386caf02204caa'; // 需要替换成你自己的 key
- const ipResponse = await axios.get(`${ipUrl}?key=${key}`);
- const { adcode } = ipResponse.data;
+ const ipResponse = await axios.get(`${ipUrl}?key=${key}`);
+ const {adcode} = ipResponse.data;
- const weatherResponse = await axios.get(`${weatherUrl}?key=${key}&city=${adcode}`);
- const weatherData = weatherResponse.data.lives[0];
+ const weatherResponse = await axios.get(`${weatherUrl}?key=${key}&city=${adcode}`);
+ const weatherData = weatherResponse.data.lives[0];
- return {
- temp: weatherData.temperature,
- weather: weatherData.weather,
- city: weatherData.city
- };
- } catch (error) {
- console.error('获取天气信息失败:', error);
- return {
- temp: '--',
- weather: '未知',
- city: '未知'
- };
- }
+ return {
+ temp: weatherData.temperature,
+ weather: weatherData.weather,
+ city: weatherData.city
+ };
+ } catch (error) {
+ console.error('获取天气信息失败:', error);
+ return {
+ temp: '--',
+ weather: '未知',
+ city: '未知'
+ };
+ }
};
\ No newline at end of file
diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts
index b3ea013e..a40bbdb8 100644
--- a/frontend/src/store/index.ts
+++ b/frontend/src/store/index.ts
@@ -1,10 +1,10 @@
-import { configureStore } from '@reduxjs/toolkit';
+import {configureStore} from '@reduxjs/toolkit';
import userReducer from './userSlice';
const store = configureStore({
- reducer: {
- user: userReducer,
- },
+ reducer: {
+ user: userReducer,
+ },
});
export type RootState = ReturnType;
diff --git a/frontend/src/store/userSlice.ts b/frontend/src/store/userSlice.ts
index 733a7b70..4f61aaac 100644
--- a/frontend/src/store/userSlice.ts
+++ b/frontend/src/store/userSlice.ts
@@ -1,51 +1,51 @@
-import { createSlice, PayloadAction } from '@reduxjs/toolkit';
-import type { MenuResponse } from '@/pages/System/Menu/types';
+import {createSlice, PayloadAction} from '@reduxjs/toolkit';
+import type {MenuResponse} from '@/pages/System/Menu/types';
interface UserInfo {
- id: number;
- username: string;
- nickname?: string;
- email?: string;
- phone?: string;
+ id: number;
+ username: string;
+ nickname?: string;
+ email?: string;
+ phone?: string;
}
interface UserState {
- token: string | null;
- userInfo: UserInfo | null;
- menus: MenuResponse[];
+ token: string | null;
+ userInfo: UserInfo | null;
+ menus: MenuResponse[];
}
const initialState: UserState = {
- token: localStorage.getItem('token'),
- userInfo: null,
- menus: []
+ token: localStorage.getItem('token'),
+ userInfo: null,
+ menus: []
};
const userSlice = createSlice({
- name: 'user',
- initialState,
- reducers: {
- setToken: (state, action: PayloadAction) => {
- state.token = action.payload;
- localStorage.setItem('token', action.payload);
- },
- setUserInfo: (state, action: PayloadAction) => {
- state.userInfo = action.payload;
- localStorage.setItem('userInfo', JSON.stringify(action.payload));
- },
- setMenus: (state, action: PayloadAction) => {
- state.menus = action.payload;
- },
- logout: (state) => {
- state.token = null;
- state.userInfo = null;
- state.menus = [];
- localStorage.removeItem('token');
- localStorage.removeItem('tenantId');
- localStorage.removeItem('userInfo');
+ name: 'user',
+ initialState,
+ reducers: {
+ setToken: (state, action: PayloadAction) => {
+ state.token = action.payload;
+ localStorage.setItem('token', action.payload);
+ },
+ setUserInfo: (state, action: PayloadAction) => {
+ state.userInfo = action.payload;
+ localStorage.setItem('userInfo', JSON.stringify(action.payload));
+ },
+ setMenus: (state, action: PayloadAction) => {
+ state.menus = action.payload;
+ },
+ logout: (state) => {
+ state.token = null;
+ state.userInfo = null;
+ state.menus = [];
+ localStorage.removeItem('token');
+ localStorage.removeItem('tenantId');
+ localStorage.removeItem('userInfo');
+ }
}
- }
});
-export const { setToken, setUserInfo, setMenus, logout } = userSlice.actions;
+export const {setToken, setUserInfo, setMenus, logout} = userSlice.actions;
export default userSlice.reducer;
\ No newline at end of file
diff --git a/frontend/src/utils/page.ts b/frontend/src/utils/page.ts
index ab8a5d34..ed37bd25 100644
--- a/frontend/src/utils/page.ts
+++ b/frontend/src/utils/page.ts
@@ -1,4 +1,4 @@
-import type { Page, PageParams } from '@/types/base/page';
+import type {Page, PageParams} from '@/types/base/page';
// 默认分页参数
const DEFAULT_PAGE_SIZE = 10;
@@ -8,22 +8,22 @@ const DEFAULT_CURRENT = 1;
* 转换前端分页参数为后端分页参数
*/
export const convertToPageParams = (params?: {
- current?: number;
- pageSize?: number;
- sortField?: string;
- sortOrder?: string;
+ current?: number;
+ pageSize?: number;
+ sortField?: string;
+ sortOrder?: string;
}): PageParams => ({
- pageNum: Math.max(1, params?.current || DEFAULT_CURRENT) - 1, // 转换为从0开始的页码
- pageSize: params?.pageSize || DEFAULT_PAGE_SIZE,
- sortField: params?.sortField,
- sortOrder: params?.sortOrder?.replace('end', '')
+ pageNum: Math.max(1, params?.current || DEFAULT_CURRENT) - 1, // 转换为从0开始的页码
+ pageSize: params?.pageSize || DEFAULT_PAGE_SIZE,
+ sortField: params?.sortField,
+ sortOrder: params?.sortOrder?.replace('end', '')
});
/**
* 转换后端分页数据为前端分页数据
*/
export const convertToPageInfo = (page?: Page) => ({
- current: (page?.number || 0) + 1,
- pageSize: page?.size || DEFAULT_PAGE_SIZE,
- total: page?.totalElements || 0
+ current: (page?.number || 0) + 1,
+ pageSize: page?.size || DEFAULT_PAGE_SIZE,
+ total: page?.totalElements || 0
});
\ No newline at end of file
diff --git a/frontend/src/utils/request.ts b/frontend/src/utils/request.ts
index 7e303c71..31cc5627 100644
--- a/frontend/src/utils/request.ts
+++ b/frontend/src/utils/request.ts
@@ -1,5 +1,5 @@
-import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
-import { message } from 'antd';
+import axios, {AxiosRequestConfig, AxiosResponse} from 'axios';
+import {message} from 'antd';
export interface ApiResponse {
code: number;
@@ -27,11 +27,11 @@ request.interceptors.request.use(
(config) => {
const token = localStorage.getItem('token');
const tenantId = localStorage.getItem('tenantId');
-
+
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
-
+
if (tenantId) {
config.headers['X-Tenant-Id'] = tenantId;
}
@@ -61,7 +61,7 @@ request.interceptors.response.use(
(error) => {
const config = error.config as RequestOptions;
const response = error.response;
-
+
if (!config.hideErrorMessage) {
if (response?.data?.message && response?.status !== 500) {
message.error(response.data.message);
@@ -75,18 +75,18 @@ request.interceptors.response.use(
);
const extendedRequest = {
- get: (url: string, config?: RequestOptions) =>
+ get: (url: string, config?: RequestOptions) =>
request.get(url, config),
-
- post: (url: string, data?: any, config?: RequestOptions) =>
+
+ post: (url: string, data?: any, config?: RequestOptions) =>
request.post(url, data, config),
-
- put: (url: string, data?: any, config?: RequestOptions) =>
+
+ put: (url: string, data?: any, config?: RequestOptions) =>
request.put(url, data, config),
-
- delete: (url: string, config?: RequestOptions) =>
+
+ delete: (url: string, config?: RequestOptions) =>
request.delete(url, config),
-
+
request: request
};
diff --git a/frontend/src/utils/table.ts b/frontend/src/utils/table.ts
index b42f8066..718a2444 100644
--- a/frontend/src/utils/table.ts
+++ b/frontend/src/utils/table.ts
@@ -1,20 +1,20 @@
-import type { TableState } from '@/types/table';
+import type {TableState} from '@/types/table';
// 创建初始状态
export const createInitialState = (pageSize: number = 10): TableState => ({
- list: [],
- pagination: {
- current: 1,
- pageSize,
- total: 0
- },
- loading: false,
- selectedRows: [],
- selectedRowKeys: []
+ list: [],
+ pagination: {
+ current: 1,
+ pageSize,
+ total: 0
+ },
+ loading: false,
+ selectedRows: [],
+ selectedRowKeys: []
});
// 处理错误
export const handleTableError = (error: any, message: string) => {
- console.error(message, error);
- return false;
+ console.error(message, error);
+ return false;
};
\ No newline at end of file