代码拉取完成,页面将自动刷新
同步操作将从 D2C/lens 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* @Author: 左盐
* @LastEditors: 左盐
*/
const fs = require('fs-extra');
const path = require('path');
const chalk = require('chalk');
const ParseSketch = require('./parserSketch/layer');
const ParseLayer = require('./parseLayer/index');
// const uniapp = require('./render/uniapp/index');
const RenderMobile = require('./render/mobile/index');
const HtmlDsl = require('./render/base/index.js');
module.exports = class SketchToDsl {
constructor(sketch = {}, platform = '', artboardName = '') {
this.sketch = sketch;
this.artboardName = artboardName;
this.platform = platform;
}
async saveToJson() {
const pathSrc = yunjin.config.source.path.split('/');
pathSrc.pop();
let toPath = pathSrc.join(path.sep) + path.sep + 'files';
toPath = yunjin.WORK_RUNTIME_UIDSL;
fs.ensureDirSync(toPath);
await this.sketch.saveDir(toPath);
}
async parseLayer() {
try {
await this.saveToJson();
const parseSketch = new ParseSketch(this.sketch);
const artboardList = parseSketch.pageArtboard(this.artboardName);
for (let i = 0, len = artboardList.length; i < len; i++) {
const artboardItem = artboardList[i];
console.log(chalk.green.bold('开始智能编排[' + artboardItem.name + '](' + (i + 1) + '/' + len + ')'));
yunjin.config.target.artboardName = artboardItem.name.replace(/ /ig, 'nbsp');
const element = await parseSketch.parse(artboardItem);
// / / const parseLayer = new ParseLayer(element);
const parseLayer = new ParseLayer();
const result = await parseLayer.formatLayers();
const htmlDsl = new HtmlDsl();
await htmlDsl.render();
const spinner = await tools.loading('输出目标页面');
// html5一定会生成,用来做preview
const renderMobile = new RenderMobile();
await renderMobile.render();
let uniapp = null;
if (yunjin.config.target.platform === 'h5') {
uniapp = require('./render/mobile/index');
} else {
uniapp = require('./render/uniapp/index');
const a = new uniapp();
await a.render();
}
spinner.succeed('输出目标页面');
}
} catch (e) {
console.log(e);
}
}
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。