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
47 lines (39 loc) · 1019 Bytes
/
Copy pathindex.ts
File metadata and controls
47 lines (39 loc) · 1019 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { UseBoundStoreWithEqualityFn, createWithEqualityFn } from 'zustand/traditional';
import { devtools } from 'zustand/middleware';
import { shallow } from 'zustand/shallow';
import { StoreApi } from 'zustand';
// 表信息
export interface tableItem {
columnList: {
columnName?: string;
columnType?: string;
}[];
}
// schema信息
export interface schemaItem {
tableList?: tableItem[];
}
// 数据库信息
export type databaseItem = {
schemaList?: schemaItem[];
} | {
databaseName: string;
tableList: tableItem[];
}
// monaco store
export interface IMonacoStore {
registerProvider: {
// 数据源id
[key: number]: databaseItem[]
}
}
const initMonacoStore = {
registerProvider: {}
}
export const useMonacoStore: UseBoundStoreWithEqualityFn<StoreApi<IMonacoStore>> = createWithEqualityFn(
devtools(() => (initMonacoStore)),
shallow
);
export const setRegisterProvider = (id: number, data: databaseItem[]) => {
useMonacoStore.getState().registerProvider[id] = data;
}