Commit 08995a53 authored by haiyoucuv's avatar haiyoucuv
parents eea0db13 db960913
......@@ -444,7 +444,8 @@ export namespace RES {
//@ts-ignore
var data: SkinInt = typeof (skin) == 'string' ? getSkinDataByName(skin) : skin;
if (!data.children || !data.children.length) return;
for (var i = data.children.length - 1; i >= 0; i--) {
// for (var i = data.children.length - 1; i >= 0; i--) {
for (var i = 0; i < data.children.length; i++) {
var child = data.children[i];
if (child.type == "skin") continue;
var dis = con.addChild(getDisplayByData(child));
......
var fs = require("fs");
var iconv = require('iconv-lite');
//读取json文件
var data = iconv.decode(fs.readFileSync("./resource/skin.json"), "utf-8");//GBK
//反序列化
data = JSON.parse(data); //eval(data)
reverseChildren(data);
const outJsonData = JSON.stringify(data, "", "\t");
var endPath = './src/';
var endFile = `export const SkinJson = ${outJsonData}`
fs.writeFileSync(endPath + "SkinJson.ts", endFile);
/**
*
* @param {*} arr
*/
function reverseChildren(arr) {
arr.children.reverse();
arr.children.forEach(element => { if (element.children && element.children.length) reverseChildren(element) });
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ var PSD = require('psd');
var path = require('path');
// const mkdirp = require('mkdirp');
//千万别再执行,否则覆盖
// return
return
var options = {
//导出图片的目录,没有就导在psd所在目录
outImgDir: "./resource/",
......@@ -50,6 +50,8 @@ files.forEach(async function (psdFileName) {
} else {
const groupName = rootNode._children[i].name;
//颠倒一下
// group111._children.reverse()
queueNodes.push(group111._children);
queueNodesIndex.push(0);
queueNodesName.push(undefined);
......@@ -113,6 +115,8 @@ files.forEach(async function (psdFileName) {
}
//单纯的组
else {
//颠倒一下
// node._children.reverse()
queueNodes.push(node._children);
queueNodesIndex[queueIndex] = nodesIndex;
queueNodesIndex.push(0);
......@@ -263,6 +267,8 @@ files.forEach(async function (psdFileName) {
//导出所有的数据
if (options.outJsonDir) {
//倒转一下所有children的层级
const outJsonData = JSON.stringify(rootStructure/*.group*/, "", "\t");
const outJsonDirPath = path.resolve(options.outJsonDir);
const outJsonPath = path.join(outJsonDirPath, 'skin.json');
......@@ -300,3 +306,8 @@ function saveAsPng(dirName, name, node, format = "png") {
}
function reverseChildren(arr) {
arr.reverse();
if (arr.children) reverseChildren(arr.children)
}
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