@fairys/taro-tools-react 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/context/page.data.instance.d.ts +16 -16
- package/esm/context/page.data.instance.js +1 -0
- package/esm/context/page.info.data.instance.d.ts +11 -11
- package/esm/context/page.info.data.instance.js +1 -0
- package/lib/context/index.js +2 -2
- package/lib/context/page.data.instance.d.ts +16 -16
- package/lib/context/page.data.instance.js +1 -0
- package/lib/context/page.info.data.instance.d.ts +11 -11
- package/lib/context/page.info.data.instance.js +1 -0
- package/package.json +1 -1
- package/src/context/page.data.instance.tsx +36 -25
- package/src/context/page.info.data.instance.tsx +33 -18
|
@@ -75,7 +75,7 @@ export declare class PageDataInstance<T extends PageDataInstanceState = PageData
|
|
|
75
75
|
/**默认值*/
|
|
76
76
|
defaultInital: T;
|
|
77
77
|
store: T;
|
|
78
|
-
ctor: (options?: PageDataOptions<T>) =>
|
|
78
|
+
ctor: (options?: PageDataOptions<T>) => this;
|
|
79
79
|
/**初始化状态值*/
|
|
80
80
|
main_page_store: (initalValues?: Partial<T>, file?: string[]) => this;
|
|
81
81
|
/**格式化请求参数*/
|
|
@@ -112,40 +112,40 @@ export interface PageDataOptions<T extends PageDataInstanceState = PageDataInsta
|
|
|
112
112
|
defaultPageSize?: number;
|
|
113
113
|
}
|
|
114
114
|
/**初始化实例*/
|
|
115
|
-
export declare function usePageDataInstance<T extends PageDataInstanceState = PageDataInstanceState
|
|
115
|
+
export declare function usePageDataInstance<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>(instance?: M): M;
|
|
116
116
|
/**页面级数据状态管理上下文*/
|
|
117
117
|
export declare const PageDataInstanceContext: import("react").Context<PageDataInstance<PageDataInstanceState>>;
|
|
118
118
|
/**获取上下文实例*/
|
|
119
|
-
export declare const usePageDataInstanceContext: <T extends PageDataInstanceState = PageDataInstanceState>() =>
|
|
120
|
-
export interface PageDataInstanceContextProviderProps<T extends PageDataInstanceState = PageDataInstanceState> extends PageDataOptions<T> {
|
|
121
|
-
instance?:
|
|
119
|
+
export declare const usePageDataInstanceContext: <T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>() => M;
|
|
120
|
+
export interface PageDataInstanceContextProviderProps<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>> extends PageDataOptions<T> {
|
|
121
|
+
instance?: M;
|
|
122
122
|
children: React.ReactNode;
|
|
123
123
|
/**请求之前处理参数*/
|
|
124
|
-
onBefore?:
|
|
124
|
+
onBefore?: M['onBefore'];
|
|
125
125
|
/**请求接口*/
|
|
126
|
-
getList?:
|
|
126
|
+
getList?: M['getList'];
|
|
127
127
|
/**请求之后处理返回值进行存储*/
|
|
128
|
-
onAfter?:
|
|
128
|
+
onAfter?: M['onAfter'];
|
|
129
129
|
/** 额外数据处理*/
|
|
130
|
-
onExtraData?:
|
|
130
|
+
onExtraData?: M['onExtraData'];
|
|
131
131
|
/** code!== 200 时 触发*/
|
|
132
|
-
onError?:
|
|
132
|
+
onError?: M['onError'];
|
|
133
133
|
/**获取弹框内重置参数*/
|
|
134
|
-
getResetValues?:
|
|
134
|
+
getResetValues?: M['getResetValues'];
|
|
135
135
|
/**默认查询参数*/
|
|
136
|
-
defaultQuery?:
|
|
136
|
+
defaultQuery?: M['defaultQuery'];
|
|
137
137
|
/**那些字段取值对象 code值*/
|
|
138
|
-
codeFields?:
|
|
138
|
+
codeFields?: M['codeFields'];
|
|
139
139
|
/**那些字段取值对象的 value 值 */
|
|
140
|
-
valueFields?:
|
|
140
|
+
valueFields?: M['valueFields'];
|
|
141
141
|
/**是否是第一次加载*/
|
|
142
142
|
isMountLoad?: boolean;
|
|
143
143
|
/**页面标题*/
|
|
144
144
|
title?: string;
|
|
145
145
|
}
|
|
146
146
|
/**页面级数据状态管理上下文提供者*/
|
|
147
|
-
export declare function PageDataInstanceContextProvider<T extends PageDataInstanceState = PageDataInstanceState>(props: PageDataInstanceContextProviderProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
147
|
+
export declare function PageDataInstanceContextProvider<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>(props: PageDataInstanceContextProviderProps<T, M>): import("react/jsx-runtime").JSX.Element;
|
|
148
148
|
/**
|
|
149
149
|
* 页面级数据状态管理
|
|
150
150
|
*/
|
|
151
|
-
export declare const usePageDataInstanceState: <T extends PageDataInstanceState = PageDataInstanceState>() => [T,
|
|
151
|
+
export declare const usePageDataInstanceState: <T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>() => [T, M, string | undefined];
|
|
@@ -44,6 +44,7 @@ class page_data_instance_PageDataInstance extends ProxyInstanceObjectBase {
|
|
|
44
44
|
this.store.tabItems = external_valtio_ref(options.tabItems);
|
|
45
45
|
this.store.isTabs = Array.isArray(options.tabItems) && options.tabItems.length > 0;
|
|
46
46
|
}
|
|
47
|
+
return this;
|
|
47
48
|
};
|
|
48
49
|
main_page_store = (initalValues = {}, file)=>{
|
|
49
50
|
const newStore = {
|
|
@@ -48,7 +48,7 @@ export declare class PageInfoDataInstance<T extends PageInfoDataInstanceState =
|
|
|
48
48
|
/**是否显示成功提示*/
|
|
49
49
|
isShowSuccessMessage?: boolean;
|
|
50
50
|
};
|
|
51
|
-
ctor(options?: PageInfoDataOptions<T>):
|
|
51
|
+
ctor(options?: PageInfoDataOptions<T>): this;
|
|
52
52
|
store: T;
|
|
53
53
|
/**初始化状态值*/
|
|
54
54
|
main_page_store: (initalValues?: Partial<T>, file?: string[]) => this;
|
|
@@ -59,35 +59,35 @@ export declare class PageInfoDataInstance<T extends PageInfoDataInstanceState =
|
|
|
59
59
|
/**保存数据*/
|
|
60
60
|
main_saveInfo: () => Promise<void>;
|
|
61
61
|
}
|
|
62
|
-
export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageInfoDataInstanceState> {
|
|
62
|
+
export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>> {
|
|
63
63
|
/**详情查询请求配置*/
|
|
64
|
-
requestInfoConfig?:
|
|
64
|
+
requestInfoConfig?: M['requestInfoConfig'];
|
|
65
65
|
/**详情保存请求配置*/
|
|
66
|
-
requestSaveInfoConfig?:
|
|
66
|
+
requestSaveInfoConfig?: M['requestSaveInfoConfig'];
|
|
67
67
|
/**初始值*/
|
|
68
68
|
initialValues?: Partial<T>;
|
|
69
69
|
/**editFormData是否使用valtio proxy 存储*/
|
|
70
70
|
isProxy?: boolean;
|
|
71
71
|
}
|
|
72
72
|
/**初始化实例*/
|
|
73
|
-
export declare const usePageInfoDataInstance: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState
|
|
73
|
+
export declare const usePageInfoDataInstance: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>(instance?: M) => M;
|
|
74
74
|
/**页面级数据状态管理上下文*/
|
|
75
75
|
export declare const PageInfoDataInstanceContext: import("react").Context<PageInfoDataInstance<PageInfoDataInstanceState>>;
|
|
76
76
|
/**获取上下文实例*/
|
|
77
|
-
export declare const usePageInfoDataInstanceContext: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState>() =>
|
|
78
|
-
export interface PageInfoDataInstanceContextProviderProps<T extends PageInfoDataInstanceState = PageInfoDataInstanceState> extends PageInfoDataOptions<T> {
|
|
79
|
-
instance?:
|
|
77
|
+
export declare const usePageInfoDataInstanceContext: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>() => M;
|
|
78
|
+
export interface PageInfoDataInstanceContextProviderProps<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>> extends PageInfoDataOptions<T, M> {
|
|
79
|
+
instance?: M;
|
|
80
80
|
children: React.ReactNode;
|
|
81
81
|
/**页面标题*/
|
|
82
82
|
title?: string;
|
|
83
83
|
/**页面一加载是否请求详情接口*/
|
|
84
84
|
isMountRequestInfo?: boolean;
|
|
85
85
|
/**自定义hooks,挂载参数和设置完初始值后执行*/
|
|
86
|
-
useHooks?: (instance:
|
|
86
|
+
useHooks?: (instance: M) => void;
|
|
87
87
|
}
|
|
88
88
|
/**页面级数据状态管理上下文提供者*/
|
|
89
|
-
export declare function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstanceState = PageInfoDataInstanceState>(props: PageInfoDataInstanceContextProviderProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
89
|
+
export declare function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>(props: PageInfoDataInstanceContextProviderProps<T, M>): import("react/jsx-runtime").JSX.Element;
|
|
90
90
|
/**
|
|
91
91
|
* 页面级数据状态管理
|
|
92
92
|
*/
|
|
93
|
-
export declare const usePageInfoDataInstanceState: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState>() => [T,
|
|
93
|
+
export declare const usePageInfoDataInstanceState: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>() => [T, M, string | undefined];
|
package/lib/context/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __webpack_modules__ = {
|
|
|
6
6
|
"./global.data.instance": function(module) {
|
|
7
7
|
module.exports = require("./global.data.instance.js");
|
|
8
8
|
},
|
|
9
|
-
"
|
|
9
|
+
"./global.setting.data.instance": function(module) {
|
|
10
10
|
module.exports = require("./global.setting.data.instance.js");
|
|
11
11
|
},
|
|
12
12
|
"./page.data.instance": function(module) {
|
|
@@ -83,7 +83,7 @@ var __webpack_exports__ = {};
|
|
|
83
83
|
return _auth_data_instance__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
84
84
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
85
85
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
86
|
-
var _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("
|
|
86
|
+
var _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./global.setting.data.instance");
|
|
87
87
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
88
88
|
for(var __WEBPACK_IMPORT_KEY__ in _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
89
89
|
return _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__[key];
|
|
@@ -75,7 +75,7 @@ export declare class PageDataInstance<T extends PageDataInstanceState = PageData
|
|
|
75
75
|
/**默认值*/
|
|
76
76
|
defaultInital: T;
|
|
77
77
|
store: T;
|
|
78
|
-
ctor: (options?: PageDataOptions<T>) =>
|
|
78
|
+
ctor: (options?: PageDataOptions<T>) => this;
|
|
79
79
|
/**初始化状态值*/
|
|
80
80
|
main_page_store: (initalValues?: Partial<T>, file?: string[]) => this;
|
|
81
81
|
/**格式化请求参数*/
|
|
@@ -112,40 +112,40 @@ export interface PageDataOptions<T extends PageDataInstanceState = PageDataInsta
|
|
|
112
112
|
defaultPageSize?: number;
|
|
113
113
|
}
|
|
114
114
|
/**初始化实例*/
|
|
115
|
-
export declare function usePageDataInstance<T extends PageDataInstanceState = PageDataInstanceState
|
|
115
|
+
export declare function usePageDataInstance<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>(instance?: M): M;
|
|
116
116
|
/**页面级数据状态管理上下文*/
|
|
117
117
|
export declare const PageDataInstanceContext: import("react").Context<PageDataInstance<PageDataInstanceState>>;
|
|
118
118
|
/**获取上下文实例*/
|
|
119
|
-
export declare const usePageDataInstanceContext: <T extends PageDataInstanceState = PageDataInstanceState>() =>
|
|
120
|
-
export interface PageDataInstanceContextProviderProps<T extends PageDataInstanceState = PageDataInstanceState> extends PageDataOptions<T> {
|
|
121
|
-
instance?:
|
|
119
|
+
export declare const usePageDataInstanceContext: <T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>() => M;
|
|
120
|
+
export interface PageDataInstanceContextProviderProps<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>> extends PageDataOptions<T> {
|
|
121
|
+
instance?: M;
|
|
122
122
|
children: React.ReactNode;
|
|
123
123
|
/**请求之前处理参数*/
|
|
124
|
-
onBefore?:
|
|
124
|
+
onBefore?: M['onBefore'];
|
|
125
125
|
/**请求接口*/
|
|
126
|
-
getList?:
|
|
126
|
+
getList?: M['getList'];
|
|
127
127
|
/**请求之后处理返回值进行存储*/
|
|
128
|
-
onAfter?:
|
|
128
|
+
onAfter?: M['onAfter'];
|
|
129
129
|
/** 额外数据处理*/
|
|
130
|
-
onExtraData?:
|
|
130
|
+
onExtraData?: M['onExtraData'];
|
|
131
131
|
/** code!== 200 时 触发*/
|
|
132
|
-
onError?:
|
|
132
|
+
onError?: M['onError'];
|
|
133
133
|
/**获取弹框内重置参数*/
|
|
134
|
-
getResetValues?:
|
|
134
|
+
getResetValues?: M['getResetValues'];
|
|
135
135
|
/**默认查询参数*/
|
|
136
|
-
defaultQuery?:
|
|
136
|
+
defaultQuery?: M['defaultQuery'];
|
|
137
137
|
/**那些字段取值对象 code值*/
|
|
138
|
-
codeFields?:
|
|
138
|
+
codeFields?: M['codeFields'];
|
|
139
139
|
/**那些字段取值对象的 value 值 */
|
|
140
|
-
valueFields?:
|
|
140
|
+
valueFields?: M['valueFields'];
|
|
141
141
|
/**是否是第一次加载*/
|
|
142
142
|
isMountLoad?: boolean;
|
|
143
143
|
/**页面标题*/
|
|
144
144
|
title?: string;
|
|
145
145
|
}
|
|
146
146
|
/**页面级数据状态管理上下文提供者*/
|
|
147
|
-
export declare function PageDataInstanceContextProvider<T extends PageDataInstanceState = PageDataInstanceState>(props: PageDataInstanceContextProviderProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
147
|
+
export declare function PageDataInstanceContextProvider<T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>(props: PageDataInstanceContextProviderProps<T, M>): import("react/jsx-runtime").JSX.Element;
|
|
148
148
|
/**
|
|
149
149
|
* 页面级数据状态管理
|
|
150
150
|
*/
|
|
151
|
-
export declare const usePageDataInstanceState: <T extends PageDataInstanceState = PageDataInstanceState>() => [T,
|
|
151
|
+
export declare const usePageDataInstanceState: <T extends PageDataInstanceState = PageDataInstanceState, M extends PageDataInstance<T> = PageDataInstance<T>>() => [T, M, string | undefined];
|
|
@@ -87,6 +87,7 @@ class page_data_instance_PageDataInstance extends instance_js_namespaceObject.Pr
|
|
|
87
87
|
this.store.tabItems = (0, external_valtio_namespaceObject.ref)(options.tabItems);
|
|
88
88
|
this.store.isTabs = Array.isArray(options.tabItems) && options.tabItems.length > 0;
|
|
89
89
|
}
|
|
90
|
+
return this;
|
|
90
91
|
};
|
|
91
92
|
main_page_store = (initalValues = {}, file)=>{
|
|
92
93
|
const newStore = {
|
|
@@ -48,7 +48,7 @@ export declare class PageInfoDataInstance<T extends PageInfoDataInstanceState =
|
|
|
48
48
|
/**是否显示成功提示*/
|
|
49
49
|
isShowSuccessMessage?: boolean;
|
|
50
50
|
};
|
|
51
|
-
ctor(options?: PageInfoDataOptions<T>):
|
|
51
|
+
ctor(options?: PageInfoDataOptions<T>): this;
|
|
52
52
|
store: T;
|
|
53
53
|
/**初始化状态值*/
|
|
54
54
|
main_page_store: (initalValues?: Partial<T>, file?: string[]) => this;
|
|
@@ -59,35 +59,35 @@ export declare class PageInfoDataInstance<T extends PageInfoDataInstanceState =
|
|
|
59
59
|
/**保存数据*/
|
|
60
60
|
main_saveInfo: () => Promise<void>;
|
|
61
61
|
}
|
|
62
|
-
export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageInfoDataInstanceState> {
|
|
62
|
+
export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>> {
|
|
63
63
|
/**详情查询请求配置*/
|
|
64
|
-
requestInfoConfig?:
|
|
64
|
+
requestInfoConfig?: M['requestInfoConfig'];
|
|
65
65
|
/**详情保存请求配置*/
|
|
66
|
-
requestSaveInfoConfig?:
|
|
66
|
+
requestSaveInfoConfig?: M['requestSaveInfoConfig'];
|
|
67
67
|
/**初始值*/
|
|
68
68
|
initialValues?: Partial<T>;
|
|
69
69
|
/**editFormData是否使用valtio proxy 存储*/
|
|
70
70
|
isProxy?: boolean;
|
|
71
71
|
}
|
|
72
72
|
/**初始化实例*/
|
|
73
|
-
export declare const usePageInfoDataInstance: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState
|
|
73
|
+
export declare const usePageInfoDataInstance: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>(instance?: M) => M;
|
|
74
74
|
/**页面级数据状态管理上下文*/
|
|
75
75
|
export declare const PageInfoDataInstanceContext: import("react").Context<PageInfoDataInstance<PageInfoDataInstanceState>>;
|
|
76
76
|
/**获取上下文实例*/
|
|
77
|
-
export declare const usePageInfoDataInstanceContext: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState>() =>
|
|
78
|
-
export interface PageInfoDataInstanceContextProviderProps<T extends PageInfoDataInstanceState = PageInfoDataInstanceState> extends PageInfoDataOptions<T> {
|
|
79
|
-
instance?:
|
|
77
|
+
export declare const usePageInfoDataInstanceContext: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>() => M;
|
|
78
|
+
export interface PageInfoDataInstanceContextProviderProps<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>> extends PageInfoDataOptions<T, M> {
|
|
79
|
+
instance?: M;
|
|
80
80
|
children: React.ReactNode;
|
|
81
81
|
/**页面标题*/
|
|
82
82
|
title?: string;
|
|
83
83
|
/**页面一加载是否请求详情接口*/
|
|
84
84
|
isMountRequestInfo?: boolean;
|
|
85
85
|
/**自定义hooks,挂载参数和设置完初始值后执行*/
|
|
86
|
-
useHooks?: (instance:
|
|
86
|
+
useHooks?: (instance: M) => void;
|
|
87
87
|
}
|
|
88
88
|
/**页面级数据状态管理上下文提供者*/
|
|
89
|
-
export declare function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstanceState = PageInfoDataInstanceState>(props: PageInfoDataInstanceContextProviderProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
89
|
+
export declare function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>(props: PageInfoDataInstanceContextProviderProps<T, M>): import("react/jsx-runtime").JSX.Element;
|
|
90
90
|
/**
|
|
91
91
|
* 页面级数据状态管理
|
|
92
92
|
*/
|
|
93
|
-
export declare const usePageInfoDataInstanceState: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState>() => [T,
|
|
93
|
+
export declare const usePageInfoDataInstanceState: <T extends PageInfoDataInstanceState = PageInfoDataInstanceState, M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>>() => [T, M, string | undefined];
|
|
@@ -74,6 +74,7 @@ class page_info_data_instance_PageInfoDataInstance extends instance_js_namespace
|
|
|
74
74
|
this.store.editFormData = {};
|
|
75
75
|
}
|
|
76
76
|
if (options?.initialValues) this.main_page_store(options.initialValues);
|
|
77
|
+
return this;
|
|
77
78
|
}
|
|
78
79
|
store = (0, external_valtio_namespaceObject.proxy)({
|
|
79
80
|
...this.defaultInital
|
package/package.json
CHANGED
|
@@ -117,6 +117,7 @@ export class PageDataInstance<
|
|
|
117
117
|
this.store.tabItems = ref(options.tabItems);
|
|
118
118
|
this.store.isTabs = Array.isArray(options.tabItems) && options.tabItems.length > 0;
|
|
119
119
|
}
|
|
120
|
+
return this;
|
|
120
121
|
};
|
|
121
122
|
/**初始化状态值*/
|
|
122
123
|
main_page_store = (initalValues: Partial<T> = {}, file?: string[]) => {
|
|
@@ -372,12 +373,13 @@ export interface PageDataOptions<T extends PageDataInstanceState = PageDataInsta
|
|
|
372
373
|
}
|
|
373
374
|
|
|
374
375
|
/**初始化实例*/
|
|
375
|
-
export function usePageDataInstance<
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
376
|
+
export function usePageDataInstance<
|
|
377
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
378
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
379
|
+
>(instance?: M) {
|
|
380
|
+
const ref = useRef<M>();
|
|
379
381
|
if (!ref.current) {
|
|
380
|
-
ref.current = instance || new PageDataInstance<T>();
|
|
382
|
+
ref.current = instance || (new PageDataInstance<T>() as M);
|
|
381
383
|
}
|
|
382
384
|
return ref.current;
|
|
383
385
|
}
|
|
@@ -386,33 +388,38 @@ export function usePageDataInstance<T extends PageDataInstanceState = PageDataIn
|
|
|
386
388
|
export const PageDataInstanceContext = createContext<PageDataInstance>(new PageDataInstance());
|
|
387
389
|
|
|
388
390
|
/**获取上下文实例*/
|
|
389
|
-
export const usePageDataInstanceContext = <
|
|
390
|
-
|
|
391
|
+
export const usePageDataInstanceContext = <
|
|
392
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
393
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
394
|
+
>() => {
|
|
395
|
+
const PageDataInstance = useContext(PageDataInstanceContext) as M;
|
|
391
396
|
return PageDataInstance;
|
|
392
397
|
};
|
|
393
398
|
|
|
394
|
-
export interface PageDataInstanceContextProviderProps<
|
|
395
|
-
extends
|
|
396
|
-
|
|
399
|
+
export interface PageDataInstanceContextProviderProps<
|
|
400
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
401
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
402
|
+
> extends PageDataOptions<T> {
|
|
403
|
+
instance?: M;
|
|
397
404
|
children: React.ReactNode;
|
|
398
405
|
/**请求之前处理参数*/
|
|
399
|
-
onBefore?:
|
|
406
|
+
onBefore?: M['onBefore'];
|
|
400
407
|
/**请求接口*/
|
|
401
|
-
getList?:
|
|
408
|
+
getList?: M['getList'];
|
|
402
409
|
/**请求之后处理返回值进行存储*/
|
|
403
|
-
onAfter?:
|
|
410
|
+
onAfter?: M['onAfter'];
|
|
404
411
|
/** 额外数据处理*/
|
|
405
|
-
onExtraData?:
|
|
412
|
+
onExtraData?: M['onExtraData'];
|
|
406
413
|
/** code!== 200 时 触发*/
|
|
407
|
-
onError?:
|
|
414
|
+
onError?: M['onError'];
|
|
408
415
|
/**获取弹框内重置参数*/
|
|
409
|
-
getResetValues?:
|
|
416
|
+
getResetValues?: M['getResetValues'];
|
|
410
417
|
/**默认查询参数*/
|
|
411
|
-
defaultQuery?:
|
|
418
|
+
defaultQuery?: M['defaultQuery'];
|
|
412
419
|
/**那些字段取值对象 code值*/
|
|
413
|
-
codeFields?:
|
|
420
|
+
codeFields?: M['codeFields'];
|
|
414
421
|
/**那些字段取值对象的 value 值 */
|
|
415
|
-
valueFields?:
|
|
422
|
+
valueFields?: M['valueFields'];
|
|
416
423
|
/**是否是第一次加载*/
|
|
417
424
|
isMountLoad?: boolean;
|
|
418
425
|
/**页面标题*/
|
|
@@ -420,9 +427,10 @@ export interface PageDataInstanceContextProviderProps<T extends PageDataInstance
|
|
|
420
427
|
}
|
|
421
428
|
|
|
422
429
|
/**页面级数据状态管理上下文提供者*/
|
|
423
|
-
export function PageDataInstanceContextProvider<
|
|
424
|
-
|
|
425
|
-
|
|
430
|
+
export function PageDataInstanceContextProvider<
|
|
431
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
432
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
433
|
+
>(props: PageDataInstanceContextProviderProps<T, M>) {
|
|
426
434
|
const {
|
|
427
435
|
instance,
|
|
428
436
|
children,
|
|
@@ -480,8 +488,11 @@ export function PageDataInstanceContextProvider<T extends PageDataInstanceState
|
|
|
480
488
|
/**
|
|
481
489
|
* 页面级数据状态管理
|
|
482
490
|
*/
|
|
483
|
-
export const usePageDataInstanceState = <
|
|
484
|
-
|
|
491
|
+
export const usePageDataInstanceState = <
|
|
492
|
+
T extends PageDataInstanceState = PageDataInstanceState,
|
|
493
|
+
M extends PageDataInstance<T> = PageDataInstance<T>,
|
|
494
|
+
>() => {
|
|
495
|
+
const PageMainDataInstance = usePageDataInstanceContext<T, M>();
|
|
485
496
|
const store = useSnapshot(PageMainDataInstance.store, { sync: true }) as T;
|
|
486
|
-
return [store, PageMainDataInstance, store.__defaultValue] as [T,
|
|
497
|
+
return [store, PageMainDataInstance, store.__defaultValue] as [T, M, string | undefined];
|
|
487
498
|
};
|
|
@@ -78,6 +78,7 @@ export class PageInfoDataInstance<
|
|
|
78
78
|
if (options?.initialValues) {
|
|
79
79
|
this.main_page_store(options.initialValues);
|
|
80
80
|
}
|
|
81
|
+
return this;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
store = proxy<T>({ ...this.defaultInital } as T);
|
|
@@ -175,11 +176,14 @@ export class PageInfoDataInstance<
|
|
|
175
176
|
};
|
|
176
177
|
}
|
|
177
178
|
|
|
178
|
-
export interface PageInfoDataOptions<
|
|
179
|
+
export interface PageInfoDataOptions<
|
|
180
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
181
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
182
|
+
> {
|
|
179
183
|
/**详情查询请求配置*/
|
|
180
|
-
requestInfoConfig?:
|
|
184
|
+
requestInfoConfig?: M['requestInfoConfig'];
|
|
181
185
|
/**详情保存请求配置*/
|
|
182
|
-
requestSaveInfoConfig?:
|
|
186
|
+
requestSaveInfoConfig?: M['requestSaveInfoConfig'];
|
|
183
187
|
/**初始值*/
|
|
184
188
|
initialValues?: Partial<T>;
|
|
185
189
|
/**editFormData是否使用valtio proxy 存储*/
|
|
@@ -187,15 +191,18 @@ export interface PageInfoDataOptions<T extends PageInfoDataInstanceState = PageI
|
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
/**初始化实例*/
|
|
190
|
-
export const usePageInfoDataInstance = <
|
|
191
|
-
|
|
194
|
+
export const usePageInfoDataInstance = <
|
|
195
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
196
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
197
|
+
>(
|
|
198
|
+
instance?: M,
|
|
192
199
|
) => {
|
|
193
|
-
const ref = useRef<
|
|
200
|
+
const ref = useRef<M>();
|
|
194
201
|
if (!ref.current) {
|
|
195
202
|
if (instance) {
|
|
196
203
|
ref.current = instance;
|
|
197
204
|
} else {
|
|
198
|
-
ref.current = new PageInfoDataInstance<T>();
|
|
205
|
+
ref.current = new PageInfoDataInstance<T>() as M;
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
208
|
return ref.current;
|
|
@@ -205,28 +212,33 @@ export const usePageInfoDataInstance = <T extends PageInfoDataInstanceState = Pa
|
|
|
205
212
|
export const PageInfoDataInstanceContext = createContext<PageInfoDataInstance>(new PageInfoDataInstance());
|
|
206
213
|
|
|
207
214
|
/**获取上下文实例*/
|
|
208
|
-
export const usePageInfoDataInstanceContext = <
|
|
209
|
-
|
|
215
|
+
export const usePageInfoDataInstanceContext = <
|
|
216
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
217
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
218
|
+
>() => {
|
|
219
|
+
const PageInfoDataInstance = useContext(PageInfoDataInstanceContext) as M;
|
|
210
220
|
return PageInfoDataInstance;
|
|
211
221
|
};
|
|
212
222
|
|
|
213
223
|
export interface PageInfoDataInstanceContextProviderProps<
|
|
214
224
|
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
226
|
+
> extends PageInfoDataOptions<T, M> {
|
|
227
|
+
instance?: M;
|
|
217
228
|
children: React.ReactNode;
|
|
218
229
|
/**页面标题*/
|
|
219
230
|
title?: string;
|
|
220
231
|
/**页面一加载是否请求详情接口*/
|
|
221
232
|
isMountRequestInfo?: boolean;
|
|
222
233
|
/**自定义hooks,挂载参数和设置完初始值后执行*/
|
|
223
|
-
useHooks?: (instance:
|
|
234
|
+
useHooks?: (instance: M) => void;
|
|
224
235
|
}
|
|
225
236
|
|
|
226
237
|
/**页面级数据状态管理上下文提供者*/
|
|
227
|
-
export function PageInfoDataInstanceContextProvider<
|
|
228
|
-
|
|
229
|
-
|
|
238
|
+
export function PageInfoDataInstanceContextProvider<
|
|
239
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
240
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
241
|
+
>(props: PageInfoDataInstanceContextProviderProps<T, M>) {
|
|
230
242
|
const {
|
|
231
243
|
instance,
|
|
232
244
|
children,
|
|
@@ -267,8 +279,11 @@ export function PageInfoDataInstanceContextProvider<T extends PageInfoDataInstan
|
|
|
267
279
|
/**
|
|
268
280
|
* 页面级数据状态管理
|
|
269
281
|
*/
|
|
270
|
-
export const usePageInfoDataInstanceState = <
|
|
271
|
-
|
|
282
|
+
export const usePageInfoDataInstanceState = <
|
|
283
|
+
T extends PageInfoDataInstanceState = PageInfoDataInstanceState,
|
|
284
|
+
M extends PageInfoDataInstance<T> = PageInfoDataInstance<T>,
|
|
285
|
+
>() => {
|
|
286
|
+
const PageInfoDataInstance = usePageInfoDataInstanceContext<T, M>();
|
|
272
287
|
const store = useSnapshot(PageInfoDataInstance.store, { sync: true }) as T;
|
|
273
|
-
return [store, PageInfoDataInstance, store.__defaultValue] as [T,
|
|
288
|
+
return [store, PageInfoDataInstance, store.__defaultValue] as [T, M, string | undefined];
|
|
274
289
|
};
|