From 5701dfb927da2fe66990f07d5a9c03b2040dde54 Mon Sep 17 00:00:00 2001 From: hughfenghen Date: Sun, 3 Dec 2023 20:36:38 +0800 Subject: [PATCH] fix: link incorrect --- doc-site/docs/demo/decode-audio.tsx | 13 +++++++------ doc-site/docs/demo/decode-image.tsx | 13 +++++++------ doc-site/docs/demo/decode-video.tsx | 9 +++++---- doc-site/docs/demo/utils.ts | 10 ++++++++-- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/doc-site/docs/demo/decode-audio.tsx b/doc-site/docs/demo/decode-audio.tsx index 8995ade2..fece43e5 100644 --- a/doc-site/docs/demo/decode-audio.tsx +++ b/doc-site/docs/demo/decode-audio.tsx @@ -1,12 +1,13 @@ import { AudioClip, DEFAULT_AUDIO_CONF } from '@webav/av-cliper'; import { Button, Radio } from 'antd'; import React, { useState } from 'react'; +import { assetsPrefix } from './utils'; -const audios = { - '44.1kHz-2chan.m4a': '/audio/44.1kHz-2chan.m4a', - '44.1kHz-2chan.mp3': '/audio/44.1kHz-2chan.mp3', - '16kHz-1chan.mp3': '/audio/16kHz-1chan.mp3', -}; +const audios = assetsPrefix({ + '44.1kHz-2chan.m4a': 'audio/44.1kHz-2chan.m4a', + '44.1kHz-2chan.mp3': 'audio/44.1kHz-2chan.mp3', + '16kHz-1chan.mp3': 'audio/16kHz-1chan.mp3', +}); let stopAudio = () => {}; async function start(audioType: keyof typeof audios) { @@ -72,7 +73,7 @@ function createUI(start: Function) { value={value} > 44.1kHz-2chan.m4a - 44.1kHz-2chan.m4a + 44.1kHz-2chan.mp3 16kHz-1chan.mp3 diff --git a/doc-site/docs/demo/decode-image.tsx b/doc-site/docs/demo/decode-image.tsx index 54fdaaf4..e41b3856 100644 --- a/doc-site/docs/demo/decode-image.tsx +++ b/doc-site/docs/demo/decode-image.tsx @@ -1,13 +1,14 @@ import { decodeImg } from '@webav/av-cliper'; import { Button, Radio } from 'antd'; import React, { useState } from 'react'; +import { assetsPrefix } from './utils'; -const imgs = { - avif: '/img/animated.avif', - webp: '/img/animated.webp', - png: '/img/animated.png', - gif: '/img/animated.gif', -}; +const imgs = assetsPrefix({ + avif: 'img/animated.avif', + webp: 'img/animated.webp', + png: 'img/animated.png', + gif: 'img/animated.gif', +}); let stopRender = () => {}; async function start( diff --git a/doc-site/docs/demo/decode-video.tsx b/doc-site/docs/demo/decode-video.tsx index be32db61..89f44062 100644 --- a/doc-site/docs/demo/decode-video.tsx +++ b/doc-site/docs/demo/decode-video.tsx @@ -1,11 +1,12 @@ import { MP4Clip } from '@webav/av-cliper'; import { Button, Divider, Radio } from 'antd'; import React, { useState } from 'react'; +import { assetsPrefix } from './utils'; -const videos = { - 'bunny.mp4': '/video/bunny-avc.mp4', - 'bear.mp4': '/video/bear-vp9.mp4', -}; +const videos = assetsPrefix({ + 'bunny.mp4': 'video/bunny-avc.mp4', + 'bear.mp4': 'video/bear-vp9.mp4', +}); async function start( speed: number, diff --git a/doc-site/docs/demo/utils.ts b/doc-site/docs/demo/utils.ts index 3fbc555b..724285c8 100644 --- a/doc-site/docs/demo/utils.ts +++ b/doc-site/docs/demo/utils.ts @@ -1,7 +1,13 @@ -export function assetsPrefix(assetsURL: string[]): string[] { +export function assetsPrefix)>(assetsURL: T): T { const prefix = process.env.NODE_ENV === 'development' ? '/' : '/WebAV/' - return assetsURL.map(url => `${prefix}${url}`) + if (Array.isArray(assetsURL)) { + return assetsURL.map(url => `${prefix}${url}`) as T + } + + return Object.fromEntries( + Object.entries(assetsURL).map(([k, v]) => [k, `${prefix}${v}`]) + ) as T }