From 155f71eb28d02050df058c11824430b248d8828b Mon Sep 17 00:00:00 2001 From: Project_IO Date: Tue, 18 Mar 2025 00:22:55 +0900 Subject: [PATCH] fix --- src/components/file-view/index.tsx | 3 ++- src/store/raw.ts | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/file-view/index.tsx b/src/components/file-view/index.tsx index ea23e72..b7e1a63 100644 --- a/src/components/file-view/index.tsx +++ b/src/components/file-view/index.tsx @@ -1,9 +1,10 @@ import { useEffect, useState } from "react"; import { useRaw } from "../../store/raw"; -import "./fview.scss"; import { useLocation } from "react-router"; import { DynamicIcon } from "lucide-react/dynamic"; +import "./fview.scss"; + function FileView() { const raw = useRaw(); const location = useLocation(); diff --git a/src/store/raw.ts b/src/store/raw.ts index c32cb9c..278dd6f 100644 --- a/src/store/raw.ts +++ b/src/store/raw.ts @@ -17,12 +17,12 @@ export const useRaw = create((set) => ({ } const contentType = res.headers.get("Content-Type"); - if (!contentType || !contentType.includes("text")) { - set({ data: "this file is not supported showing preview" }); + if (contentType && contentType.includes("text")) { + const text = await res.text(); + set({ data: text }); return; } - - const text = await res.text(); - set({ data: text }); + + set({ data: "this file is not supported showing preview" }); } }));