-
Notifications
You must be signed in to change notification settings - Fork 318
Expand file tree
/
Copy pathcommon-data.tsx
More file actions
59 lines (48 loc) · 1.34 KB
/
common-data.tsx
File metadata and controls
59 lines (48 loc) · 1.34 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
import { createContext, useContext } from 'react';
import type {
DomainGitIdentity,
DomainHost,
DomainImage,
DomainModel,
DomainProject,
DomainProjectTask,
DomainUser,
DomainVirtualMachine,
} from '@/api/Api';
export type CommonData = {
user: DomainUser;
reloadUser: () => void;
hosts: DomainHost[];
vms: DomainVirtualMachine[];
loadingHosts: boolean;
hostsInited: boolean;
reloadHosts: () => void;
models: DomainModel[];
loadingModels: boolean;
reloadModels: () => void;
images: DomainImage[];
loadingImages: boolean;
reloadImages: () => void;
identities: DomainGitIdentity[];
loadingIdentities: boolean;
reloadIdentities: () => void;
balance: number;
bonus: number;
reloadWallet: () => void;
members: DomainUser[];
loadingMembers: boolean;
reloadMembers: () => void;
projects: DomainProject[];
loadingProjects: boolean;
reloadProjects: () => void;
/** 未关联项目的任务(quick_start),用于侧边栏「默认」分组展示 */
unlinkedTasks: DomainProjectTask[];
loadingUnlinkedTasks: boolean;
reloadUnlinkedTasks: () => void;
};
export const DataContext = createContext<CommonData | null>(null);
export const useCommonData = () => {
const ctx = useContext(DataContext);
if (!ctx) throw new Error('useCommonData must be used within DataProvider');
return ctx;
};