Skip to content

Commit

Permalink
表示される情報を拡充
Browse files Browse the repository at this point in the history
  • Loading branch information
o-tr committed Aug 28, 2024
1 parent b5be612 commit f0600f5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/_types/api/getMyFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const fileSchema = z.object({
fileId: z.string(),
count: z.number(),
server: z.union([z.literal("HA"), z.literal("Normal")]),
format: z.string(),
version: z.number(),
createdAt: z.string(),
expireAt: z.string(),
});
Expand Down
22 changes: 17 additions & 5 deletions src/app/(_)/files/[fileId]/_components/URLDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"use client";
import { FC, useEffect, useState } from "react";
import { Button, Flex, Input, Result, Spin } from "antd";
import {Alert, Button, Flex, Input, Result, Spin} from "antd";
import Compact from "antd/es/space/Compact";
import { TbCheck, TbCopy } from "react-icons/tb";
import { getFile } from "@/lib/service/getFile";
import { S3_HA_PUBLIC_BASE_URL, S3_NORMAL_PUBLIC_BASE_URL } from "@/const/env";
import Link from "next/link";
import {FileItem} from "@/_types/api/getMyFiles";

export const URLDisplay: FC<{ fileId: string }> = ({ fileId }) => {
const [files, setFiles] = useState<string[] | undefined>(undefined);
const [urls, setUrls] = useState<string[] | undefined>(undefined);
const [file, setFile] = useState<FileItem>();
const [notFound, setNotFound] = useState(false);
useEffect(() => {
(async () => {
Expand All @@ -20,7 +22,8 @@ export const URLDisplay: FC<{ fileId: string }> = ({ fileId }) => {
for (let i = 0; i < file.count; i++) {
result.push(`${baseUrl}/${fileId}_${i}`);
}
setFiles(result);
setFile(file);
setUrls(result);
} catch (e) {
setNotFound(true);
}
Expand All @@ -44,15 +47,24 @@ export const URLDisplay: FC<{ fileId: string }> = ({ fileId }) => {

return (
<>
<h2 className={"text-xl"}>{file?.name}</h2>
<Flex vertical>
{files?.map((url, i) => <URLDisplayItem key={i} url={url} />)}
{!files && (
{urls?.map((url, i) => <URLDisplayItem key={i} url={url} />)}
{!urls && (
<Flex gap={"middle"} align={"center"}>
<Spin size={"large"} />
<span>Loading...</span>
</Flex>
)}
</Flex>
<Flex vertical align={"start"} gap={"middle"}>
{file?.format === "DXT1" && (
<Alert message={"ImageSlide v0.2.x未満及び、Questではこのスライドを読み込むことができません"} type="info" showIcon />
)}
{file?.version === 1 && file?.format !== "DXT1" && (
<Alert message={"ImageSlide v0.1.x未満ではこのスライドを読み込むことができません"} type="info" showIcon />
)}
</Flex>
<div>
<p>
このページのURLと上記のURLは、知っていれば誰でもアクセスすることができます
Expand Down
2 changes: 2 additions & 0 deletions src/app/(_)/my/files/_components/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export const FileList: FC = () => {
</Flex>
),
},
{ title: "Format", dataIndex: "format", key: "format", width: 100 },
{ title: "Version", dataIndex: "version", key: "version", width: 100 },
{
title: "Created At",
dataIndex: "createdAt",
Expand Down
2 changes: 2 additions & 0 deletions src/app/api/files/[fileId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const GET = async (
name: file.name,
count: file.count,
server: file.ha ? "HA" : "Normal",
format: file.format,
version: file.version,
createdAt: format(
new Date(file.createdAt),
"YYYY/MM/DD HH:mm:ss",
Expand Down
2 changes: 2 additions & 0 deletions src/app/api/my/files/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const GET = async () => {
name: file.name,
count: file.count,
server: file.ha ? "HA" : "Normal",
format: file.format,
version: file.version,
createdAt: format(new Date(file.createdAt), "YYYY/MM/DD HH:mm:ss", "en"),
expireAt: format(
addDay(new Date(file.createdAt), file.ha ? 7 : 30),
Expand Down

0 comments on commit f0600f5

Please sign in to comment.