From 2eb9a45a7760f30a19f8b63fbbce668f5dc2b728 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 9 Feb 2023 19:30:52 -0500 Subject: [PATCH] [+] Typing --- src/App.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 8bb1724..0e6d9e7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,17 +9,24 @@ import 'tippy.js/themes/light.css'; import 'tippy.js/animations/shift-away.css'; import './app.sass'; +interface File { + name: string + type: 'file' | 'directory' + size: number + mtime: string +} + const host = "https://daisy-ddns.hydev.org/data/api" const path = window.location.pathname -const fetchApi = async () => await (await fetch(urlJoin(host, path))).json() +const fetchApi = async () => await (await fetch(urlJoin(host, path))).json() as File[] function sizeFmt(size: number) { var i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024)); return (size / Math.pow(1024, i)).toFixed(1) + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]; } -function getIcon(f) +function getIcon(f: File) { if (f.type == "directory") return "/mime/folder.svg"