Skip to content

Commit

Permalink
feat: add asciinema preview (close alist-org/alist#5683)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Dec 13, 2023
1 parent 8520e30 commit 23aed38
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -63,6 +63,7 @@
"aplayer": "^1.10.1",
"artplayer": "^5.0.9",
"artplayer-plugin-danmuku": "^5.0.1",
"asciinema-player": "^3.6.3",
"axios": "^1.0.0",
"clsx": "^2.0.0",
"copy-to-clipboard": "^3.3.2",
Expand Down
21 changes: 21 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/pages/home/previews/asciinema.tsx
@@ -0,0 +1,13 @@
import { Box } from "@hope-ui/solid"
import * as AsciinemaPlayer from "asciinema-player"
import "asciinema-player/dist/bundle/asciinema-player.css"
import { onMount } from "solid-js"
import { objStore } from "~/store"
export default function Preview() {
let d: HTMLDivElement

onMount(() => {
AsciinemaPlayer.create(objStore.raw_url, d)
})
return <Box w="$full" ref={d!} />
}
5 changes: 5 additions & 0 deletions src/pages/home/previews/index.ts
Expand Up @@ -78,6 +78,11 @@ const previews: Preview[] = [
provider: /^Aliyundrive(Share)?$/,
component: lazy(() => import("./aliyun_office")),
},
{
name: "Asciinema",
exts: ["cast"],
component: lazy(() => import("./asciinema")),
},
]

export const getPreviews = (
Expand Down
2 changes: 2 additions & 0 deletions src/utils/icon.ts
Expand Up @@ -27,6 +27,7 @@ import {
VscodeIconsFileTypeAi2,
VscodeIconsFileTypePhotoshop2,
} from "~/components"
import { SiAsciinema } from "solid-icons/si"

const iconMap = {
"dmg,ipa,plist,tipa": BsApple,
Expand All @@ -45,6 +46,7 @@ const iconMap = {
psd: VscodeIconsFileTypePhotoshop2,
ai: VscodeIconsFileTypeAi2,
url: FaSolidLink,
cast: SiAsciinema,
}

export const getIconByTypeAndExt = (type: number, ext: string) => {
Expand Down

0 comments on commit 23aed38

Please sign in to comment.