feat: jsparse, add crypto lib & feat: jsparse, jscode tooptip & fix: workflow, json parse, CodeMirror (#1306)
Reviewed-on: https://git.daoyoucloud.com:8443/daoyoucloud/tachybase/pulls/1306
This commit is contained in:
		
							parent
							
								
									f6dd7fbccb
								
							
						
					
					
						commit
						e1eee17965
					
				@ -27,6 +27,9 @@ export class JSParseInstruction extends Instruction {
 | 
				
			|||||||
      type: 'string',
 | 
					      type: 'string',
 | 
				
			||||||
      title: tval('JSCode expression'),
 | 
					      title: tval('JSCode expression'),
 | 
				
			||||||
      'x-decorator': 'FormItem',
 | 
					      'x-decorator': 'FormItem',
 | 
				
			||||||
 | 
					      'x-decorator-props': {
 | 
				
			||||||
 | 
					        tooltip: 'ctx.data\nctx.body\n__ctx\nlib.JSON\nlib.qrcode\ncanvas\nlib.dayjs\nlib.log',
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
      'x-component': 'CodeMirror',
 | 
					      'x-component': 'CodeMirror',
 | 
				
			||||||
      required: true,
 | 
					      required: true,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
				
			|||||||
@ -27,7 +27,7 @@ export class JSONParseInstruction extends Instruction {
 | 
				
			|||||||
      type: 'string',
 | 
					      type: 'string',
 | 
				
			||||||
      title: tval('Query expression'),
 | 
					      title: tval('Query expression'),
 | 
				
			||||||
      'x-decorator': 'FormItem',
 | 
					      'x-decorator': 'FormItem',
 | 
				
			||||||
      'x-component': 'Input.TextArea',
 | 
					      'x-component': 'CodeMirror',
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    model: {
 | 
					    model: {
 | 
				
			||||||
      type: 'array',
 | 
					      type: 'array',
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					import crypto from 'crypto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import * as canvas from 'canvas';
 | 
					import * as canvas from 'canvas';
 | 
				
			||||||
import _ from 'lodash';
 | 
					import _ from 'lodash';
 | 
				
			||||||
import qrcode from 'qrcode';
 | 
					import qrcode from 'qrcode';
 | 
				
			||||||
@ -19,6 +21,7 @@ export class JSParseInstruction extends Instruction {
 | 
				
			|||||||
          JSON,
 | 
					          JSON,
 | 
				
			||||||
          canvas,
 | 
					          canvas,
 | 
				
			||||||
          qrcode,
 | 
					          qrcode,
 | 
				
			||||||
 | 
					          crypto,
 | 
				
			||||||
          log: console.log,
 | 
					          log: console.log,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
@ -62,7 +65,7 @@ function mapModel(data, model) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function evalSimulate(jsCode, { ctx, lib }) {
 | 
					async function evalSimulate(jsCode, { ctx, lib }) {
 | 
				
			||||||
  const AsyncFunction = async function () {}.constructor;
 | 
					  const AsyncFunction: any = async function () {}.constructor;
 | 
				
			||||||
  return await new AsyncFunction('$root', `with($root) { ${jsCode}; }`)({
 | 
					  return await new AsyncFunction('$root', `with($root) { ${jsCode}; }`)({
 | 
				
			||||||
    ctx,
 | 
					    ctx,
 | 
				
			||||||
    // 允许用户覆盖,这个时候可以使用 _ctx
 | 
					    // 允许用户覆盖,这个时候可以使用 _ctx
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user