mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
refactor(cloudfunc) getPathLink: map -> for
This commit is contained in:
parent
d08921bde3
commit
a2586424f9
1 changed files with 15 additions and 11 deletions
|
|
@ -72,30 +72,34 @@ function getPathLink(url, prefix, template) {
|
|||
.slice(1, -1);
|
||||
|
||||
const allNames = ['/', ...names];
|
||||
const length = allNames.length - 1;
|
||||
const lines = [];
|
||||
const n = allNames.length;
|
||||
|
||||
let path = '/';
|
||||
|
||||
const pathHTML = allNames.map((name, index) => {
|
||||
const isLast = index === length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
const name = allNames[i];
|
||||
const isLast = i === n - 1;
|
||||
|
||||
if (index)
|
||||
if (i)
|
||||
path += name + '/';
|
||||
|
||||
if (index && isLast)
|
||||
return name + '/';
|
||||
if (i && isLast) {
|
||||
lines.push(name + '/');
|
||||
continue;
|
||||
}
|
||||
|
||||
const slash = index ? '/' : '';
|
||||
const slash = i ? '/' : '';
|
||||
|
||||
return rendy(template, {
|
||||
lines.push(rendy(template, {
|
||||
path,
|
||||
name,
|
||||
slash,
|
||||
prefix,
|
||||
});
|
||||
}).join('');
|
||||
}));
|
||||
}
|
||||
|
||||
return pathHTML;
|
||||
return lines.join('');
|
||||
}
|
||||
|
||||
const getDataName = (name) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue