重构图片加载逻辑,更新为本地-远程-占位图+异步下载。优先显示本地图片,没有就显示原始远程图片,还没有就使用占位图。后台自动异步下载原始图
@ -87,7 +87,8 @@ export default async function DynamicPage({ params, searchParams }) {
|
|||||||
slug_list: slugArr,
|
slug_list: slugArr,
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: pageSize,
|
page_size: pageSize,
|
||||||
downloadFiles: true // Download files for page rendering
|
downloadFiles: false,
|
||||||
|
rewriteToProxy: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@ -75,7 +75,8 @@ export default async function Page({ params, searchParams }) {
|
|||||||
slug_list: slugArr,
|
slug_list: slugArr,
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: pageSize,
|
page_size: pageSize,
|
||||||
downloadFiles: true,
|
downloadFiles: false,
|
||||||
|
rewriteToProxy: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@ -50,7 +50,8 @@ export default async function Page() {
|
|||||||
// 获取页面数据
|
// 获取页面数据
|
||||||
const { data, error } = await getPageData({
|
const { data, error } = await getPageData({
|
||||||
slug_list: slugArr,
|
slug_list: slugArr,
|
||||||
downloadFiles: true // Download files for page rendering
|
downloadFiles: false,
|
||||||
|
rewriteToProxy: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@ -47,7 +47,9 @@ export async function GET(req, { params }) {
|
|||||||
const remoteUrl = `${BACKEND_SERVER_URL}/files/${fileName}`;
|
const remoteUrl = `${BACKEND_SERVER_URL}/files/${fileName}`;
|
||||||
const res = await fetch(remoteUrl);
|
const res = await fetch(remoteUrl);
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
return new NextResponse('Not Found', { status: 404, headers: { 'Cache-Control': 'no-store' } });
|
// 占位图(SVG),避免前端空白
|
||||||
|
const placeholder = `<svg xmlns="http://www.w3.org/2000/svg" width="800" height="450" viewBox="0 0 800 450"><rect width="800" height="450" fill="#f3f4f6"/><text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" fill="#9ca3af" font-size="20" font-family="Arial, Helvetica, sans-serif">Image unavailable</text></svg>`;
|
||||||
|
return new NextResponse(placeholder, { status: 200, headers: { 'Content-Type': 'image/svg+xml', 'Cache-Control': 'no-store' } });
|
||||||
}
|
}
|
||||||
const arrayBuffer = await res.arrayBuffer();
|
const arrayBuffer = await res.arrayBuffer();
|
||||||
const buffer = Buffer.from(arrayBuffer);
|
const buffer = Buffer.from(arrayBuffer);
|
||||||
|
|||||||
@ -75,7 +75,8 @@ export default async function Page({ params, searchParams }) {
|
|||||||
slug_list: slugArr,
|
slug_list: slugArr,
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: pageSize,
|
page_size: pageSize,
|
||||||
downloadFiles: true,
|
downloadFiles: false,
|
||||||
|
rewriteToProxy: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@ -16,7 +16,8 @@ export default async function DynamicListPage({ slugArr, basePath, columns, page
|
|||||||
slug_list: slugArr,
|
slug_list: slugArr,
|
||||||
page: currentPage,
|
page: currentPage,
|
||||||
page_size: pageSize,
|
page_size: pageSize,
|
||||||
downloadFiles: true
|
downloadFiles: false,
|
||||||
|
rewriteToProxy: true
|
||||||
});
|
});
|
||||||
items = result.data;
|
items = result.data;
|
||||||
total = result.total;
|
total = result.total;
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 698 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 908 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 919 KiB |
|
Before Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 926 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 39 KiB |