Display created time of files.

This commit is contained in:
2025-10-04 21:10:47 +08:00
parent ff30125518
commit af52e7b764
3 changed files with 8 additions and 1 deletions

View File

@@ -106,6 +106,7 @@ export interface RFile {
resource?: Resource; resource?: Resource;
hash?: string; hash?: string;
storage_name?: string; storage_name?: string;
created_at: number; // unix timestamp
} }
export interface UploadingFile { export interface UploadingFile {

View File

@@ -25,7 +25,7 @@ import Markdown from "react-markdown";
import "../markdown.css"; import "../markdown.css";
import Loading from "../components/loading.tsx"; import Loading from "../components/loading.tsx";
import { import {
MdAdd, MdAdd, MdOutlineAccessTime,
MdOutlineAdd, MdOutlineAdd,
MdOutlineArchive, MdOutlineArchive,
MdOutlineArticle, MdOutlineArticle,
@@ -776,6 +776,10 @@ function FileTile({ file }: { file: RFile }) {
{file.storage_name} {file.storage_name}
</Badge> </Badge>
)} )}
<Badge className={"badge-soft badge-info text-xs mr-2"}>
<MdOutlineAccessTime size={16} className={"inline-block"} />
{new Date(file.created_at).toISOString().substring(0, 10)}
</Badge>
<DeleteFileDialog fileId={file.id} uploaderId={file.user.id} /> <DeleteFileDialog fileId={file.id} uploaderId={file.user.id} />
<UpdateFileInfoDialog file={file} /> <UpdateFileInfoDialog file={file} />
</p> </p>

View File

@@ -31,6 +31,7 @@ type FileView struct {
Resource *ResourceView `json:"resource,omitempty"` Resource *ResourceView `json:"resource,omitempty"`
Hash string `json:"hash,omitempty"` Hash string `json:"hash,omitempty"`
StorageName string `json:"storage_name,omitempty"` StorageName string `json:"storage_name,omitempty"`
CreatedAt int64 `json:"created_at,omitempty"`
} }
func (f *File) ToView() *FileView { func (f *File) ToView() *FileView {
@@ -43,6 +44,7 @@ func (f *File) ToView() *FileView {
User: f.User.ToView(), User: f.User.ToView(),
Hash: f.Hash, Hash: f.Hash,
StorageName: f.Storage.Name, StorageName: f.Storage.Name,
CreatedAt: f.CreatedAt.Unix(),
} }
} }