优化全局提醒
This commit is contained in:
18
src/App.tsx
18
src/App.tsx
@@ -1,8 +1,24 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { RouterProvider } from 'react-router-dom';
|
import { RouterProvider } from 'react-router-dom';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
|
import { App as AntdApp } from 'antd';
|
||||||
|
import utils from './lib/utils';
|
||||||
|
|
||||||
|
// 用于静态注入 message/modal/notification
|
||||||
|
const StaticAntd = () => {
|
||||||
|
const { message, modal, notification } = AntdApp.useApp();
|
||||||
|
utils.setMessage(message);
|
||||||
|
utils.setModal(modal);
|
||||||
|
utils.setNotification(notification);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
|
|
||||||
return <RouterProvider router={router} />;
|
return (
|
||||||
|
<AntdApp>
|
||||||
|
<StaticAntd />
|
||||||
|
<RouterProvider router={router} />
|
||||||
|
</AntdApp>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,34 @@
|
|||||||
import { type ClassValue, clsx } from 'clsx';
|
import { type ClassValue, clsx } from 'clsx';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
|
import type { MessageInstance } from 'antd/es/message/interface';
|
||||||
|
import type { ModalStaticFunctions } from 'antd/es/modal/confirm';
|
||||||
|
import type { NotificationInstance } from 'antd/es/notification/interface';
|
||||||
|
|
||||||
|
let message: MessageInstance;
|
||||||
|
let notification: NotificationInstance;
|
||||||
|
let modal: Omit<ModalStaticFunctions, 'warn'>;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
get message() {
|
||||||
|
return message;
|
||||||
|
},
|
||||||
|
setMessage(instance: MessageInstance) {
|
||||||
|
message = instance;
|
||||||
|
},
|
||||||
|
get notification() {
|
||||||
|
return notification;
|
||||||
|
},
|
||||||
|
setNotification(instance: NotificationInstance) {
|
||||||
|
notification = instance;
|
||||||
|
},
|
||||||
|
get modal() {
|
||||||
|
return modal;
|
||||||
|
},
|
||||||
|
setModal(instance: Omit<ModalStaticFunctions, 'warn'>) {
|
||||||
|
modal = instance;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const TokenKey = 'Admin-Token'
|
const TokenKey = 'Admin-Token'
|
||||||
const TokenKeyAi = 'ai-Token'
|
const TokenKeyAi = 'ai-Token'
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import { RootState, useAppDispatch } from '../store';
|
|||||||
import { setUserInfo } from '../store/userSlice';
|
import { setUserInfo } from '../store/userSlice';
|
||||||
import { getUserProfile, updateUserProfile, updateUserPwd, uploadAvatar } from '../api/user';
|
import { getUserProfile, updateUserProfile, updateUserPwd, uploadAvatar } from '../api/user';
|
||||||
import envConfig from '../../env';
|
import envConfig from '../../env';
|
||||||
|
import utils from '../lib/utils';
|
||||||
|
|
||||||
const { TabPane } = Tabs;
|
const { TabPane } = Tabs;
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
@@ -42,6 +43,7 @@ const Profile: React.FC = () => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [pwdForm] = Form.useForm();
|
const [pwdForm] = Form.useForm();
|
||||||
|
const message = utils.message; // 使用全局 message
|
||||||
|
|
||||||
const fetchProfile = async () => {
|
const fetchProfile = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import { orderTypeConfig, sourceTypeMap } from '../constants';
|
|||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { RootState } from '../store';
|
import { RootState } from '../store';
|
||||||
import { getUser } from '../api/user';
|
import { getUser } from '../api/user';
|
||||||
|
import utils from '../lib/utils';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
@@ -92,7 +93,7 @@ const WorkOrderPage = () => {
|
|||||||
|
|
||||||
const [completeModalVisible, setCompleteModalVisible] = useState(false);
|
const [completeModalVisible, setCompleteModalVisible] = useState(false);
|
||||||
const [completeForm] = Form.useForm(); // 完成工单表单
|
const [completeForm] = Form.useForm(); // 完成工单表单
|
||||||
const [messageApi, contextHolder] = message.useMessage();
|
const messageApi = utils.message; // 使用全局 message
|
||||||
|
|
||||||
// 获取用户列表 (用于负责人选择)
|
// 获取用户列表 (用于负责人选择)
|
||||||
const fetchUserList = async () => {
|
const fetchUserList = async () => {
|
||||||
@@ -409,7 +410,6 @@ const WorkOrderPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: '0px 0px', background: '#f5f7fa', minHeight: '100vh', boxSizing: 'border-box' }}>
|
<div style={{ padding: '0px 0px', background: '#f5f7fa', minHeight: '100vh', boxSizing: 'border-box' }}>
|
||||||
{contextHolder}
|
|
||||||
<style>{`
|
<style>{`
|
||||||
.compact-table .ant-table-thead > tr > th { background: #f8fafc; padding: 2px 4px !important; font-size: 12px; color: #4E5969; }
|
.compact-table .ant-table-thead > tr > th { background: #f8fafc; padding: 2px 4px !important; font-size: 12px; color: #4E5969; }
|
||||||
.compact-table .ant-table-tbody > tr > td { padding: 2px 4px !important; font-size: 12px; }
|
.compact-table .ant-table-tbody > tr > td { padding: 2px 4px !important; font-size: 12px; }
|
||||||
|
|||||||
Reference in New Issue
Block a user