Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
babycare_xiaoxiao
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王剑峰
babycare_xiaoxiao
Commits
db960913
Commit
db960913
authored
Jul 07, 2020
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
436e3050
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1610 additions
and
550 deletions
+1610
-550
RES.ts
module/RES.ts
+2
-1
aa.js
scripts/aa.js
+22
-0
psdH.js
scripts/psdH.js
+12
-1
SkinJson.1.ts
src/SkinJson.1.ts
+1026
-0
SkinJson.ts
src/SkinJson.ts
+548
-548
No files found.
module/RES.ts
View file @
db960913
...
@@ -444,7 +444,8 @@ export namespace RES {
...
@@ -444,7 +444,8 @@ export namespace RES {
//@ts-ignore
//@ts-ignore
var
data
:
SkinInt
=
typeof
(
skin
)
==
'string'
?
getSkinDataByName
(
skin
)
:
skin
;
var
data
:
SkinInt
=
typeof
(
skin
)
==
'string'
?
getSkinDataByName
(
skin
)
:
skin
;
if
(
!
data
.
children
||
!
data
.
children
.
length
)
return
;
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
];
var
child
=
data
.
children
[
i
];
if
(
child
.
type
==
"skin"
)
continue
;
if
(
child
.
type
==
"skin"
)
continue
;
var
dis
=
con
.
addChild
(
getDisplayByData
(
child
));
var
dis
=
con
.
addChild
(
getDisplayByData
(
child
));
...
...
scripts/aa.js
0 → 100644
View file @
db960913
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
scripts/psdH.js
View file @
db960913
...
@@ -3,7 +3,7 @@ var PSD = require('psd');
...
@@ -3,7 +3,7 @@ var PSD = require('psd');
var
path
=
require
(
'path'
);
var
path
=
require
(
'path'
);
// const mkdirp = require('mkdirp');
// const mkdirp = require('mkdirp');
//千万别再执行,否则覆盖
//千万别再执行,否则覆盖
//
return
return
var
options
=
{
var
options
=
{
//导出图片的目录,没有就导在psd所在目录
//导出图片的目录,没有就导在psd所在目录
outImgDir
:
"./resource/"
,
outImgDir
:
"./resource/"
,
...
@@ -50,6 +50,8 @@ files.forEach(async function (psdFileName) {
...
@@ -50,6 +50,8 @@ files.forEach(async function (psdFileName) {
}
else
{
}
else
{
const
groupName
=
rootNode
.
_children
[
i
].
name
;
const
groupName
=
rootNode
.
_children
[
i
].
name
;
//颠倒一下
// group111._children.reverse()
queueNodes
.
push
(
group111
.
_children
);
queueNodes
.
push
(
group111
.
_children
);
queueNodesIndex
.
push
(
0
);
queueNodesIndex
.
push
(
0
);
queueNodesName
.
push
(
undefined
);
queueNodesName
.
push
(
undefined
);
...
@@ -113,6 +115,8 @@ files.forEach(async function (psdFileName) {
...
@@ -113,6 +115,8 @@ files.forEach(async function (psdFileName) {
}
}
//单纯的组
//单纯的组
else
{
else
{
//颠倒一下
// node._children.reverse()
queueNodes
.
push
(
node
.
_children
);
queueNodes
.
push
(
node
.
_children
);
queueNodesIndex
[
queueIndex
]
=
nodesIndex
;
queueNodesIndex
[
queueIndex
]
=
nodesIndex
;
queueNodesIndex
.
push
(
0
);
queueNodesIndex
.
push
(
0
);
...
@@ -263,6 +267,8 @@ files.forEach(async function (psdFileName) {
...
@@ -263,6 +267,8 @@ files.forEach(async function (psdFileName) {
//导出所有的数据
//导出所有的数据
if
(
options
.
outJsonDir
)
{
if
(
options
.
outJsonDir
)
{
//倒转一下所有children的层级
const
outJsonData
=
JSON
.
stringify
(
rootStructure
/*.group*/
,
""
,
"
\
t"
);
const
outJsonData
=
JSON
.
stringify
(
rootStructure
/*.group*/
,
""
,
"
\
t"
);
const
outJsonDirPath
=
path
.
resolve
(
options
.
outJsonDir
);
const
outJsonDirPath
=
path
.
resolve
(
options
.
outJsonDir
);
const
outJsonPath
=
path
.
join
(
outJsonDirPath
,
'skin.json'
);
const
outJsonPath
=
path
.
join
(
outJsonDirPath
,
'skin.json'
);
...
@@ -300,3 +306,8 @@ function saveAsPng(dirName, name, node, format = "png") {
...
@@ -300,3 +306,8 @@ function saveAsPng(dirName, name, node, format = "png") {
}
}
function
reverseChildren
(
arr
)
{
arr
.
reverse
();
if
(
arr
.
children
)
reverseChildren
(
arr
.
children
)
}
src/SkinJson.1.ts
0 → 100644
View file @
db960913
This diff is collapsed.
Click to expand it.
src/SkinJson.ts
View file @
db960913
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment