mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(cloudcmd) readify: add support of links
This commit is contained in:
parent
03685ee390
commit
52ffc2ac28
5 changed files with 31 additions and 23 deletions
|
|
@ -188,8 +188,8 @@ module.exports.buildFromJSON = (params) => {
|
|||
const name = encode(file.name);
|
||||
const link = prefix + FS + path + name;
|
||||
|
||||
const type = getType(file.size);
|
||||
const size = getSize(file.size);
|
||||
const {type} = file;
|
||||
const size = getSize(file);
|
||||
|
||||
const date = file.date || '--.--.----';
|
||||
const owner = file.owner || 'root';
|
||||
|
|
@ -199,7 +199,7 @@ module.exports.buildFromJSON = (params) => {
|
|||
link,
|
||||
title: name,
|
||||
name,
|
||||
attribute: getAttribute(file.size)
|
||||
attribute: getAttribute(file.type)
|
||||
});
|
||||
|
||||
const dataName = getDataName(file.name);
|
||||
|
|
@ -223,22 +223,20 @@ module.exports.buildFromJSON = (params) => {
|
|||
return fileTable;
|
||||
};
|
||||
|
||||
function getType(size) {
|
||||
if (size === 'dir')
|
||||
return 'directory';
|
||||
|
||||
return 'text-file';
|
||||
}
|
||||
|
||||
function getAttribute(size) {
|
||||
if (size === 'dir')
|
||||
function getAttribute(type) {
|
||||
if (type === 'directory')
|
||||
return '';
|
||||
|
||||
return 'target="_blank" ';
|
||||
}
|
||||
|
||||
function getSize(size) {
|
||||
if (size === 'dir')
|
||||
function getSize(file) {
|
||||
const {
|
||||
size,
|
||||
type,
|
||||
} = file;
|
||||
|
||||
if (type === 'directory')
|
||||
return '<dir>';
|
||||
|
||||
return size;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue