diff --git a/src/App.tsx b/src/App.tsx index 3729d22..7787157 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,3 +1,4 @@ +import mime from 'mime'; import moment from 'moment'; import { Component, createResource, createSignal, For, lazy, Show } from 'solid-js'; @@ -9,6 +10,16 @@ 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) +{ + if (f.type == "directory") return "/mime/folder.svg" + + const sp = f.name.split(".") + const m = mime.getType(sp[sp.length - 1]) + if (m) return `/mime/${m.replace("/", "-")}.svg` + else return '/mime/application-blank.svg' +} export default function App() { const [api] = createResource(fetchApi) @@ -20,6 +31,7 @@ export default function App() {