@ywfe/fe-tools 1.2.1-beta.32 → 1.2.1-beta.34

Sign up to get free protection for your applications and to get access to all the features.
package/JSON2String.ts CHANGED
@@ -4,14 +4,11 @@ interface Input {
4
4
  // Ctrl-S保存代码
5
5
  function JSON2String({input}: { input: Input }){
6
6
  const { data } = input;
7
- const result:{content: string} = {content:''};
8
7
  try {
9
8
  const str = JSON.stringify(data);
10
- result.content = '```json' + str + 'json```';
11
- return result;
9
+ return '```json' + str + 'json```'
12
10
  } catch (error) {
13
- result.content = '```json' + '{}' + 'json```';
14
- return result;
11
+ return '```json' + '{}' + 'json```'
15
12
  }
16
13
  }
17
14
  export default JSON2String
@@ -3,7 +3,5 @@ interface Input {
3
3
  }
4
4
  declare function JSON2String({ input }: {
5
5
  input: Input;
6
- }): {
7
- content: string;
8
- };
6
+ }): string;
9
7
  export default JSON2String;
@@ -4,5 +4,9 @@ interface userInput {
4
4
  }
5
5
  declare function userInputToJson({ input }: {
6
6
  input: userInput;
7
- }): Promise<any>;
7
+ }): Promise<{
8
+ message: string;
9
+ success: boolean;
10
+ data: any;
11
+ }>;
8
12
  export default userInputToJson;
@@ -8728,6 +8728,7 @@ function request(_a) {
8728
8728
  };
8729
8729
  prefix = getBasePath();
8730
8730
  requestUrl = isValidURL(input.url) ? input.url : "".concat(prefix).concat(input.url);
8731
+ console.log('requestUrl', requestUrl, isValidURL(input.url));
8731
8732
  fetchOption = {
8732
8733
  method: method,
8733
8734
  headers: {
@@ -8746,13 +8747,11 @@ function request(_a) {
8746
8747
  response = _c.sent();
8747
8748
  if (!response.ok) {
8748
8749
  message = "An error has occured: ".concat(response.status);
8749
- console.log('req result', message);
8750
8750
  return [2 /*return*/, { success: false, message: message }];
8751
8751
  }
8752
8752
  return [4 /*yield*/, response.json()];
8753
8753
  case 2:
8754
8754
  result = _c.sent();
8755
- console.log('req result', result);
8756
8755
  return [2 /*return*/, result];
8757
8756
  }
8758
8757
  });
@@ -8761,28 +8760,21 @@ function request(_a) {
8761
8760
 
8762
8761
  function userInputToJson(_a) {
8763
8762
  return __awaiter(this, arguments, void 0, function (_b) {
8764
- var res, result;
8763
+ var res;
8765
8764
  var input = _b.input;
8766
8765
  return __generator(this, function (_c) {
8767
8766
  switch (_c.label) {
8768
- case 0:
8769
- console.log("input", input);
8770
- return [4 /*yield*/, request({
8771
- input: {
8772
- url: "https://fc-typechat.ywwl.com/userInputToJson",
8773
- method: "GET",
8774
- params: input,
8775
- },
8776
- })];
8767
+ case 0: return [4 /*yield*/, request({
8768
+ input: {
8769
+ url: "https://fc-typechat.ywwl.com/userInputToJson",
8770
+ method: "GET",
8771
+ params: input,
8772
+ },
8773
+ })];
8777
8774
  case 1:
8778
8775
  res = _c.sent();
8779
- if (res.success) {
8780
- result = res.data;
8781
- return [2 /*return*/, result.success ? result.data : result];
8782
- }
8783
- else {
8784
- return [2 /*return*/, res.success ? res.data : res];
8785
- }
8776
+ console.log('userINput1', res);
8777
+ return [2 /*return*/, res];
8786
8778
  }
8787
8779
  });
8788
8780
  });
@@ -8792,15 +8784,12 @@ function userInputToJson(_a) {
8792
8784
  function JSON2String(_a) {
8793
8785
  var input = _a.input;
8794
8786
  var data = input.data;
8795
- var result = { content: '' };
8796
8787
  try {
8797
8788
  var str = JSON.stringify(data);
8798
- result.content = '```json' + str + 'json```';
8799
- return result;
8789
+ return '```json' + str + 'json```';
8800
8790
  }
8801
8791
  catch (error) {
8802
- result.content = '```json' + '{}' + 'json```';
8803
- return result;
8792
+ return '```json' + '{}' + 'json```';
8804
8793
  }
8805
8794
  }
8806
8795