forked from OtterMind/Chat2DB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
29 lines (24 loc) · 655 Bytes
/
Copy pathindex.ts
File metadata and controls
29 lines (24 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { StoreApi } from 'zustand';
import { UseBoundStoreWithEqualityFn, createWithEqualityFn } from 'zustand/traditional';
import { devtools } from 'zustand/middleware';
import { shallow } from 'zustand/shallow';
export interface IConfigStore {
curRoute: string;
}
const initConfigStore: IConfigStore = {
curRoute: '/',
};
/**
* 配置 store
*/
export const useConfigStore: UseBoundStoreWithEqualityFn<StoreApi<IConfigStore>> = createWithEqualityFn(
devtools(() => initConfigStore),
shallow,
);
/**
*
* @param curRoute 设置当前路由
*/
export const setCurRoute = (curRoute: string) => {
useConfigStore.setState({ curRoute });
}