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 6161 "devDependencies" : {
6262 "@commitlint/cli" : " ^12.1.1" ,
6363 "@commitlint/config-conventional" : " ^12.1.1" ,
64+ "@td-design/pont-engine" : " 1.0.2" ,
6465 "@testing-library/jest-dom" : " ^5.11.10" ,
6566 "@testing-library/react" : " ^11.2.6" ,
6667 "@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 {
127127 const paramsCode = inter . getParamsCode ( ) ;
128128 const bodyParamsCode = inter . getBodyParamsCode ( ) ;
129129 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` ;
133131
134132 if ( ! hasGetParams ) {
135133 requestParams = bodyParamsCode ? `bodyParams: ${ bodyParamsCode } ` : '' ;
@@ -141,6 +139,7 @@ export default class MyGenerator extends CodeGenerator {
141139 export type Response = ${ inter . responseType }
142140
143141 export const init: Response;
142+ export const url: string;
144143
145144 export function fetch(${ requestParams } ): Promise<Response>;
146145 ` ;
@@ -179,7 +178,10 @@ export default class MyGenerator extends CodeGenerator {
179178
180179 const backEndUrl = serverConfig()['${ this . dataSource . name } '];
181180
181+ // 初始值
182182 export const init = ${ initValue } ;
183+ // 接口地址
184+ export const url = ${ inter . path } ;
183185
184186 export async function fetch(${ requestParams } ) {
185187 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 863863 dependencies :
864864 " @sinonjs/commons" " ^1.7.0"
865865
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+
866881" @testing-library/dom@^7.28.1 " :
867882 version "7.29.4"
868883 resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.29.4.tgz#1647c2b478789621ead7a50614ad81ab5ae5b86c"
@@ -9025,6 +9040,11 @@ typescript@^3.5.3:
90259040 resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
90269041 integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
90279042
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+
90289048typescript@^4.2.3 :
90299049 version "4.2.3"
90309050 resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
You can’t perform that action at this time.
0 commit comments