Commit 9da4b276 authored by rockyl's avatar rockyl

data类型修改为dynamic

增加map类型
parent 177a5a79
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"false" "false"
], ],
"id": "compare", "id": "compare",
"script": "var leftValue = typeof props.left === 'string' ? '\"' + props.left + '\"' : props.left;\nvar rightValue = typeof props.right === 'string' ? '\"' + props.right + '\"' : props.right;\nvar operator = (args ? args.operator : props.operator) || '==';\nif (operator === '==' || operator === '!=') {\n operator += '=';\n}\nvar func = new Function('return ' + leftValue + operator + rightValue);\nvar result = func();\nnext(result ? 'true' : 'false');\n", "script": "var leftValue = typeof props.left === 'string' ? '\"' + props.left + '\"' : props.left;\nvar rightValue = typeof props.right === 'string' ? '\"' + props.right + '\"' : props.right;\nvar operator = props.operator;\nvar func = new Function('return ' + leftValue + operator + rightValue);\nvar result = func();\nnext(result ? 'true' : 'false');\n",
"group": "base", "group": "base",
"type": "builtin" "type": "builtin"
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"success" "success"
], ],
"id": "entry", "id": "entry",
"script": "next('success');\n", "script": "next('success', args);\n",
"group": "base", "group": "base",
"type": "builtin" "type": "builtin"
} }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"success" "success"
], ],
"id": "log", "id": "log",
"script": "console.log(props ? props.content : (args ? args.content : ''));\nnext('success');\n", "script": "console.log(props ? props.content : (args ? args.content : ''));\nnext('success', args);\n",
"group": "base", "group": "base",
"type": "builtin" "type": "builtin"
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"success" "success"
], ],
"id": "turntable-start", "id": "turntable-start",
"script": "var key = 'state-' + vm.id;\nglobal[key] = true;\nengine.Tween.get(props.target)\n .set({ rotation: 0 })\n .to({ rotation: 360 }, props.duration, engine.Ease.quintIn)\n .call(function () {\n next('success');\n playLoop();\n});\nfunction playLoop() {\n var goon = global[key];\n if (goon) {\n engine.Tween.get(props.target)\n .set({ rotation: 0 })\n .to({ rotation: 360 }, props.duration / 4)\n .call(function () {\n engine.globalEvent.dispatchEvent('loop-end');\n playLoop();\n });\n }\n}\n", "script": "var key = 'state-' + vm.id;\nglobal[key] = true;\nengine.Tween.get(props.target)\n .set({ rotation: 0 })\n .to({ rotation: 360 }, props.duration, engine.Ease.quintIn)\n .call(function () {\n next('success', args);\n playLoop();\n});\nfunction playLoop() {\n var goon = global[key];\n if (goon) {\n engine.Tween.get(props.target)\n .set({ rotation: 0 })\n .to({ rotation: 360 }, props.duration / 4)\n .call(function () {\n engine.globalEvent.dispatchEvent('loop-end');\n playLoop();\n });\n }\n}\n",
"group": "custom", "group": "custom",
"type": "builtin" "type": "builtin"
} }
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
"success" "success"
], ],
"id": "turntable-stop", "id": "turntable-stop",
"script": "if (args && args.hasOwnProperty('index')) {\n var key = 'state-' + vm.id;\n var index = args.index;\n var per = 360 / props.divid;\n var ratio = per * props.ratio;\n var rotation_1 = 360 * 3 - index * per + Math.random() * ratio + (per - ratio) / 2;\n delete global[key];\n engine.globalEvent.once('loop-end', function () {\n engine.Tween.get(props.target || target)\n .to({ rotation: rotation_1 }, props.duration, engine.Ease.quintOut)\n .call(function () {\n next('success');\n });\n });\n}\nelse {\n engine.Tween.removeTweens(props.target || target);\n next('success');\n}\n", "script": "if (args && args.hasOwnProperty('index')) {\n var key = 'state-' + vm.id;\n var index = args.index;\n var per = 360 / props.divid;\n var ratio = per * props.ratio;\n var rotation_1 = 360 * 3 - index * per + Math.random() * ratio + (per - ratio) / 2;\n delete global[key];\n engine.globalEvent.once('loop-end', function () {\n engine.Tween.get(props.target || target)\n .to({ rotation: rotation_1 }, props.duration, engine.Ease.quintOut)\n .call(function () {\n next('success', args);\n });\n });\n}\nelse {\n engine.Tween.removeTweens(props.target || target);\n next('success', args);\n}\n",
"group": "custom", "group": "custom",
"type": "builtin" "type": "builtin"
} }
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
"name": { "name": {
"type": "string", "type": "string",
"alias": "数据名" "alias": "数据名"
},
"params": {
"type": "map",
"alias": "参数"
} }
}, },
"output": [ "output": [
...@@ -180,7 +184,7 @@ ...@@ -180,7 +184,7 @@
} }
], ],
"id": "duiba-api", "id": "duiba-api",
"script": "next('success');\n", "script": "next('success', args);\n",
"group": "duiba", "group": "duiba",
"type": "builtin" "type": "builtin"
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"success" "success"
], ],
"id": "goto-record", "id": "goto-record",
"script": "location.href = '/record';\nnext('success');\n", "script": "location.href = '/record';\nnext('success', args);\n",
"group": "duiba", "group": "duiba",
"type": "builtin" "type": "builtin"
} }
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
"props": { "props": {
"url": { "url": {
"type": "string", "type": "string",
"enum": [],
"alias": "链接" "alias": "链接"
}, },
"method": { "method": {
...@@ -17,30 +16,29 @@ ...@@ -17,30 +16,29 @@
}, },
"count": { "count": {
"type": "number", "type": "number",
"enum": [],
"alias": "次数", "alias": "次数",
"default": 10 "default": 10
}, },
"delay": { "delay": {
"type": "number", "type": "number",
"enum": [],
"default": 500, "default": 500,
"alias": "单次延时" "alias": "单次延时"
}, },
"name": { "name": {
"type": "string", "type": "string",
"enum": [],
"alias": "数据名" "alias": "数据名"
}, },
"field": { "field": {
"type": "string", "type": "string",
"enum": [],
"alias": "字段名" "alias": "字段名"
}, },
"successValues": { "successValues": {
"type": "string", "type": "string",
"enum": [],
"alias": "成功值" "alias": "成功值"
},
"params": {
"type": "map",
"alias": "参数"
} }
}, },
"output": [ "output": [
...@@ -238,7 +236,6 @@ ...@@ -238,7 +236,6 @@
} }
], ],
"id": "http-polling", "id": "http-polling",
"script": "",
"group": "net", "group": "net",
"type": "builtin" "type": "builtin"
} }
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
], ],
"alias": "方法", "alias": "方法",
"default": "get" "default": "get"
},
"params": {
"type": "map",
"alias": "参数"
} }
}, },
"output": [ "output": [
...@@ -22,7 +26,7 @@ ...@@ -22,7 +26,7 @@
"exception" "exception"
], ],
"id": "http-request", "id": "http-request",
"script": "if (!props.url) {\n console.log('url is empty');\n next('exception', '\\'url is empty\\'');\n}\nelse {\n engine.httpRequest(function (s, payload) {\n if (s) {\n next('success', payload);\n }\n else {\n next('failed', payload);\n }\n }, props.url, props.method, {}, 'json');\n}\n", "script": "var url = engine.findVariable('url', args, props);\nvar params = engine.findVariable('params', args, props);\nif (!url) {\n console.log('url is empty');\n next('exception', '\\'url is empty\\'');\n}\nelse {\n engine.httpRequest(function (s, payload) {\n if (s) {\n next('success', payload);\n }\n else {\n next('failed', payload);\n }\n }, url, props.method, params, 'json');\n}\n",
"group": "net", "group": "net",
"type": "builtin" "type": "builtin"
} }
{
"props": {
"host": {
"type": "string",
"alias": "接口根"
},
"uri": {
"type": "string",
"alias": "URI"
},
"method": {
"type": "enum",
"enum": [
"get",
"post"
],
"alias": "方法"
},
"dataName": {
"type": "string",
"alias": "数据名"
},
"params": {
"type": "map",
"alias": "参数"
}
},
"name": "api请求",
"output": [
"success",
"failed",
"exception"
],
"sub": {
"e6a9f1de-40c6-445b-b5e9-5c50a904a4de": {
"uuid": "e6a9f1de-40c6-445b-b5e9-5c50a904a4de",
"meta": "entry",
"design": {
"x": 10,
"y": 10,
"input": {},
"output": {
"success": [
{
"x": 124.5,
"y": 31
}
]
}
},
"props": {},
"output": {
"success": [
"567169ba-a2c1-4c10-9025-605a2e89ef0f"
]
}
},
"567169ba-a2c1-4c10-9025-605a2e89ef0f": {
"uuid": "567169ba-a2c1-4c10-9025-605a2e89ef0f",
"meta": "a4b27753-4cbb-47e3-9b31-51ced475e41a",
"design": {
"x": 151,
"y": 115,
"input": {
"default": [
{
"x": 5.5,
"y": 47.5
}
]
},
"output": {
"success": [
{
"x": 124.5,
"y": 47.5
}
]
}
},
"props": {
"host": {
"type": "link"
},
"uri": {
"type": "link"
}
},
"output": {
"success": [
"f9a32b46-aec1-4bd2-9b98-3d9a427d87db"
]
}
},
"f9a32b46-aec1-4bd2-9b98-3d9a427d87db": {
"uuid": "f9a32b46-aec1-4bd2-9b98-3d9a427d87db",
"meta": "duiba-api",
"design": {
"x": 350,
"y": 188,
"input": {
"default": [
{
"x": 5.5,
"y": 56
}
]
},
"output": {
"success": [
{
"x": 124.5,
"y": 49
}
],
"failed": [
{
"x": 124.5,
"y": 63
}
]
}
},
"props": {
"method": {
"type": "link"
},
"name": {
"type": "link",
"alias": "dataName"
}
},
"output": {}
}
},
"subEntry": "e6a9f1de-40c6-445b-b5e9-5c50a904a4de",
"metas": [
{
"id": "a4b27753-4cbb-47e3-9b31-51ced475e41a",
"script": "var host = engine.findVariable('host', args, props);\nvar uri = engine.findVariable('uri', args, props);\nnext('success', {url: engine.joinPath(host, uri)});",
"props": {
"host": {
"type": "string",
"alias": "接口根"
},
"uri": {
"type": "string",
"alias": "URI"
}
},
"isInline": true,
"name": "url拼接",
"output": [
"success"
]
}
],
"id": "api-request",
"group": "projextX",
"type": "builtin"
}
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"complete" "complete"
], ],
"id": "push-dialog", "id": "push-dialog",
"script": "if (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage = engine.gameStage;\n var view = gameStage.instantiateView(props.viewName);\n if (view) {\n gameStage.popupContainer.push(view);\n }\n next('complete');\n}\n", "script": "if (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage = engine.gameStage;\n var view = gameStage.instantiateView(props.viewName);\n if (view) {\n gameStage.popupContainer.push(view, { center: props.center });\n }\n next('complete');\n}\n",
"group": "view", "group": "view",
"type": "builtin" "type": "builtin"
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"success" "success"
], ],
"id": "set-mouse-enabled", "id": "set-mouse-enabled",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n targetNode.mouseEnabled = props.enabled;\n}\nnext('success');\n", "script": "var targetNode = target || props.target;\nif (targetNode) {\n targetNode.mouseEnabled = props.enabled;\n}\nnext('success', args);\n",
"group": "view", "group": "view",
"type": "builtin" "type": "builtin"
} }
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"success" "success"
], ],
"id": "set-node-property", "id": "set-node-property",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n var field = props.field, valueType = props.valueType, value = props.value;\n if (field && value) {\n var tValue = void 0;\n switch (valueType) {\n case 'number':\n tValue = parseFloat(value);\n break;\n case 'string':\n tValue = value;\n break;\n case 'boolean':\n tValue = value === 'true' ? true : (value === 'false' ? false : value);\n break;\n }\n if (tValue !== undefined) {\n targetNode[field] = tValue;\n }\n }\n}\nnext('success');\n", "script": "var targetNode = target || props.target;\nif (targetNode) {\n var field = props.field, valueType = props.valueType, value = props.value;\n if (field && value) {\n var tValue = void 0;\n switch (valueType) {\n case 'number':\n tValue = parseFloat(value);\n break;\n case 'string':\n tValue = value;\n break;\n case 'boolean':\n tValue = value === 'true' ? true : (value === 'false' ? false : value);\n break;\n }\n if (tValue !== undefined) {\n targetNode[field] = tValue;\n }\n }\n}\nnext('success', args);\n",
"group": "view", "group": "view",
"type": "builtin" "type": "builtin"
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"success" "success"
], ],
"id": "set-node-visibility", "id": "set-node-visibility",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n targetNode.visible = props.visible;\n}\nnext('success');\n", "script": "var targetNode = target || props.target;\nif (targetNode) {\n targetNode.visible = props.visible;\n}\nnext('success', args);\n",
"group": "view", "group": "view",
"type": "builtin" "type": "builtin"
} }
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
"success" "success"
], ],
"id": "set-script-enabled", "id": "set-script-enabled",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n var scriptsProxy = targetNode.scriptsProxy;\n var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;\n var script = void 0;\n if (scriptIndex !== undefined) {\n script = scriptsProxy.all[scriptIndex];\n }\n else if (scriptName !== undefined) {\n script = scriptsProxy.get(scriptName);\n }\n if (script) {\n script.disabled = !enabled;\n }\n}\nnext('success');\n", "script": "var targetNode = target || props.target;\nif (targetNode) {\n var scriptsProxy = targetNode.scriptsProxy;\n var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;\n var script = void 0;\n if (scriptIndex !== undefined) {\n script = scriptsProxy.all[scriptIndex];\n }\n else if (scriptName !== undefined) {\n script = scriptsProxy.get(scriptName);\n }\n if (script) {\n script.disabled = !enabled;\n }\n}\nnext('success', args);\n",
"group": "view", "group": "view",
"type": "builtin" "type": "builtin"
} }
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
"success" "success"
], ],
"id": "set-script-property", "id": "set-script-property",
"script": "var targetNode = target || props.target;\nif (targetNode) {\n var scriptsProxy = targetNode.scriptsProxy;\n var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;\n var script = void 0;\n if (scriptIndex !== undefined) {\n script = scriptsProxy.all[scriptIndex];\n }\n else if (scriptName !== undefined) {\n script = scriptsProxy.get(scriptName);\n }\n if (script) {\n var field = props.field, valueType = props.valueType, value = props.value;\n if (field && value) {\n var tValue = void 0;\n switch (valueType) {\n case 'number':\n tValue = parseFloat(value);\n break;\n case 'string':\n tValue = value;\n break;\n case 'boolean':\n tValue = value === 'true' ? true : (value === 'false' ? false : value);\n break;\n }\n if (tValue !== undefined) {\n script[field] = tValue;\n }\n }\n }\n}\nnext('success');\n", "script": "var targetNode = target || props.target;\nif (targetNode) {\n var scriptsProxy = targetNode.scriptsProxy;\n var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;\n var script = void 0;\n if (scriptIndex !== undefined) {\n script = scriptsProxy.all[scriptIndex];\n }\n else if (scriptName !== undefined) {\n script = scriptsProxy.get(scriptName);\n }\n if (script) {\n var field = props.field, valueType = props.valueType, value = props.value;\n if (field && value) {\n var tValue = void 0;\n switch (valueType) {\n case 'number':\n tValue = parseFloat(value);\n break;\n case 'string':\n tValue = value;\n break;\n case 'boolean':\n tValue = value === 'true' ? true : (value === 'false' ? false : value);\n break;\n }\n if (tValue !== undefined) {\n script[field] = tValue;\n }\n }\n }\n}\nnext('success', args);\n",
"group": "view", "group": "view",
"type": "builtin" "type": "builtin"
} }
...@@ -11,6 +11,12 @@ declare module engine { ...@@ -11,6 +11,12 @@ declare module engine {
export function addCustomModule(id, container: Container, options?): Container; export function addCustomModule(id, container: Container, options?): Container;
export function findVariable(name, ...contexts);
export function joinPath(...segments);
export function trimChar(str, char);
export const devicePixelRatio: number; export const devicePixelRatio: number;
export let StageScaleMode: { export let StageScaleMode: {
...@@ -2793,7 +2799,7 @@ declare module engine { ...@@ -2793,7 +2799,7 @@ declare module engine {
getViewConfigByName(name: any): any; getViewConfigByName(name: any): any;
instantiateView(name, cache = true):any; instantiateView(name, cache = true): any;
setBlackLayerVisible(visible: any): void; setBlackLayerVisible(visible: any): void;
......
...@@ -29,9 +29,11 @@ const [_, __, sourcePath, outputPath = 'dist/customs'] = process.argv; ...@@ -29,9 +29,11 @@ const [_, __, sourcePath, outputPath = 'dist/customs'] = process.argv;
async function compileProcess(sourcePath, output) { async function compileProcess(sourcePath, output) {
const id = sourcePath; const id = sourcePath;
const meta = fs.readJsonSync(path.join('src/custom/' + sourcePath, 'meta.json')); const meta = fs.readJsonSync(path.join('src/custom/' + sourcePath, 'meta.json'));
const {code} = await compile('src/custom/' + sourcePath + '/index.ts'); const result = await compile('src/custom/' + sourcePath, false);
meta.id = id; meta.id = id;
meta.code = code; if(result){
meta.code = result.code;
}
const outputPath = path.join(output, sourcePath); const outputPath = path.join(output, sourcePath);
fs.ensureDirSync(path.dirname(outputPath)); fs.ensureDirSync(path.dirname(outputPath));
......
...@@ -29,9 +29,11 @@ function compileProcess(sourcePath, output, isBuiltin) { ...@@ -29,9 +29,11 @@ function compileProcess(sourcePath, output, isBuiltin) {
const group = arr[0]; const group = arr[0];
const id = arr[1]; const id = arr[1];
const meta = fs.readJsonSync(path.join('src/process/' + sourcePath, 'meta.json')); const meta = fs.readJsonSync(path.join('src/process/' + sourcePath, 'meta.json'));
const {code} = compile('src/process/' + sourcePath); const result = compile('src/process/' + sourcePath, false);
meta.id = id; meta.id = id;
meta.script = code; if(result){
meta.script = result.code;
}
meta.group = group; meta.group = group;
if(isBuiltin){ if(isBuiltin){
meta.type = 'builtin' meta.type = 'builtin'
......
...@@ -26,9 +26,11 @@ console.log('complete!'); ...@@ -26,9 +26,11 @@ console.log('complete!');
function compileProcess(sourcePath, output) { function compileProcess(sourcePath, output) {
const id = sourcePath; const id = sourcePath;
const meta = fs.readJsonSync(path.join('src/script/' + sourcePath, 'meta.json')); const meta = fs.readJsonSync(path.join('src/script/' + sourcePath, 'meta.json'));
const {code} = compile('src/script/' + sourcePath); const result = compile('src/script/' + sourcePath, false);
meta.id = id; meta.id = id;
meta.code = code; if(result){
meta.code = result.code;
}
const outputPath = path.join(output, sourcePath); const outputPath = path.join(output, sourcePath);
fs.ensureDirSync(path.dirname(outputPath)); fs.ensureDirSync(path.dirname(outputPath));
......
...@@ -14,7 +14,7 @@ exports.prepare = function (tsconfig, projectPath) { ...@@ -14,7 +14,7 @@ exports.prepare = function (tsconfig, projectPath) {
_projectPath = projectPath; _projectPath = projectPath;
}; };
exports.compile = function (file) { exports.compile = function (file, throwError = true) {
if (!_options) { if (!_options) {
throw Error('no options input') throw Error('no options input')
} }
...@@ -25,8 +25,11 @@ exports.compile = function (file) { ...@@ -25,8 +25,11 @@ exports.compile = function (file) {
filePath = path.resolve(_projectPath, file + '/index.ts'); filePath = path.resolve(_projectPath, file + '/index.ts');
if (!fs.existsSync(filePath)) { if (!fs.existsSync(filePath)) {
if(throwError){
throw new Error('source code file not exists'); throw new Error('source code file not exists');
} }
return null;
}
} }
let source = fs.readFileSync(filePath, 'utf-8'); let source = fs.readFileSync(filePath, 'utf-8');
......
...@@ -4,10 +4,7 @@ ...@@ -4,10 +4,7 @@
let leftValue = typeof props.left === 'string' ? '"' + props.left + '"' : props.left; let leftValue = typeof props.left === 'string' ? '"' + props.left + '"' : props.left;
let rightValue = typeof props.right === 'string' ? '"' + props.right + '"' : props.right; let rightValue = typeof props.right === 'string' ? '"' + props.right + '"' : props.right;
let operator = (args ? args.operator : props.operator) || '=='; let operator = props.operator;
if(operator === '==' || operator === '!='){
operator += '=';
}
let func = new Function('return ' + leftValue + operator + rightValue); let func = new Function('return ' + leftValue + operator + rightValue);
let result = func(); let result = func();
next(result ? 'true' : 'false'); next(result ? 'true' : 'false');
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
* Created by rockyl on 2019-11-16. * Created by rockyl on 2019-11-16.
*/ */
next('success'); next('success', args);
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
*/ */
console.log(props ? props.content : (args ? args.content : '')); console.log(props ? props.content : (args ? args.content : ''));
next('success');
\ No newline at end of file next('success', args);
\ No newline at end of file
...@@ -9,7 +9,7 @@ engine.Tween.get(props.target) ...@@ -9,7 +9,7 @@ engine.Tween.get(props.target)
.set({rotation: 0}) .set({rotation: 0})
.to({rotation: 360}, props.duration, engine.Ease.quintIn) .to({rotation: 360}, props.duration, engine.Ease.quintIn)
.call(function () { .call(function () {
next('success'); next('success', args);
playLoop(); playLoop();
}); });
......
...@@ -13,10 +13,10 @@ if (args && args.hasOwnProperty('index')) { ...@@ -13,10 +13,10 @@ if (args && args.hasOwnProperty('index')) {
engine.Tween.get(props.target || target) engine.Tween.get(props.target || target)
.to({rotation}, props.duration, engine.Ease.quintOut) .to({rotation}, props.duration, engine.Ease.quintOut)
.call(function () { .call(function () {
next('success'); next('success', args);
}) })
}); });
} else { } else {
engine.Tween.removeTweens(props.target || target); engine.Tween.removeTweens(props.target || target);
next('success'); next('success', args);
} }
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
* Created by rockyl on 2019-11-16. * Created by rockyl on 2019-11-16.
*/ */
next('success'); next('success', args);
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
"name": { "name": {
"type": "string", "type": "string",
"alias": "数据名" "alias": "数据名"
},
"params": {
"type": "map",
"alias": "参数"
} }
}, },
"output": [ "output": [
......
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
*/ */
location.href='/record'; location.href='/record';
next('success');
next('success', args);
/**
* Created by rockyl on 2019-11-16.
*/
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
"props": { "props": {
"url": { "url": {
"type": "string", "type": "string",
"enum": [],
"alias": "链接" "alias": "链接"
}, },
"method": { "method": {
...@@ -17,30 +16,29 @@ ...@@ -17,30 +16,29 @@
}, },
"count": { "count": {
"type": "number", "type": "number",
"enum": [],
"alias": "次数", "alias": "次数",
"default": 10 "default": 10
}, },
"delay": { "delay": {
"type": "number", "type": "number",
"enum": [],
"default": 500, "default": 500,
"alias": "单次延时" "alias": "单次延时"
}, },
"name": { "name": {
"type": "string", "type": "string",
"enum": [],
"alias": "数据名" "alias": "数据名"
}, },
"field": { "field": {
"type": "string", "type": "string",
"enum": [],
"alias": "字段名" "alias": "字段名"
}, },
"successValues": { "successValues": {
"type": "string", "type": "string",
"enum": [],
"alias": "成功值" "alias": "成功值"
},
"params": {
"type": "map",
"alias": "参数"
} }
}, },
"output": [ "output": [
......
...@@ -2,15 +2,18 @@ ...@@ -2,15 +2,18 @@
* Created by rockyl on 2019-11-16. * Created by rockyl on 2019-11-16.
*/ */
if(!props.url){ const url = engine.findVariable('url', args, props);
const params = engine.findVariable('params', args, props);
if (!url) {
console.log('url is empty'); console.log('url is empty');
next('exception', '\'url is empty\''); next('exception', '\'url is empty\'');
}else{ } else {
engine.httpRequest((s, payload) => { engine.httpRequest((s, payload) => {
if(s){ if (s) {
next('success', payload); next('success', payload);
}else{ } else {
next('failed', payload); next('failed', payload);
} }
}, props.url, props.method, {}, 'json'); }, url, props.method, params, 'json');
} }
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
"desc": "Http请求", "desc": "Http请求",
"props": { "props": {
"url": {"type": "string", "alias": "地址"}, "url": {"type": "string", "alias": "地址"},
"method": {"type": "enum", "enum": ["get", "post"], "alias": "方法", "default": "get"} "method": {"type": "enum", "enum": ["get", "post"], "alias": "方法", "default": "get"},
"params": {
"type": "map",
"alias": "参数"
}
}, },
"output": ["success", "failed", "exception"] "output": ["success", "failed", "exception"]
} }
\ No newline at end of file
{
"props": {
"host": {
"type": "string",
"alias": "接口根"
},
"uri": {
"type": "string",
"alias": "URI"
},
"method": {
"type": "enum",
"enum": [
"get",
"post"
],
"alias": "方法"
},
"dataName": {
"type": "string",
"alias": "数据名"
},
"params": {
"type": "map",
"alias": "参数"
}
},
"name": "api请求",
"output": [
"success",
"failed",
"exception"
],
"sub": {
"e6a9f1de-40c6-445b-b5e9-5c50a904a4de": {
"uuid": "e6a9f1de-40c6-445b-b5e9-5c50a904a4de",
"meta": "entry",
"design": {
"x": 10,
"y": 10,
"input": {},
"output": {
"success": [
{
"x": 124.5,
"y": 31
}
]
}
},
"props": {},
"output": {
"success": [
"567169ba-a2c1-4c10-9025-605a2e89ef0f"
]
}
},
"567169ba-a2c1-4c10-9025-605a2e89ef0f": {
"uuid": "567169ba-a2c1-4c10-9025-605a2e89ef0f",
"meta": "a4b27753-4cbb-47e3-9b31-51ced475e41a",
"design": {
"x": 151,
"y": 115,
"input": {
"default": [
{
"x": 5.5,
"y": 47.5
}
]
},
"output": {
"success": [
{
"x": 124.5,
"y": 47.5
}
]
}
},
"props": {
"host": {
"type": "link"
},
"uri": {
"type": "link"
}
},
"output": {
"success": [
"f9a32b46-aec1-4bd2-9b98-3d9a427d87db"
]
}
},
"f9a32b46-aec1-4bd2-9b98-3d9a427d87db": {
"uuid": "f9a32b46-aec1-4bd2-9b98-3d9a427d87db",
"meta": "duiba-api",
"design": {
"x": 350,
"y": 188,
"input": {
"default": [
{
"x": 5.5,
"y": 56
}
]
},
"output": {
"success": [
{
"x": 124.5,
"y": 49
}
],
"failed": [
{
"x": 124.5,
"y": 63
}
]
}
},
"props": {
"method": {
"type": "link"
},
"name": {
"type": "link",
"alias": "dataName"
}
},
"output": {}
}
},
"subEntry": "e6a9f1de-40c6-445b-b5e9-5c50a904a4de",
"metas": [
{
"id": "a4b27753-4cbb-47e3-9b31-51ced475e41a",
"script": "var host = engine.findVariable('host', args, props);\nvar uri = engine.findVariable('uri', args, props);\nnext('success', {url: engine.joinPath(host, uri)});",
"props": {
"host": {
"type": "string",
"alias": "接口根"
},
"uri": {
"type": "string",
"alias": "URI"
}
},
"isInline": true,
"name": "url拼接",
"output": [
"success"
]
}
]
}
\ No newline at end of file
...@@ -9,7 +9,7 @@ if (!props.viewName) { ...@@ -9,7 +9,7 @@ if (!props.viewName) {
let gameStage = engine.gameStage; let gameStage = engine.gameStage;
let view = gameStage.instantiateView(props.viewName); let view = gameStage.instantiateView(props.viewName);
if (view) { if (view) {
gameStage.popupContainer.push(view); gameStage.popupContainer.push(view, {center: props.center});
} }
next('complete'); next('complete');
......
...@@ -7,4 +7,4 @@ if(targetNode){ ...@@ -7,4 +7,4 @@ if(targetNode){
targetNode.mouseEnabled = props.enabled; targetNode.mouseEnabled = props.enabled;
} }
next('success'); next('success', args);
...@@ -24,4 +24,4 @@ if (targetNode) { ...@@ -24,4 +24,4 @@ if (targetNode) {
} }
} }
next('success'); next('success', args);
...@@ -7,4 +7,4 @@ if(targetNode){ ...@@ -7,4 +7,4 @@ if(targetNode){
targetNode.visible = props.visible; targetNode.visible = props.visible;
} }
next('success'); next('success', args);
...@@ -17,4 +17,4 @@ if (targetNode) { ...@@ -17,4 +17,4 @@ if (targetNode) {
} }
} }
next('success'); next('success', args);
...@@ -34,4 +34,4 @@ if (targetNode) { ...@@ -34,4 +34,4 @@ if (targetNode) {
} }
} }
next('success'); next('success', args);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment