Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, contentDiv.children, true);
// fetch all images
const urls = Object.keys(imageUrls);
const promises: Promise[] = urls.map(url => {
console.log(`fetchArticle - fetching image from ${url}`);
return fetch.buffer(url, "GET").then(image => {
const imageFileName = imageUrls[url];
const imageFilePath = this.getFilePath(imageFileName);
console.log(`fetchArticle - writing image to ${imageFilePath}`);
return fs.writeFile(imageFilePath, Buffer.from(image))
});
});
// write article HTML content
const contentHtml = DomUtils.getInnerHTML(contentDiv);
const articleFileName = `${this.articlesDir}/article-${articleIndex}.html`;
this.result.files[`scene_${articleFileName}`] = articleFileName;
const articleFilePath = this.getFilePath(articleFileName);
promises.push(fs.writeFile(articleFilePath, contentHtml));
return Promise.all(promises);
}
}, contentDiv.children, true);
// fetch all images
const urls = Object.keys(imageUrls);
const promises: Promise[] = urls.map(url => {
console.log(`fetchArticle - fetching image from ${url}`);
return fetch.buffer(url, "GET").then(image => {
const imageFileName = imageUrls[url];
const imageFilePath = path.resolve(context.job.jobDir, imageFileName);
console.log(`fetchArticle - writing image to ${imageFilePath}`);
return fs.writeFile(imageFilePath, Buffer.from(image))
});
});
// write article HTML content
const contentHtml = DomUtils.getInnerHTML(contentDiv);
const articleFileName = `${context.articleDir}/article-${articleIndex}.html`;
context.files[articleFileName] = articleFileName;
const articleFilePath = path.resolve(context.job.jobDir, articleFileName);
promises.push(fs.writeFile(articleFilePath, contentHtml));
return Promise.all(promises);
}
let attrKeys = Object.keys(attribs)
/**
* 抽象组件处理
* 如果作死有这个鬼那就ooo了
*/
if (/generic:/.test(attrKeys.join(';'))) {
attrKeys.forEach(key => {
/generic:/.test(key) && tags.push(attribs[key])
})
}
handle && handle(componnets, el, componnets.has(name), this.request)
})
content = DomUtils.getInnerHTML({ children: dom })
tags.length && this.writeToComponent(tags)
return new ConcatSource(content)
}
}
if (dom.length > 1) {
dom = [{
type: 'tag',
name: 'view',
attribs: {
class: '{{ rootClass }}',
id: '{{ id }}',
onTap: '$_tap',
'data-parent': '{{ parentData }}'
},
children: dom
}]
}
}
content = DomUtils.getInnerHTML({
children: dom
})
assets[distPath] = new ConcatSource(content)
}
for (const file of tree.jsons) {
let fileMeta = tree.getFile(file)
if (fileMeta.generics.size) {
let wxmlPath = file.replace('.json', '.wxml')
let distJsonPath = toTargetPath(utils.getDistPath(file))
let distWxmlPath = toTargetPath(utils.getDistPath(wxmlPath))
let jsonFileContent = JSON.parse(getAssetContent(file, compilation))
let wxmlFileContent = assets[distWxmlPath].source().toString()
<${propName} />
`, (el) => {
if (el.name === propName) {
el.attribs = { ...attribs }
el.children = children
}
})
parent.children.splice(index, 0, genericDom[0])
})
attribs['a:else'] = 'true'
}
})
DomUtils.getInnerHTML({ children: dom })
return new ConcatSource(DomUtils.getInnerHTML({ children: dom }))
}
`, (el) => {
if (el.name === propName) {
el.attribs = { ...attribs }
el.children = children
}
})
parent.children.splice(index, 0, genericDom[0])
})
attribs['a:else'] = 'true'
}
})
DomUtils.getInnerHTML({ children: dom })
return new ConcatSource(DomUtils.getInnerHTML({ children: dom }))
}