新增文件列表解析接口/v2/getFileList?url=

This commit is contained in:
QAIU
2025-02-07 19:27:48 +08:00
parent 577ec46f71
commit 8dbcaed813
11 changed files with 428 additions and 75 deletions

View File

@@ -0,0 +1,18 @@
package cn.qaiu.util;
/**
* 转换为任意类型 旨在消除泛型转换时的异常
*/
public interface CastUtil {
/**
* 泛型转换
* @param object 要转换的object
* @param <T> T
* @return T
*/
@SuppressWarnings("unchecked")
static <T> T cast(Object object) {
return (T) object;
}
}

View File

@@ -0,0 +1,35 @@
package cn.qaiu.util;
public class FileSizeConverter {
public static long convertToBytes(String sizeStr) {
if (sizeStr == null || sizeStr.isEmpty()) {
throw new IllegalArgumentException("Invalid file size string");
}
sizeStr = sizeStr.trim().toUpperCase();
char unit = sizeStr.charAt(sizeStr.length() - 1);
double size = Double.parseDouble(sizeStr.substring(0, sizeStr.length() - 1));
return switch (unit) {
case 'B' -> (long) size;
case 'K' -> (long) (size * 1024);
case 'M' -> (long) (size * 1024 * 1024);
case 'G' -> (long) (size * 1024 * 1024 * 1024);
default -> throw new IllegalArgumentException("Unknown file size unit: " + unit);
};
}
public static String convertToReadableSize(long bytes) {
if (bytes < 1024) {
return bytes + " B";
} else if (bytes < 1024 * 1024) {
return String.format("%.1f K", bytes / 1024.0);
} else if (bytes < 1024 * 1024 * 1024) {
return String.format("%.1f M", bytes / (1024.0 * 1024));
} else {
return String.format("%.1f G", bytes / (1024.0 * 1024 * 1024));
}
}
}

View File

@@ -124,7 +124,10 @@ public interface JsContent {
},
ajax: function (obj) {
signObj = obj
}
},
val: function(a) {
},
}
},
@@ -134,7 +137,6 @@ public interface JsContent {
jQuery.fn.init.prototype = jQuery.fn;
// 伪装jquery.ajax函数获取关键数据
$.ajax = function (obj) {
signObj = obj
}
@@ -142,11 +144,16 @@ public interface JsContent {
var document = {
getElementById: function (v) {
return {
value: 'v'
value: 'v',
style: {
display: ''
},
addEventListener: function() {}
}
},
}
var window = {location: {}}
""";
String kwSignString = """