mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-09-23 20:50:08 +08:00
move code to utils/file
This commit is contained in:
@@ -29,10 +29,9 @@ import {
|
||||
showConfirm,
|
||||
showImageModal,
|
||||
showModal,
|
||||
IndexDBImage,
|
||||
} from "@/app/components/ui-lib";
|
||||
import { func } from "prop-types";
|
||||
import { useFileDB } from "@/app/utils/file";
|
||||
import { useFileDB, IndexDBImage } from "@/app/utils/file";
|
||||
|
||||
function getSdTaskStatus(item: any) {
|
||||
let s: string;
|
||||
|
@@ -511,29 +511,3 @@ export function Selector<T>(props: {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function IndexDBImage({ src, alt, onClick, db, className }) {
|
||||
const [data, setData] = useState(src);
|
||||
const imgId = useMemo(
|
||||
() => src.replace("indexeddb://", "").split("@").pop(),
|
||||
[src],
|
||||
);
|
||||
useEffect(() => {
|
||||
db.getByID(imgId)
|
||||
.then(({ data }) => {
|
||||
setData(`data:image/png;base64,${data}`);
|
||||
})
|
||||
.catch((e) => {
|
||||
setData(src);
|
||||
});
|
||||
}, [src, imgId]);
|
||||
|
||||
return (
|
||||
<img
|
||||
className={className}
|
||||
src={data}
|
||||
alt={alt}
|
||||
onClick={(e) => onClick(data, e)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user