Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
modulesServer
Overview
Overview
Details
Activity
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
standardized
modulesServer
Commits
47cccd4a
Commit
47cccd4a
authored
Dec 17, 2021
by
chenjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
92d20503
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
directory.ts
src/directory.ts
+45
-0
No files found.
src/directory.ts
0 → 100644
View file @
47cccd4a
const
fs
=
require
(
"fs"
);
const
path
=
require
(
"path"
);
//创建文件目录
export
async
function
mkPath
(
uid
,
picName
)
{
let
picPath
;
let
picType
;
for
(
let
i
=
0
;
i
<
2
;
i
++
)
{
if
(
i
==
0
)
picType
=
`png/
${
picName
}
.png`
;
if
(
i
>
0
)
picType
=
`psd/
${
picName
}
.psd`
;
let
date
=
new
Date
();
let
imgFile
=
`
${
date
.
getFullYear
()}${
date
.
getMonth
()
+
1
}${
date
.
getDate
()}
`
;
picPath
=
path
.
join
(
`res/
${
imgFile
}
/
${
uid
}
/
${
picType
}
`
);
//转变成数组,如 ['res', 'imgFile', '1212']
let
parts
=
picPath
.
split
(
path
.
sep
);
for
(
let
i
=
1
;
i
<=
parts
.
length
;
i
++
)
{
//重新拼接成 res res/imgFile res/imgFile/1212
let
current
=
parts
.
slice
(
0
,
i
).
join
(
path
.
sep
);
fs
.
access
(
current
,
(
err
)
=>
{
if
(
err
){
console
.
log
(
"文件目录不存在"
)
fs
.
mkdir
(
current
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'创建文件目录失败'
);
}
else
{
console
.
log
(
'创建文件目录完成'
);
}
})
}
else
{
console
.
log
(
'文件目录已存在'
)
}
})
}
}
console
.
log
(
picPath
);
return
picPath
;
}
function
test
(
uid
,
picName
)
{
// let suffix = picName.slice(picName.lastIndexOf("."));
}
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