返回 AiToEarn
commont.ts
1 import { create } from 'zustand';
2 import { combine } from 'zustand/middleware';
3 import { NotificationInstance } from 'antd/es/notification/interface';
4
5 export interface ICommontStore {
6 // 全局通知api
7 notification?: NotificationInstance;
8 }
9
10 const store: ICommontStore = {
11 notification: undefined,
12 };
13
14 // 项目中的通用的、全局的状态和方法
15 export const useCommontStore = create(
16 combine(
17 {
18 ...store,
19 },
20 (set, get, storeApi) => {
21 const methods = {
22 setNotification(notification: NotificationInstance) {
23 set({
24 notification,
25 });
26 },
27 };
28 return methods;
29 },
30 ),
31 );
32
32 lines TYPESCRIPT