Commit e600c203 authored by rockyl's avatar rockyl

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

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