Commit c59885af authored by 王梦佳's avatar 王梦佳

娃娃机

parents 8b42bb0e 1666d831
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
## 一、工程目录 http://gitlab2.dui88.com/laoqifeng/zeroing-libs
切换`dev`分支,在`dev`分支新增修改
## 二、文件路径及大概用途
- 1、`dist`文件下即为打包后的json用于发布版本使用
- 2、src为代码路径
* 1、`src/custom` 为所有自定义模块的源码,也是新增或修改的代码路径
* 2、`src/custom` 路径下每一个自定义模块单独一个项目名字文件夹
- 3、通用代码脚本
* 1、`meta.json`文件
- 1、`name`为项目名字
- 2、`desc` 为项目描述
- 3、`props` 为配置属性,提供对外可配置内容
- 4、`assets` 为资源加载属性,加载路径需跟`uuid`相匹配,注意对应类型
- 5、`events` 为事件属性,与外界用事件传递消息,注意每个模块的时间名
* 2、`debug文件`
- 1、该文件是本地运行使用文件
- 2、可修改`app.js`文件里的事件名,而去执行对应的模块代码
* 3、`src/custom/src`为每个模块的项目代码
- 1、`index.ts`为初始化脚本可以通用
- 2、`props.ts`为获取meta.json文件中的配置使用,可通用的脚本
- 3、`game`文件为自身项目的逻辑代码
## 三、本地运行
- 1、安装本地启动服务`game-cli` 地址:http://cf.dui88.com/display/dbyw/game-cli
- 2、运行http服务,执行src/custom下对应的自定义模块下的`debug`文件
- 3、`yarn build-custom -s 模块名 -w` 为保存档次代码修改也为打包指令
- 4、执行保存指令后在浏览器刷新图标处右键选择`清空缓存`并硬性重新加载,这样可以 保证运行最新修改的代码(劳工手工传授)
## 四、代码执行过程
- 1、入口为`app.js` 读取meta.json文件下的配置,加载对应资源,添加自定义模块
- 2、配置加载成功后使用引擎api将对应模块添加到显示到显示舞台
- 3、而后执行src/custom/对应模块`/src/index.ts` 初始化项目所需要的东西
- 4、而后执行props.ts获取meta.json中的props配置
- 5、而后创建项目逻辑入口脚本实例(例如GameWrapper)
- 6、而后即为对应模块逻辑代码
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -14,13 +14,18 @@
"type": "boolean",
"alias": "是否捕获",
"default": true
},
"isGlobal": {
"type": "boolean",
"alias": "是否全局",
"default": true
}
},
"output": [
"success"
],
"id": "dispatch-event",
"script": "var eventName = engine.findVariable('eventName', args, props);\nvar data = engine.findVariable('data', args, props);\nvar useCapture = engine.findVariable('useCapture', args, props);\nif (eventName) {\n engine.globalEvent.dispatchEvent(eventName, data, useCapture);\n}\nnext('success', args);\n",
"script": "var eventName = engine.findVariable('eventName', args, props);\nvar data = engine.findVariable('data', args, props);\nvar useCapture = engine.findVariable('useCapture', args, props);\nvar isGlobal = engine.findVariable('isGlobal', args, props);\nif (eventName) {\n var sender = isGlobal ? engine.globalEvent : target;\n sender.dispatchEvent(eventName, data, useCapture);\n}\nnext('success', args);\n",
"group": "base",
"type": "builtin"
}
{
"props": {},
"props": {
"map": {
"alias": "UA包含表",
"type": "map"
}
},
"name": "环境判断",
"output": [
"success"
],
"id": "env-judge",
"script": "var ua = navigator.userAgent.toLowerCase();\nvar env;\nif (ua.indexOf('eversunshine') >= 0) {\n env = 'eversunshine';\n}\nelse if (ua.indexOf('micromessenger') >= 0) {\n env = 'weixin';\n}\nconsole.log('env:', env);\nvar payload = args || {};\npayload.env = env;\nnext('success', payload);\n",
"script": "var map = engine.findVariable('map', args, props);\nvar ua = navigator.userAgent.toLowerCase();\nvar env;\nif (map) {\n for (var key in map) {\n if (ua.indexOf(key) >= 0) {\n env = map[key];\n break;\n }\n }\n}\nvar payload = args || {};\npayload.env = env;\nnext('success', payload);\n",
"group": "base",
"type": "builtin"
}
......@@ -121,7 +121,7 @@
"metas": [
{
"id": "duiba-api-transform",
"script": "if (args.success) {\n next('success', args.data);\n}\nelse {\n\tengine.globalEvent.dispatchEvent('net-failed', args);\n next('failed', args);\n}\n",
"script": "if (args.success) {\n\tvar payload;\n\n\tif (args.data && typeof args.data === 'object') {\n\t\tpayload = engine.objClone(args.data);\n\n\t\tvar origin = engine.objClone(args);\n\t\tObject.defineProperty(payload, '__origin', {\n\t\t\tget: function () {\n\t\t\t\treturn origin\n\t\t\t},\n\t\t\tenumerable: false\n\t\t});\n\t} else {\n\t\tpayload = args.data;\n\t}\n\tnext('success', payload);\n}\nelse {\n\tengine.globalEvent.dispatchEvent('net-failed', args);\n\tnext('failed', args);\n}",
"props": {},
"isInline": true,
"name": "兑吧接口转换",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"script": "var bizIdMap = {\n\t'sharePage': '506',\n\t'pageRemain': '156'\n}\n\nvar bizId = bizIdMap[props.id];\n\nif(bizId){\n\tengine.accessLog(bizId);\n}\n\nnext('success');\n",
"props": {
"id": {
"type": "enum",
"enum": [
"sharePage",
"pageRemain"
],
"alias": "类型",
"default": "sharePage"
}
},
"name": "访问日志接口",
"output": [
"success"
],
"id": "access-log",
"group": "projectX",
"type": "builtin"
}
......@@ -66,6 +66,9 @@
},
"uri": {
"type": "link"
},
"params": {
"type": "link"
}
},
"output": {
......@@ -74,8 +77,8 @@
]
},
"design": {
"x": 160,
"y": 199
"x": 275,
"y": 204
}
},
"f9a32b46-aec1-4bd2-9b98-3d9a427d87db": {
......@@ -105,8 +108,8 @@
},
"output": {},
"design": {
"x": 489,
"y": 107
"x": 507,
"y": 115
}
}
},
......@@ -114,11 +117,15 @@
"metas": [
{
"id": "a4b27753-4cbb-47e3-9b31-51ced475e41a",
"script": "var uri = engine.findVariable('uri', args, props);\nvar url;\n\nvar hash = window.location.hash;\ntry {\n\thash = top.location.hash;\n} catch (e) {\n}\nvar pathname = window.location.pathname;\ntry {\n\tpathname = top.location.pathname;\n} catch (e) {\n}\n\nif(uri.indexOf('//') !== 0 && uri.indexOf('://') < 0 && pathname === '/preview' || hash.indexOf('preview/') >= 0){\n\tvar projectX = 'projectx';\n\tvar projectID = engine.env.projectID;\n url = engine.joinPath(projectX, projectID, uri);\n}else{\n url = uri;\n}\n\nscope.url = url;\n\nnext('success', args);",
"script": "var uri = engine.findVariable('uri', args, props);\nvar url;\n\nvar hash = window.location.hash;\ntry {\n\thash = top.location.hash;\n} catch (e) {\n}\nvar pathname = window.location.pathname;\ntry {\n\tpathname = top.location.pathname;\n} catch (e) {\n}\n\nif(uri.indexOf('//') !== 0 && uri.indexOf('://') < 0 && pathname === '/preview' || hash.indexOf('preview/') >= 0){\n\tvar projectX = 'projectx';\n\tvar projectID = engine.env.projectID;\n url = engine.joinPath(projectX, projectID, uri);\n}else{\n url = uri;\n}\n\nscope.url = url;\n\nvar params = engine.findVariable('params', args, props);\nif (!params) {\n\tparams = {};\n}\nparams.user_type = global.env.newUser ? '0' : '1';\nparams.is_from_share = global.env.fromShare ? '0' : '1';\nif(args === undefined || args === null){\n\targs = {}\n}\nargs.params = params;\n\nnext('success', args);",
"props": {
"uri": {
"type": "string",
"alias": "URI"
},
"params": {
"type": "map",
"alias": "参数"
}
},
"isInline": true,
......
{
"name": "获取星速台Token",
"props": {
"comment": {
"type": "string",
"alias": "星速台通用token"
}
},
"output": [
"success",
"failed",
"invalid",
"error"
],
"id": "px-token",
"script": "if (top.location.href.indexOf('preview') >= 0) {\n scope.token = 'dev-token';\n next('success', args);\n}\nelse {\n if (window['getPxToken']) {\n window['getPxToken'](function (e, token) {\n switch (e) {\n case 'net error':\n next('error', { type: 'error' });\n break;\n case 'need login':\n next('failed', { type: 'failed' });\n break;\n case 'state invalid':\n next('invalid', { type: 'invalid' });\n break;\n default:\n if (token) {\n scope.token = token;\n next('success', args);\n }\n else {\n next('invalid', { type: 'invalid key' });\n }\n }\n });\n }\n else {\n next('error', { type: 'no ready' });\n }\n}\n",
"group": "projectX",
"type": "builtin"
}
......@@ -19,7 +19,7 @@
"complete"
],
"id": "add-custom-module",
"script": "var p = engine.findVariable('props', args, props);\nengine.addCustomModule(props.id, props.target || target, p);\nnext('complete');\n",
"script": "var p = engine.findVariable('props', args, props);\nvar id = engine.findVariable('id', args, props);\nvar target2 = engine.findVariable('target', args, props);\nengine.addCustomModule(id, target2 || target, p);\nnext('complete');\n",
"group": "view",
"type": "builtin"
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
declare function getAssetByUUID(uuid: string);
declare function getAssetByName(name: string);
declare function getProps():any;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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