Prechádzať zdrojové kódy

优化多项目接口同时生成,采用延时处理

zhontai 2 rokov pred
rodič
commit
1c7e8701b1
1 zmenil súbory, kde vykonal 25 pridanie a 23 odobranie
  1. 25 23
      gen/gen-admin-api.js

+ 25 - 23
gen/gen-admin-api.js

@@ -9,29 +9,31 @@ const apis = [
   },
 ]
 
-apis?.forEach((api) => {
-  generateApi({
-    output: api.output,
-    templates: path.resolve(__dirname, './templates'),
-    url: api.url,
-    httpClientType: 'axios',
-    modular: true,
-    cleanOutput: true,
-    moduleNameIndex: 2, // 0 api, 1 api htt-client data-contracts, 2 apis htt-client data-contracts
-    moduleNameFirstTag: true, //apis htt-client data-contracts
-    unwrapResponseData: true,
-    generateUnionEnums: true,
-    defaultResponseType: 'AxiosResponse',
-    // hooks: {
-    //   onFormatTypeName: (typeName, rawTypeName, schemaType) => {
+apis?.forEach((api, index) => {
+  setTimeout(() => {
+    generateApi({
+      output: api.output,
+      templates: path.resolve(__dirname, './templates'),
+      url: api.url,
+      httpClientType: 'axios',
+      modular: true,
+      cleanOutput: true,
+      moduleNameIndex: 2, // 0 api, 1 api htt-client data-contracts, 2 apis htt-client data-contracts
+      moduleNameFirstTag: true, //apis htt-client data-contracts
+      unwrapResponseData: true,
+      generateUnionEnums: true,
+      defaultResponseType: 'AxiosResponse',
+      // hooks: {
+      //   onFormatTypeName: (typeName, rawTypeName, schemaType) => {
 
-    //   },
-    // }
-  })
-    .then((r) => {
-      // files.forEach(({ content, name }) => {
-      //   fs.writeFile(path, content);
-      // });
+      //   },
+      // }
     })
-    .catch((e) => console.error(e))
+      .then((r) => {
+        // files.forEach(({ content, name }) => {
+        //   fs.writeFile(path, content);
+        // });
+      })
+      .catch((e) => console.error(e))
+  }, index * 1500)
 })