Commit e600c203 authored by rockyl's avatar rockyl

增加自定义模块参数配置功能

parent 1ef1fdb8
...@@ -149,6 +149,9 @@ var module = { ...@@ -149,6 +149,9 @@ var module = {
function getAssetByUUID(uuid){ function getAssetByUUID(uuid){
return engine.resolveCustomAsset('${id}', uuid); return engine.resolveCustomAsset('${id}', uuid);
} }
function getProps(){
return engine.getProps('${id}');
}
${code} ${code}
})(module); })(module);
...@@ -276,10 +279,17 @@ async function divideCode(data, {debug, compile, uglify, getProcesses, getScript ...@@ -276,10 +279,17 @@ async function divideCode(data, {debug, compile, uglify, getProcesses, getScript
data.customs = customMetas.map(item => { data.customs = customMetas.map(item => {
const custom = typeof item === 'string' ? JSON.parse(item) : item; const custom = typeof item === 'string' ? JSON.parse(item) : item;
customManager.deal(custom); customManager.deal(custom);
let assetMapping = customs.find(c => c.id === custom.id).assetMapping; let {props, assetMapping} = customs.find(c => c.id === custom.id);
for(let uuid in assetMapping){ if (props) {
let asset = custom.assets.find(item=>item.uuid === uuid); for (let key in custom.props) {
if(asset){ if (!props.hasOwnProperty(key) && custom.props[key].hasOwnProperty('default')) {
props[key] = custom.props[key].default;
}
}
}
for (let uuid in assetMapping) {
let asset = custom.assets.find(item => item.uuid === uuid);
if (asset) {
asset.url = assetMapping[uuid]; asset.url = assetMapping[uuid];
} }
} }
...@@ -287,6 +297,7 @@ async function divideCode(data, {debug, compile, uglify, getProcesses, getScript ...@@ -287,6 +297,7 @@ async function divideCode(data, {debug, compile, uglify, getProcesses, getScript
id: custom.id, id: custom.id,
name: custom.name, name: custom.name,
assets: custom.assets, assets: custom.assets,
props,
}; };
}); });
} }
......
This diff is collapsed.
...@@ -155,6 +155,9 @@ var module = { ...@@ -155,6 +155,9 @@ var module = {
function getAssetByUUID(uuid){ function getAssetByUUID(uuid){
return engine.resolveCustomAsset('${id}', uuid); return engine.resolveCustomAsset('${id}', uuid);
} }
function getProps(){
return engine.getProps('${id}');
}
${code} ${code}
})(module); })(module);
...@@ -282,10 +285,17 @@ async function divideCode(data, {debug, compile, uglify, getProcesses, getScript ...@@ -282,10 +285,17 @@ async function divideCode(data, {debug, compile, uglify, getProcesses, getScript
data.customs = customMetas.map(item => { data.customs = customMetas.map(item => {
const custom = typeof item === 'string' ? JSON.parse(item) : item; const custom = typeof item === 'string' ? JSON.parse(item) : item;
customManager.deal(custom); customManager.deal(custom);
let assetMapping = customs.find(c => c.id === custom.id).assetMapping; let {props, assetMapping} = customs.find(c => c.id === custom.id);
for(let uuid in assetMapping){ if (props) {
let asset = custom.assets.find(item=>item.uuid === uuid); for (let key in custom.props) {
if(asset){ if (!props.hasOwnProperty(key) && custom.props[key].hasOwnProperty('default')) {
props[key] = custom.props[key].default;
}
}
}
for (let uuid in assetMapping) {
let asset = custom.assets.find(item => item.uuid === uuid);
if (asset) {
asset.url = assetMapping[uuid]; asset.url = assetMapping[uuid];
} }
} }
...@@ -293,6 +303,7 @@ async function divideCode(data, {debug, compile, uglify, getProcesses, getScript ...@@ -293,6 +303,7 @@ async function divideCode(data, {debug, compile, uglify, getProcesses, getScript
id: custom.id, id: custom.id,
name: custom.name, name: custom.name,
assets: custom.assets, assets: custom.assets,
props,
}; };
}); });
} }
......
This diff is collapsed.
...@@ -155,6 +155,9 @@ var module = { ...@@ -155,6 +155,9 @@ var module = {
function getAssetByUUID(uuid){ function getAssetByUUID(uuid){
return engine.resolveCustomAsset('${id}', uuid); return engine.resolveCustomAsset('${id}', uuid);
} }
function getProps(){
return engine.getProps('${id}');
}
${code} ${code}
})(module); })(module);
...@@ -282,10 +285,17 @@ ${scripts} ...@@ -282,10 +285,17 @@ ${scripts}
data.customs = customMetas.map(item => { data.customs = customMetas.map(item => {
const custom = typeof item === 'string' ? JSON.parse(item) : item; const custom = typeof item === 'string' ? JSON.parse(item) : item;
customManager.deal(custom); customManager.deal(custom);
let assetMapping = customs.find(c => c.id === custom.id).assetMapping; let {props, assetMapping} = customs.find(c => c.id === custom.id);
for(let uuid in assetMapping){ if (props) {
let asset = custom.assets.find(item=>item.uuid === uuid); for (let key in custom.props) {
if(asset){ if (!props.hasOwnProperty(key) && custom.props[key].hasOwnProperty('default')) {
props[key] = custom.props[key].default;
}
}
}
for (let uuid in assetMapping) {
let asset = custom.assets.find(item => item.uuid === uuid);
if (asset) {
asset.url = assetMapping[uuid]; asset.url = assetMapping[uuid];
} }
} }
...@@ -293,6 +303,7 @@ ${scripts} ...@@ -293,6 +303,7 @@ ${scripts}
id: custom.id, id: custom.id,
name: custom.name, name: custom.name,
assets: custom.assets, assets: custom.assets,
props,
}; };
}); });
} }
......
This diff is collapsed.
...@@ -23,6 +23,9 @@ var module = { ...@@ -23,6 +23,9 @@ var module = {
function getAssetByUUID(uuid){ function getAssetByUUID(uuid){
return engine.resolveCustomAsset('${id}', uuid); return engine.resolveCustomAsset('${id}', uuid);
} }
function getProps(){
return engine.getProps('${id}');
}
${code} ${code}
})(module); })(module);
......
...@@ -100,10 +100,17 @@ export async function divideCode(data, {debug, compile, uglify, getProcesses, ge ...@@ -100,10 +100,17 @@ export async function divideCode(data, {debug, compile, uglify, getProcesses, ge
data.customs = customMetas.map(item => { data.customs = customMetas.map(item => {
const custom = typeof item === 'string' ? JSON.parse(item) : item; const custom = typeof item === 'string' ? JSON.parse(item) : item;
customManager.deal(custom); customManager.deal(custom);
let assetMapping = customs.find(c => c.id === custom.id).assetMapping; let {props, assetMapping} = customs.find(c => c.id === custom.id);
for(let uuid in assetMapping){ if (props) {
let asset = custom.assets.find(item=>item.uuid === uuid); for (let key in custom.props) {
if(asset){ if (!props.hasOwnProperty(key) && custom.props[key].hasOwnProperty('default')) {
props[key] = custom.props[key].default;
}
}
}
for (let uuid in assetMapping) {
let asset = custom.assets.find(item => item.uuid === uuid);
if (asset) {
asset.url = assetMapping[uuid]; asset.url = assetMapping[uuid];
} }
} }
...@@ -111,6 +118,7 @@ export async function divideCode(data, {debug, compile, uglify, getProcesses, ge ...@@ -111,6 +118,7 @@ export async function divideCode(data, {debug, compile, uglify, getProcesses, ge
id: custom.id, id: custom.id,
name: custom.name, name: custom.name,
assets: custom.assets, assets: custom.assets,
props,
}; };
}) })
} }
......
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