Commit 25bf7a81 authored by rockyl's avatar rockyl

提交一次

parent b4bbd46e
......@@ -14,7 +14,7 @@
})();
function launchWithCustomModule(customModule) {
engine.globalEvent.addEventListener('update-game-status', (e)=>{
engine.globalEvent.addEventListener('update-game-status', (e) => {
console.log(e.type, e.data);
});
......@@ -29,10 +29,10 @@ function launchWithCustomModule(customModule) {
name: 'entry',
type: 'node',
}],
}, null, null, function(){
}, null, function () {
engine.addCustomModule(customModule.id, engine.gameStage.sceneContainer.getChildAt(0));
setTimeout(()=>{
setTimeout(() => {
engine.globalEvent.dispatchEvent('start-game', {level: 1});
}, 500);
});
......
......@@ -31,7 +31,7 @@
<div id="game-container" style="line-height:0;font-size:0"></div>
<script src="//res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<!--script src="http://localhost:4002/debug/engine.js"></script-->
<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.d208e8f972669861e966f1cfe979ad7700cb1f8d.js"></script>
<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>
<script src="app.js"></script>
<script>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -9,5 +9,5 @@
}
],
"id": "test1",
"code": "'use strict';\n\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\n\nvar Test1 = (function (_super) {\n __extends(Test1, _super);\n function Test1() {\n var _this = _super.call(this) || this;\n var sprite = new engine.Sprite(engine.Texture.from('20191216114509'));\n _this.addChild(sprite);\n sprite.addEventListener(engine.MouseEvent.CLICK, _this.onClick, _this);\n engine.globalEvent.addEventListener('start-game', _this.onGameStart, _this);\n return _this;\n }\n Test1.prototype.onClick = function (e) {\n engine.globalEvent.dispatchEvent('update-game-status', { score: 1 });\n };\n Test1.prototype.onGameStart = function (e) {\n console.log(e.type, e.data);\n var rect = new engine.Rect();\n rect.x = 100;\n rect.y = 100;\n rect.width = 100;\n rect.height = 100;\n rect.fillColor = 'green';\n this.addChild(rect);\n };\n return Test1;\n}(engine.Container));\n\nfunction index (options) {\n var instance = new Test1();\n return instance;\n}\n\nmodule.exports = index;\n"
"code": "'use strict';\n\nvar tslib = require('tslib');\n\nvar Test1 = (function (_super) {\n tslib.__extends(Test1, _super);\n function Test1() {\n var _this = _super.call(this) || this;\n var sprite = new engine.Sprite(engine.Texture.from('20191216114509'));\n _this.addChild(sprite);\n sprite.addEventListener(engine.MouseEvent.CLICK, _this.onClick, _this);\n engine.globalEvent.addEventListener('start-game', _this.onGameStart, _this);\n return _this;\n }\n Test1.prototype.onClick = function (e) {\n engine.globalEvent.dispatchEvent('update-game-status', { score: 1 });\n };\n Test1.prototype.onGameStart = function (e) {\n console.log(e.type, e.data);\n var rect = new engine.Rect();\n rect.x = 100;\n rect.y = 200;\n rect.width = 100;\n rect.height = 100;\n rect.fillColor = 'green';\n this.addChild(rect);\n };\n return Test1;\n}(engine.Container));\n\nfunction index (options) {\n var instance = new Test1();\n return instance;\n}\n\nmodule.exports = index;\n"
}
......@@ -15,6 +15,16 @@
"alias": "方法",
"default": "get"
},
"type": {
"type": "enum",
"enum": [
"json",
"text",
"jsonp"
],
"alias": "类型",
"default": "json"
},
"name": {
"type": "string",
"alias": "数据名"
......@@ -22,6 +32,10 @@
"params": {
"type": "map",
"alias": "参数"
},
"headers": {
"type": "map",
"alias": "头部"
}
},
"output": [
......@@ -49,8 +63,14 @@
"method": {
"type": "link"
},
"type": {
"type": "link"
},
"params": {
"type": "link"
},
"headers": {
"type": "link"
}
},
"output": {
......@@ -96,7 +116,6 @@
}
],
"id": "duiba-api",
"script": "next('success', args);\n",
"group": "duiba",
"type": "builtin"
}
......@@ -39,6 +39,10 @@
"params": {
"type": "map",
"alias": "参数"
},
"headers": {
"type": "map",
"alias": "头部"
}
},
"output": [
......@@ -104,6 +108,12 @@
},
"name": {
"type": "link"
},
"params": {
"type": "link"
},
"headers": {
"type": "link"
}
},
"output": {
......
......@@ -15,9 +15,23 @@
"alias": "方法",
"default": "get"
},
"type": {
"type": "enum",
"enum": [
"json",
"text",
"jsonp"
],
"alias": "类型",
"default": "json"
},
"params": {
"type": "map",
"alias": "参数"
},
"headers": {
"type": "map",
"alias": "头部"
}
},
"output": [
......@@ -26,7 +40,7 @@
"exception"
],
"id": "http-request",
"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(url, props.method, params, 'json')\n .then(function (data) {\n next('success', data);\n }, function (err) {\n next('failed', err);\n });\n}\n",
"script": "var url = engine.findVariable('url', args, props);\nvar type = engine.findVariable('type', args, props);\nvar params = engine.findVariable('params', args, props);\nvar headers = engine.findVariable('headers', args, props);\nif (!url) {\n console.log('url is empty');\n next('exception', '\\'url is empty\\'');\n}\nelse {\n engine.httpRequest(url, props.method, params, type, headers)\n .then(function (data) {\n next('success', data);\n }, function (err) {\n next('failed', err);\n });\n}\n",
"group": "net",
"type": "builtin"
}
......@@ -13,6 +13,16 @@
"alias": "方法",
"default": "get"
},
"type": {
"type": "enum",
"enum": [
"json",
"text",
"jsonp"
],
"alias": "类型",
"default": "json"
},
"count": {
"type": "number",
"alias": "次数",
......@@ -38,6 +48,10 @@
"params": {
"type": "map",
"alias": "参数"
},
"headers": {
"type": "map",
"alias": "头部"
}
},
"name": "API轮询",
......@@ -103,11 +117,17 @@
"method": {
"type": "link"
},
"type": {
"type": "link"
},
"dataName": {
"type": "link"
},
"params": {
"type": "link"
},
"headers": {
"type": "link"
}
},
"output": {
......
......@@ -13,6 +13,16 @@
"alias": "方法",
"default": "get"
},
"type": {
"type": "enum",
"enum": [
"json",
"text",
"jsonp"
],
"alias": "类型",
"default": "json"
},
"dataName": {
"type": "string",
"alias": "数据名"
......@@ -20,6 +30,10 @@
"params": {
"type": "map",
"alias": "参数"
},
"headers": {
"type": "map",
"alias": "头部"
}
},
"name": "API请求",
......@@ -63,12 +77,18 @@
"method": {
"type": "link"
},
"type": {
"type": "link"
},
"name": {
"type": "link",
"alias": "dataName"
},
"params": {
"type": "link"
},
"headers": {
"type": "link"
}
},
"output": {}
......
{
"id": "init-weixin-env",
"props": {
"debug": {
"type": "boolean",
"alias": "调试模式"
}
},
"name": "初始化微信环境",
"output": [
"success"
],
"sub": {
"345ffd18-6e91-4a6e-8469-12d0e9f76e73": {
"uuid": "345ffd18-6e91-4a6e-8469-12d0e9f76e73",
"meta": "entry",
"design": {
"x": 10,
"y": 10,
"input": {},
"output": {
"success": [
{
"x": 124.5,
"y": 32
}
]
}
},
"props": {},
"output": {
"success": [
"303b8a54-5d14-4bb1-b2ad-72e54b5d4faf"
]
}
},
"d1eb90cd-9bbb-41a9-a43d-6a87cfe8510a": {
"uuid": "d1eb90cd-9bbb-41a9-a43d-6a87cfe8510a",
"meta": "66e003c5-4cd2-41cf-94e4-2c42d6d0112d",
"design": {
"x": 475,
"y": 213
},
"props": {
"debug": {
"type": "link"
}
},
"output": {}
},
"0ef79170-f204-4a63-8317-4714dd4114b4": {
"uuid": "0ef79170-f204-4a63-8317-4714dd4114b4",
"meta": "http-request",
"design": {
"x": 284,
"y": 144
},
"props": {
"url": "/wechatShare/getShareInfo/v2",
"params": {
"type": "map",
"value": {}
}
},
"output": {
"success": [
"d1eb90cd-9bbb-41a9-a43d-6a87cfe8510a"
]
}
},
"303b8a54-5d14-4bb1-b2ad-72e54b5d4faf": {
"uuid": "303b8a54-5d14-4bb1-b2ad-72e54b5d4faf",
"meta": "ab7b55eb-5e38-4028-815f-0ba3f6e1c998",
"design": {
"x": 119,
"y": 114
},
"props": {},
"output": {
"success": [
"0ef79170-f204-4a63-8317-4714dd4114b4"
]
}
}
},
"subEntry": "345ffd18-6e91-4a6e-8469-12d0e9f76e73",
"metas": [
{
"id": "66e003c5-4cd2-41cf-94e4-2c42d6d0112d",
"script": "//alert(JSON.stringify(args))\n\nwx.config({\n debug: props.debug,\n appId: args.wxappid,\n timestamp: args.wxtimestamp,\n nonceStr: args.wxnonceStr,\n signature: args.wxsignature,\n jsApiList: ['checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage']\n});\n\nwx.error(function(res){\n\talert(JSON.stringify(res))\n});\n\nnext('success');",
"props": {
"debug": {
"type": "boolean",
"alias": "调试模式"
}
},
"isInline": true,
"name": "设置微信环境",
"output": [
"success"
]
},
{
"id": "ab7b55eb-5e38-4028-815f-0ba3f6e1c998",
"script": "next('success', {\n params: {\n url: encodeURIComponent(location.href)\n }\n});",
"props": {},
"isInline": true,
"name": "获取当前链接",
"output": [
"success"
]
}
],
"group": "share",
"type": "builtin"
}
......@@ -24,7 +24,7 @@
"success"
],
"id": "set-script-enabled",
"script": "var targetNode = props.target || target;\nif (targetNode) {\n var scriptsProxy = targetNode.scriptsProxy;\n var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;\n if (scriptIndex !== undefined) {\n var script = scriptsProxy.all[scriptIndex];\n if (script) {\n script.disabled = !enabled;\n }\n }\n else if (scriptName !== undefined) {\n var scripts = scriptsProxy.get(scriptName);\n for (var _i = 0, scripts_1 = scripts; _i < scripts_1.length; _i++) {\n var script = scripts_1[_i];\n script.disabled = !enabled;\n }\n }\n}\nnext('success', args);\n",
"script": "var targetNode = props.target || target;\nif (targetNode) {\n var scripts = targetNode.scripts;\n var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;\n if (scriptIndex !== undefined) {\n var script = scripts.all[scriptIndex];\n if (script) {\n script.disabled = !enabled;\n }\n }\n else if (scriptName !== undefined) {\n var scripts_2 = scripts_2.get(scriptName);\n for (var _i = 0, scripts_1 = scripts_2; _i < scripts_1.length; _i++) {\n var script = scripts_1[_i];\n script.disabled = !enabled;\n }\n }\n}\nnext('success', args);\n",
"group": "view",
"type": "builtin"
}
......@@ -37,7 +37,7 @@
"success"
],
"id": "set-script-property",
"script": "var targetNode = props.target || 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",
"script": "var targetNode = props.target || target;\nif (targetNode) {\n var scripts = targetNode.scripts;\n var scriptIndex = props.scriptIndex, scriptName = props.scriptName, enabled = props.enabled;\n var script = void 0;\n if (scriptIndex !== undefined) {\n script = scripts.all[scriptIndex];\n }\n else if (scriptName !== undefined) {\n script = scripts.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",
"type": "builtin"
}
......@@ -15,8 +15,18 @@
"alias": "DOM",
"type": "string",
"default": "0.0.0.0"
},
"autoExposure": {
"alias": "自动曝光",
"type": "boolean",
"default": true
},
"autoClick": {
"alias": "自动点击",
"type": "boolean",
"default": true
}
},
"id": "buried-point",
"code": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar BuriedPoint = (function (_super) {\n __extends(BuriedPoint, _super);\n function BuriedPoint() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.dpm = '0.0.0.0';\n _this.dcm = '0.0.0.0';\n _this.dom = '0.0.0.0';\n return _this;\n }\n BuriedPoint.prototype.mounted = function () {\n this.dpm && (this.dpm = fill(this.dpm));\n this.dcm && (this.dcm = fill(this.dcm));\n this.dom && (this.dom = fill(this.dom));\n this.host.addEventListener(engine.MouseEvent.CLICK, this._onClick, this);\n };\n BuriedPoint.prototype.awake = function () {\n log('exposure', this);\n };\n BuriedPoint.prototype._onClick = function (e) {\n log('click', this);\n };\n BuriedPoint.id = 'buried-point';\n return BuriedPoint;\n}(engine.ScriptBase));\nexports.default = BuriedPoint;\nfunction fill(src) {\n var result = src;\n for (var key in engine.env) {\n result = result.replace(key, engine.env[key]);\n }\n return result;\n}\nfunction log(type, data) {\n var dpm = data.dpm, dcm = data.dcm, dom = data.dom;\n var params = {\n dpm: dpm, dcm: dcm, appId: engine.env.app_id\n };\n if (dom !== '0.0.0.0') {\n params.dom = dom;\n }\n var isExposure = type === 'exposure';\n engine.httpRequest(isExposure ? '//embedlog.duiba.com.cn/exposure/standard' : '/log/click', 'get', params, isExposure ? 'jsonp' : 'text');\n}\n"
"code": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar BuriedPoint = (function (_super) {\n __extends(BuriedPoint, _super);\n function BuriedPoint() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.dpm = '0.0.0.0';\n _this.dcm = '0.0.0.0';\n _this.dom = '0.0.0.0';\n _this.autoExposure = true;\n _this.autoClick = true;\n return _this;\n }\n BuriedPoint.prototype.onModify = function (value, key, oldValue) {\n switch (key) {\n case 'dpm':\n case 'dcm':\n case 'dom':\n this['__' + key] = fill(value);\n break;\n }\n };\n BuriedPoint.prototype.mounted = function () {\n this.host.addEventListener(engine.MouseEvent.CLICK, this._onClick, this);\n };\n BuriedPoint.prototype.awake = function () {\n if (this.autoExposure) {\n this.logExposure();\n }\n };\n BuriedPoint.prototype._onClick = function (e) {\n if (this.autoClick) {\n this.logClick();\n }\n };\n BuriedPoint.prototype.logExposure = function () {\n this.log('exposure');\n };\n BuriedPoint.prototype.logClick = function () {\n this.log('click');\n };\n BuriedPoint.prototype.log = function (type) {\n log(type, {\n dpm: this['__dpm'],\n dcm: this['__dcm'],\n dom: this['__dom'],\n });\n };\n BuriedPoint.id = 'buried-point';\n __decorate([\n engine.dirtyFieldTrigger\n ], BuriedPoint.prototype, \"dpm\", void 0);\n __decorate([\n engine.dirtyFieldTrigger\n ], BuriedPoint.prototype, \"dcm\", void 0);\n __decorate([\n engine.dirtyFieldTrigger\n ], BuriedPoint.prototype, \"dom\", void 0);\n return BuriedPoint;\n}(engine.ScriptBase));\nexports.default = BuriedPoint;\nfunction fill(src) {\n var result = src;\n for (var key in engine.env) {\n result = result.replace(key, engine.env[key]);\n }\n return result;\n}\nfunction log(type, data) {\n var dpm = data.dpm, dcm = data.dcm, dom = data.dom;\n var params = {\n dpm: dpm, dcm: dcm, appId: engine.env.app_id\n };\n if (dom !== '0.0.0.0') {\n params.dom = dom;\n }\n var isExposure = type === 'exposure';\n engine.httpRequest(isExposure ? '//embedlog.duiba.com.cn/exposure/standard' : '/log/click', 'get', params, isExposure ? 'jsonp' : 'text');\n}\n"
}
......@@ -824,7 +824,7 @@ export class Transform extends HashObject {
destroy(): void;
}
export function httpRequest(url: string, method?: string, params?: any, type?: 'text' | 'json' | 'jsonp'): Promise<{}>;
export function httpRequest(url: string, method?: string, params?: any, type?: 'text' | 'json' | 'jsonp', headers?): Promise<{}>;
export function jsonp(url: any, params: any): Promise<{}>;
......@@ -2183,7 +2183,7 @@ export class DataCenter extends EventDispatcher {
export const dataCenter: DataCenter;
export let env: {};
export let env: any;
export function injectEnv(data: any): void;
......@@ -2298,9 +2298,7 @@ export let gameStage: GameStage;
export function launch(url: any, onAssetsProgress: any, onAssetsComplete: any): Promise<{}>;
export function launchWithLocalStorage(id: any, onAssetsProgress: any, onAssetsComplete: any): Promise<{}>;
export function launchWithConfig(config: any, onAssetsProgress: any, onAssetsComplete: any): Promise<{}>;
export function launchWithConfig(config: any, loadingDelegate: any, onStart: any): Promise<{}>;
export function findNodeByUUID(node: any, uuid: any): any;
......
......@@ -5,6 +5,7 @@
"license": "MIT",
"scripts": {
"build-process": "node scripts/compiler-process",
"build-process:prod": "node scripts/compiler-process prod",
"build-script": "node scripts/compiler-script",
"build-custom": "node scripts/compiler-custom"
},
......
/**
* Created by rockyl on 2018/11/16.
*/
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const progress = require('rollup-plugin-progress');
const typescript = require('rollup-plugin-typescript');
const {uglify} = require('rollup-plugin-uglify');
export default {
input: 'src/custom/test1/index.ts',
output: [
{
file: `dist/customs/test1.js`,
format: 'cjs',
name: 'test1',
sourcemap: true,
}
],
plugins: [
progress(),
resolve({
//only: [/^\.{0,2}\//],
}),
typescript({
//useTsconfigDeclarationDir: true,
}),
commonjs(),
//uglify({}),
]
};
......@@ -7,10 +7,6 @@ const fs = require('fs-extra');
const path = require('path');
const glob = require('glob');
const tsconfig = fs.readJsonSync('tsconfig.json');
//tsconfig.compilerOptions.module = 'umd';
//prepare(tsconfig, process.cwd());
const [_, __, sourcePath, outputPath = 'dist/customs'] = process.argv;
(async function(){
......@@ -38,8 +34,8 @@ async function compileProcess(sourcePath, output) {
const outputPath = path.join(output, sourcePath);
fs.ensureDirSync(path.dirname(outputPath));
fs.writeJsonSync(outputPath + '.json', meta, {spaces: ' '});
//fs.writeFileSync(outputPath + '.js', result.code);
/*fs.writeJsonSync(outputPath + '-req.json', {
/*fs.writeFileSync(outputPath + '.js', result.code);
fs.writeJsonSync(outputPath + '-req.json', {
data: JSON.stringify(meta)
});*/
......
......@@ -8,26 +8,30 @@ const progress = require('rollup-plugin-progress');
const typescript = require('rollup-plugin-typescript');
const {uglify} = require('rollup-plugin-uglify');
const rollup = require('rollup');
const fs = require('fs');
const tslib = fs.readFileSync(__dirname + '/tslib.es6.js', 'utf-8');
exports.compile = async function (file, options) {
const {prod = false} = options;
exports.compile = async function(file){
let plugins = [
progress(),
resolve({
//only: [/^\.{0,2}\//],
}),
typescript({
tslib,
//useTsconfigDeclarationDir: true,
}),
commonjs(),
//uglify({}),
];
if (prod) {
plugins.push(uglify({}));
}
let writeConfig = {
format: 'cjs',
globals: {
tslib: 'tslib'
},
};
const bundle = await rollup.rollup({
......@@ -35,7 +39,8 @@ exports.compile = async function(file){
plugins,
onwarn: warning => {
console.log(warning);
}
},
external: ['tslib'],
});
const {output: [result]} = await bundle.generate(writeConfig);
return result;
......
......@@ -211,11 +211,6 @@
"uuid": "2ddd9477-12de-4f13-bb35-5b255f1624bd",
"ext": ".png"
},
{
"url": "",
"uuid": "",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/905239e8db76682f47339668e7d9279b2ec4f0e2.png",
"uuid": "93992a62-e3c4-46d5-99f4-f7ba35fe4f4f",
......
/**
* Created by rockyl on 2019-11-16.
*/
next('success', args);
......@@ -15,6 +15,7 @@
"alias": "方法",
"default": "get"
},
"type": {"type": "enum", "enum": ["json", "text", "jsonp"], "alias": "类型", "default": "json" },
"name": {
"type": "string",
"alias": "数据名"
......@@ -22,7 +23,8 @@
"params": {
"type": "map",
"alias": "参数"
}
},
"headers": {"type": "map", "alias": "头部" }
},
"output": [
"success",
......@@ -49,8 +51,14 @@
"method": {
"type": "link"
},
"type": {
"type": "link"
},
"params": {
"type": "link"
},
"headers": {
"type": "link"
}
},
"output": {
......
......@@ -39,7 +39,8 @@
"params": {
"type": "map",
"alias": "参数"
}
},
"headers": {"type": "map", "alias": "头部" }
},
"output": [
"success",
......@@ -104,6 +105,12 @@
},
"name": {
"type": "link"
},
"params": {
"type": "link"
},
"headers": {
"type": "link"
}
},
"output": {
......
......@@ -3,13 +3,15 @@
*/
const url = engine.findVariable('url', args, props);
const type = engine.findVariable('type', args, props);
const params = engine.findVariable('params', args, props);
const headers = engine.findVariable('headers', args, props);
if (!url) {
console.log('url is empty');
next('exception', '\'url is empty\'');
} else {
engine.httpRequest(url, props.method, params, 'json')
engine.httpRequest(url, props.method, params, type, headers)
.then(
data => {
next('success', data);
......
......@@ -4,10 +4,9 @@
"props": {
"url": {"type": "string", "alias": "地址"},
"method": {"type": "enum", "enum": ["get", "post"], "alias": "方法", "default": "get"},
"params": {
"type": "map",
"alias": "参数"
}
"type": {"type": "enum", "enum": ["json", "text", "jsonp"], "alias": "类型", "default": "json" },
"params": {"type": "map", "alias": "参数" },
"headers": {"type": "map", "alias": "头部" }
},
"output": ["success", "failed", "exception"]
}
\ No newline at end of file
......@@ -13,6 +13,7 @@
"alias": "方法",
"default": "get"
},
"type": {"type": "enum", "enum": ["json", "text", "jsonp"], "alias": "类型", "default": "json" },
"count": {
"type": "number",
"alias": "次数",
......@@ -38,7 +39,8 @@
"params": {
"type": "map",
"alias": "参数"
}
},
"headers": {"type": "map", "alias": "头部" }
},
"name": "API轮询",
"output": [
......@@ -103,11 +105,17 @@
"method": {
"type": "link"
},
"type": {
"type": "link"
},
"dataName": {
"type": "link"
},
"params": {
"type": "link"
},
"headers": {
"type": "link"
}
},
"output": {
......
......@@ -13,6 +13,7 @@
"alias": "方法",
"default": "get"
},
"type": {"type": "enum", "enum": ["json", "text", "jsonp"], "alias": "类型", "default": "json" },
"dataName": {
"type": "string",
"alias": "数据名"
......@@ -20,7 +21,8 @@
"params": {
"type": "map",
"alias": "参数"
}
},
"headers": {"type": "map", "alias": "头部" }
},
"name": "API请求",
"output": [
......@@ -63,12 +65,18 @@
"method": {
"type": "link"
},
"type": {
"type": "link"
},
"name": {
"type": "link",
"alias": "dataName"
},
"params": {
"type": "link"
},
"headers": {
"type": "link"
}
},
"output": {}
......
{
"id": "init-weixin-env",
"props": {
"debug": {
"type": "boolean",
"alias": "调试模式"
}
},
"name": "初始化微信环境",
"output": [
"success"
],
"sub": {
"345ffd18-6e91-4a6e-8469-12d0e9f76e73": {
"uuid": "345ffd18-6e91-4a6e-8469-12d0e9f76e73",
"meta": "entry",
"design": {
"x": 10,
"y": 10,
"input": {},
"output": {
"success": [
{
"x": 124.5,
"y": 32
}
]
}
},
"props": {},
"output": {
"success": [
"303b8a54-5d14-4bb1-b2ad-72e54b5d4faf"
]
}
},
"d1eb90cd-9bbb-41a9-a43d-6a87cfe8510a": {
"uuid": "d1eb90cd-9bbb-41a9-a43d-6a87cfe8510a",
"meta": "66e003c5-4cd2-41cf-94e4-2c42d6d0112d",
"design": {
"x": 475,
"y": 213
},
"props": {
"debug": {
"type": "link"
}
},
"output": {}
},
"0ef79170-f204-4a63-8317-4714dd4114b4": {
"uuid": "0ef79170-f204-4a63-8317-4714dd4114b4",
"meta": "http-request",
"design": {
"x": 284,
"y": 144
},
"props": {
"url": "/wechatShare/getShareInfo/v2",
"params": {
"type": "map",
"value": {}
}
},
"output": {
"success": [
"d1eb90cd-9bbb-41a9-a43d-6a87cfe8510a"
]
}
},
"303b8a54-5d14-4bb1-b2ad-72e54b5d4faf": {
"uuid": "303b8a54-5d14-4bb1-b2ad-72e54b5d4faf",
"meta": "ab7b55eb-5e38-4028-815f-0ba3f6e1c998",
"design": {
"x": 119,
"y": 114
},
"props": {},
"output": {
"success": [
"0ef79170-f204-4a63-8317-4714dd4114b4"
]
}
}
},
"subEntry": "345ffd18-6e91-4a6e-8469-12d0e9f76e73",
"metas": [
{
"id": "66e003c5-4cd2-41cf-94e4-2c42d6d0112d",
"script": "//alert(JSON.stringify(args))\n\nwx.config({\n debug: props.debug,\n appId: args.wxappid,\n timestamp: args.wxtimestamp,\n nonceStr: args.wxnonceStr,\n signature: args.wxsignature,\n jsApiList: ['checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage']\n});\n\nwx.error(function(res){\n\talert(JSON.stringify(res))\n});\n\nnext('success');",
"props": {
"debug": {
"type": "boolean",
"alias": "调试模式"
}
},
"isInline": true,
"name": "设置微信环境",
"output": [
"success"
]
},
{
"id": "ab7b55eb-5e38-4028-815f-0ba3f6e1c998",
"script": "next('success', {\n params: {\n url: encodeURIComponent(location.href)\n }\n});",
"props": {},
"isInline": true,
"name": "获取当前链接",
"output": [
"success"
]
}
]
}
\ No newline at end of file
......@@ -4,15 +4,15 @@
let targetNode = props.target || target;
if (targetNode) {
const {scriptsProxy} = targetNode;
const {scripts} = targetNode;
const {scriptIndex, scriptName, enabled} = props;
if (scriptIndex !== undefined) {
let script = scriptsProxy.all[scriptIndex];
let script = scripts.all[scriptIndex];
if (script) {
script.disabled = !enabled;
}
} else if (scriptName !== undefined) {
let scripts = scriptsProxy.get(scriptName);
let scripts = scripts.get(scriptName);
for(let script of scripts){
script.disabled = !enabled;
}
......
......@@ -4,13 +4,13 @@
let targetNode = props.target || target;
if (targetNode) {
const {scriptsProxy} = targetNode;
const {scripts} = targetNode;
const {scriptIndex, scriptName, enabled} = props;
let script;
if (scriptIndex !== undefined) {
script = scriptsProxy.all[scriptIndex];
script = scripts.all[scriptIndex];
} else if (scriptName !== undefined) {
script = scriptsProxy.get(scriptName);
script = scripts.get(scriptName);
}
if (script) {
const {field, valueType, value} = props;
......
......@@ -5,24 +5,56 @@
export default class BuriedPoint extends engine.ScriptBase {
static id = 'buried-point';
@engine.dirtyFieldTrigger
dpm: string = '0.0.0.0';
@engine.dirtyFieldTrigger
dcm: string = '0.0.0.0';
@engine.dirtyFieldTrigger
dom: string = '0.0.0.0';
mounted() {
this.dpm && (this.dpm = fill(this.dpm));
this.dcm && (this.dcm = fill(this.dcm));
this.dom && (this.dom = fill(this.dom));
autoExposure:boolean = true;
autoClick:boolean = true;
onModify(value, key, oldValue) {
switch (key) {
case 'dpm':
case 'dcm':
case 'dom':
this['__' + key] = fill(value);
break;
}
}
mounted() {
this.host.addEventListener(engine.MouseEvent.CLICK, this._onClick, this);
}
awake(): void {
log('exposure', this);
if(this.autoExposure){
this.logExposure();
}
}
private _onClick(e) {
log('click', this);
if(this.autoClick){
this.logClick();
}
}
logExposure(){
this.log('exposure');
}
logClick(){
this.log('click');
}
log(type) {
log(type, {
dpm: this['__dpm'],
dcm: this['__dcm'],
dom: this['__dom'],
});
}
}
......
......@@ -15,6 +15,16 @@
"alias": "DOM",
"type": "string",
"default": "0.0.0.0"
},
"autoExposure": {
"alias": "自动曝光",
"type": "boolean",
"default": true
},
"autoClick": {
"alias": "自动点击",
"type": "boolean",
"default": true
}
}
}
\ No newline at end of file
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