liuxiran commented on a change in pull request #1240:
URL: https://github.com/apache/apisix-dashboard/pull/1240#discussion_r557013155



##########
File path: web/src/pages/Route/List.tsx
##########
@@ -63,6 +104,84 @@ const Page: React.FC = () => {
     });
   };
 
+  const handleExport = (exportFileType: number) => {
+    exportRoutes(selectedRowKeys.join(',')).then((resp) => {
+      let exportFile: string;
+      let exportFileName = 
`APISIX_routes_${moment().format('YYYYMMDDHHmmss')}`;
+
+      switch (exportFileType) {
+        case ExportFileType.YAML:
+          exportFile = yaml.dump(resp.data);
+          exportFileName = `${exportFileName}.yaml`;
+          break;
+        case ExportFileType.JSON:
+        default:
+          exportFile = js_beautify(JSON.stringify(resp.data), {
+            indent_size: 2,
+          });
+          exportFileName = `${exportFileName}.json`;
+          break;
+      }
+
+      const blob = new Blob([exportFile], {
+        type: EXPORT_FILE_MIME_TYPE_SUPPORTED[exportFileType],
+      });
+      const aLink = document.createElement('a');

Review comment:
       > Please take a look at `file-saver` if it's helpful
   > 
   > https://github.com/eligrey/FileSaver.js
   
   so cool~! it would be better than native approach, let me updated ASAP, 
thanks a lot  @juzhiyuan 
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to