- 以 TabBar + 三个视图(任务/搜索/设置)替换原有 DashBoard/Side/HentaiSearch 单页结构 - 拆分 TaskView / TaskRow / TaskDetailSheet / SearchView / SettingsView / AuthScreen - 统一 theme.css 视觉规范,补 AppIcon 与缩略图工具 thumbnail.js 及其单测 - 提交弹层默认选中最高可用分辨率,缩略图加载失败走占位 - E站搜索结果与远端抽屉补回「在线看」入口
28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
const BaseUrl = "https://downloader.lionwebsite.xyz/";
|
|
|
|
// Remote galleries carry a raw thumbnail path; it only resolves through the
|
|
// backend proxy once the active auth code is attached.
|
|
export function ehThumbnailUrl(path, AuthCode) {
|
|
if (!path) return "";
|
|
return BaseUrl + "GalleryManage/ehThumbnail?" + new URLSearchParams({path, AuthCode}).toString();
|
|
}
|
|
|
|
const UNIT_SCALE = {b: 1, k: 1024, m: 1024 ** 2, g: 1024 ** 3, t: 1024 ** 4};
|
|
|
|
function sizeInBytes(text) {
|
|
const match = String(text).match(/([\d.]+)\s*([kmgt]?)(?:i?b)/i);
|
|
if (!match) return 0;
|
|
const scale = UNIT_SCALE[match[2].toLowerCase()] ?? 1;
|
|
return Number(match[1]) * scale;
|
|
}
|
|
|
|
// Prefer the original file; otherwise take whichever entry reports the most bytes.
|
|
export function pickDefaultResolution(availableResolution) {
|
|
const entries = Object.entries(availableResolution || {});
|
|
if (entries.length === 0) return "";
|
|
const original = entries.find(([resolution]) => /original/i.test(resolution));
|
|
if (original) return original[0];
|
|
return entries.reduce((best, current) =>
|
|
sizeInBytes(current[1]) > sizeInBytes(best[1]) ? current : best)[0];
|
|
}
|