From aad05a8e6150ba2964a783483df1247ef75018f7 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Thu, 19 May 2022 21:54:16 +0800 Subject: [PATCH 1/6] feat: customize pdf viewer (Xhofe/alist#1109) --- src/pages/list/preview/pdf.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/list/preview/pdf.tsx b/src/pages/list/preview/pdf.tsx index 7dc24bc..8b0e606 100644 --- a/src/pages/list/preview/pdf.tsx +++ b/src/pages/list/preview/pdf.tsx @@ -1,17 +1,20 @@ import { Center } from "@chakra-ui/react"; -import React from "react"; +import React, { useContext } from "react"; +import { IContext } from "../context"; export const type = -1; export const exts = []; const Pdf = ({ url, unfold }: { url: string; unfold: boolean }) => { + const { getSetting } = useContext(IContext) + const pdfPreviewUrl = getSetting("pdf viewer url") || "https://alist-org.github.io/pdf.js/web/viewer.html?file=$url"; return (
) : show === "edit" ? ( - + ) : ( - {content} + + {file.name.endsWith(".md") + ? content + : "```" + + file.name.split(".").pop() + + "\n" + + content + + "\n" + + "```"} + )} From 8d62361fc9b341b4fef04a7b2ea74fdfda5a9495 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Sat, 28 May 2022 20:49:54 +0800 Subject: [PATCH 6/6] fix: refresh while pagination (close Xhofe/alist#1124) --- src/pages/list/layout/files/menus/refresh.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/list/layout/files/menus/refresh.tsx b/src/pages/list/layout/files/menus/refresh.tsx index 69e4712..9fd4fb4 100644 --- a/src/pages/list/layout/files/menus/refresh.tsx +++ b/src/pages/list/layout/files/menus/refresh.tsx @@ -10,7 +10,7 @@ import bus from "../../../../../utils/event-bus"; import { IContext } from "../../../context"; const Refresh = () => { - const { loggedIn } = useContext(IContext); + const { loggedIn, setPage, page } = useContext(IContext); const { t } = useTranslation(); const { refresh } = useApi(); const toast = useToast(); @@ -28,6 +28,7 @@ const Refresh = () => { isClosable: true, }); if (res.code === 200) { + setPage({ ...page, page_num: 1 }); bus.emit("refresh"); } }); @@ -42,4 +43,4 @@ const Refresh = () => { ); }; -export default Refresh; \ No newline at end of file +export default Refresh;