File tree Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Original file line number Diff line number Diff line change 61
61
"devDependencies" : {
62
62
"@commitlint/cli" : " ^12.1.1" ,
63
63
"@commitlint/config-conventional" : " ^12.1.1" ,
64
+ "@td-design/pont-engine" : " 1.0.2" ,
64
65
"@testing-library/jest-dom" : " ^5.11.10" ,
65
66
"@testing-library/react" : " ^11.2.6" ,
66
67
"@testing-library/react-hooks" : " ^5.1.1" ,
Original file line number Diff line number Diff line change @@ -127,9 +127,7 @@ export default class MyGenerator extends CodeGenerator {
127
127
const paramsCode = inter . getParamsCode ( ) ;
128
128
const bodyParamsCode = inter . getBodyParamsCode ( ) ;
129
129
const hasGetParams = ! ! inter . parameters . filter ( param => param . in !== 'body' ) . length ;
130
- let requestParams = bodyParamsCode
131
- ? `bodyParams: ${ bodyParamsCode } , params: Params`
132
- : `params: Params` ;
130
+ let requestParams = bodyParamsCode ? `bodyParams: ${ bodyParamsCode } , params: Params` : `params: Params` ;
133
131
134
132
if ( ! hasGetParams ) {
135
133
requestParams = bodyParamsCode ? `bodyParams: ${ bodyParamsCode } ` : '' ;
@@ -141,6 +139,7 @@ export default class MyGenerator extends CodeGenerator {
141
139
export type Response = ${ inter . responseType }
142
140
143
141
export const init: Response;
142
+ export const url: string;
144
143
145
144
export function fetch(${ requestParams } ): Promise<Response>;
146
145
` ;
@@ -179,7 +178,10 @@ export default class MyGenerator extends CodeGenerator {
179
178
180
179
const backEndUrl = serverConfig()['${ this . dataSource . name } '];
181
180
181
+ // 初始值
182
182
export const init = ${ initValue } ;
183
+ // 接口地址
184
+ export const url = ${ inter . path } ;
183
185
184
186
export async function fetch(${ requestParams } ) {
185
187
const request = await initRequest();
Original file line number Diff line number Diff line change
1
+ import React , { createContext , useContext } from 'react' ;
2
+
3
+ /**
4
+ * 创建局部共享数据
5
+ * @param hooks 自定义hooks
6
+ * @returns
7
+ */
8
+ export function createLocalShare ( hooks : ( ...args : any [ ] ) => any ) {
9
+ const Context = createContext ( { } ) ;
10
+
11
+ const ModelProvider = ( { children } : { children ?: React . ReactNode } ) => (
12
+ < Context . Provider value = { hooks ( ) } > { children } </ Context . Provider >
13
+ ) ;
14
+
15
+ const useModel = ( ) => useContext ( Context ) ;
16
+ useModel . Provider = ModelProvider ;
17
+
18
+ return useModel ;
19
+ }
Original file line number Diff line number Diff line change 863
863
dependencies :
864
864
" @sinonjs/commons" " ^1.7.0"
865
865
866
+
867
+ version "1.0.2"
868
+ resolved "https://registry.yarnpkg.com/@td-design/pont-engine/-/pont-engine-1.0.2.tgz#d875c3c249dbd3426faa591fb9d7b0bb0648e7da"
869
+ integrity sha512-c7wNIjeD8JstZ2wODmeikoPkA510/hNhjGQpb8MUM51WF7vbXbxZLdPMgYCMsNVWZ+Kb3X+U4VeAclvx3I1aHw==
870
+ dependencies :
871
+ chalk "^2.3.0"
872
+ commander "^2.19.0"
873
+ fs-extra "^5.0.0"
874
+ inquirer "^7.1.0"
875
+ lodash "^4.17.5"
876
+ node-fetch "^1.7.3"
877
+ prettier "^1.19.1"
878
+ translation.js "^0.7.5"
879
+ typescript "^3.9.10"
880
+
866
881
" @testing-library/dom@^7.28.1 " :
867
882
version "7.29.4"
868
883
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.29.4.tgz#1647c2b478789621ead7a50614ad81ab5ae5b86c"
@@ -9025,6 +9040,11 @@ typescript@^3.5.3:
9025
9040
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
9026
9041
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
9027
9042
9043
+ typescript@^3.9.10 :
9044
+ version "3.9.10"
9045
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"
9046
+ integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==
9047
+
9028
9048
typescript@^4.2.3 :
9029
9049
version "4.2.3"
9030
9050
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
You can’t perform that action at this time.
0 commit comments