From 7549b83730c91b1611c4d6b80676bce20ad15141 Mon Sep 17 00:00:00 2001 From: hole-thu Date: Sun, 17 Apr 2022 22:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=B5=8C=E5=85=A5=E9=9F=B3?= =?UTF-8?q?=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common.css | 3 ++- src/Common.js | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Common.css b/src/Common.css index d78d138c..d122ab5f 100644 --- a/src/Common.css +++ b/src/Common.css @@ -58,7 +58,8 @@ } .ext-img, -.ext-video { +.ext-video, +.ext-audio { max-width: 100%; max-height: 2000px; display: block; diff --git a/src/Common.js b/src/Common.js index 2f888707..b2b36e89 100644 --- a/src/Common.js +++ b/src/Common.js @@ -35,6 +35,18 @@ function is_video(s) { } } +function is_audio(s) { + try { + let url = new URL(s); + return ( + url.pathname.endsWith('.mp3') || + (url.searchParams.get('filetype') || '').startsWith('audio/') + ); + } catch (e) { + return false; + } +} + export function build_highlight_re( txt, split = ' ', @@ -185,7 +197,10 @@ export class HighlightedMarkdown extends Component { {is_video(p) && ( -