2
0
Эх сурвалжийг харах

fix: playground request error in electron

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 2 долоо хоног өмнө
parent
commit
92bc7123be

+ 13 - 0
client/src/http/Milvus.service.ts

@@ -42,4 +42,17 @@ export class MilvusService extends BaseModel {
   static useDatabase(data: { database: string }) {
     return super.create({ path: `/milvus/usedb`, data });
   }
+
+  static request(data: PlaygroundRequestOptions) {
+    return super.create({ path: `/playground`, data });
+  }
 }
+
+type PlaygroundRequestOptions = {
+  url: string;
+  method?: string;
+  host?: string;
+  headers?: Record<string, string | undefined>;
+  params?: Record<string, string>;
+  body?: Record<string, any>;
+};

+ 4 - 3
client/src/pages/play/language/extensions/codelens.ts

@@ -5,7 +5,8 @@ import { EditorView, Decoration, DecorationSet } from '@codemirror/view';
 import { AxiosError } from 'axios';
 import { MILVUS_RESTFUL_DOC_URL, CLOUD_RESTFUL_DOC_URL } from '@/consts';
 import { CustomEventNameEnum, PlaygroundExtensionParams } from '../../Types';
-import { playgroundRequest, DocumentEventManager } from '../../utils';
+import { DocumentEventManager } from '../../utils';
+import { MilvusService } from '@/http';
 
 class CodeLensWidget extends WidgetType {
   constructor(
@@ -138,11 +139,11 @@ export const codeLensDecoration = (options: PlaygroundExtensionParams) =>
                     { loading: true, response: 'running' }
                   );
 
-                  const res = await playgroundRequest(params);
+                  const data = await MilvusService.request(params);
 
                   DocumentEventManager.dispatch(
                     CustomEventNameEnum.PlaygroundResponseDetail,
-                    { response: res.data, loading: false }
+                    { response: data, loading: false }
                   );
 
                   // if param body contains collectionName, dispatch PlaygroundCollectionUpdate event

+ 0 - 30
client/src/pages/play/utils/request.ts

@@ -1,30 +0,0 @@
-import axios from 'axios';
-
-type PlaygroundRequestOptions = {
-  url: string;
-  method?: string;
-  host?: string;
-  headers?: Record<string, string | undefined>;
-  params?: Record<string, string>;
-  body?: Record<string, any>;
-};
-
-export const playgroundRequest = (options: PlaygroundRequestOptions) => {
-  const {
-    url,
-    method = 'POST',
-    host = '',
-    headers = {},
-    body = {},
-    params = {},
-  } = options;
-
-  return axios.post('/api/v1/playground', {
-    host,
-    url,
-    headers,
-    method,
-    body,
-    params,
-  });
-};