支持缩略图加载,故事项新建调整
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { fetchImage } from '@/pages/story/service';
|
||||
import { useRequest } from '@umijs/max';
|
||||
import { useEffect, useState } from 'react';
|
||||
import {fetchImageLowRes} from "@/services/file/api";
|
||||
|
||||
const useFetchImageUrl = (imageInstanceId: string) => {
|
||||
const [imageUrl, setImageUrl] = useState("error");
|
||||
const { data: response, run, loading } = useRequest(
|
||||
() => {
|
||||
return fetchImage(imageInstanceId);
|
||||
return fetchImageLowRes(imageInstanceId);
|
||||
},
|
||||
{
|
||||
manual: true,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import useFetchImageUrl from '@/components/Hooks/useFetchImageUrl';
|
||||
import { Image } from 'antd';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { LoadingOutlined } from "@ant-design/icons";
|
||||
import React, { useState } from 'react';
|
||||
|
||||
interface ImageItem {
|
||||
instanceId: string;
|
||||
@@ -28,18 +27,18 @@ const TimelineImage: React.FC<Props> = (props) => {
|
||||
width = 200,
|
||||
height = 200,
|
||||
imageList = [],
|
||||
currentIndex = 0
|
||||
currentIndex = 0,
|
||||
} = props;
|
||||
|
||||
const { imageUrl, loading } = useFetchImageUrl(imageInstanceId ?? '');
|
||||
const [previewVisible, setPreviewVisible] = useState(false);
|
||||
|
||||
// 构建预览列表
|
||||
imageList.map(item => ({
|
||||
imageList.map((item) => ({
|
||||
src: item.instanceId,
|
||||
title: item.imageName
|
||||
title: item.imageName,
|
||||
}));
|
||||
// 预览配置
|
||||
// 预览配置
|
||||
const previewConfig = {
|
||||
visible: previewVisible,
|
||||
onVisibleChange: (visible: boolean) => setPreviewVisible(visible),
|
||||
@@ -50,8 +49,10 @@ const TimelineImage: React.FC<Props> = (props) => {
|
||||
<div className="tl-image-container" style={{ width, height }}>
|
||||
<Image
|
||||
loading="lazy"
|
||||
src={src ?? imageUrl}
|
||||
preview={loading ? false : previewConfig}
|
||||
src={src ?? `/file/image-low-res/${imageInstanceId}`}
|
||||
preview={{
|
||||
src: `/file/image/${imageInstanceId}`,
|
||||
}}
|
||||
height={height}
|
||||
width={width}
|
||||
alt={title}
|
||||
|
||||
Reference in New Issue
Block a user