From e48f39375ee4a2510c3b7b068974a6c9dfdcc757 Mon Sep 17 00:00:00 2001 From: josc146 Date: Sun, 10 Dec 2023 23:08:44 +0800 Subject: [PATCH] add midi tracks to webUI --- .../AudiotrackManager/AudiotrackEditor.tsx | 15 +++++- frontend/src/pages/Chat.tsx | 2 +- frontend/src/pages/Composition.tsx | 50 ++++++++++--------- frontend/src/utils/web-file-operations.ts | 9 +++- 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx b/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx index 57029f1..5247489 100644 --- a/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx +++ b/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx @@ -18,7 +18,7 @@ import { } from '@fluentui/react-icons'; import { Button, Card, DialogTrigger, Slider, Text, Tooltip } from '@fluentui/react-components'; import { useWindowSize } from 'usehooks-ts'; -import commonStore from '../../stores/commonStore'; +import commonStore, { ModelStatus } from '../../stores/commonStore'; import classnames from 'classnames'; import { InstrumentType, @@ -420,6 +420,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
: } size="small" shape="circular" appearance="subtle" onClick={() => { @@ -481,6 +482,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
+ } />
} onClick={() => { diff --git a/frontend/src/utils/web-file-operations.ts b/frontend/src/utils/web-file-operations.ts index 872305b..1d6f224 100644 --- a/frontend/src/utils/web-file-operations.ts +++ b/frontend/src/utils/web-file-operations.ts @@ -1,12 +1,17 @@ import { getDocument, GlobalWorkerOptions, PDFDocumentProxy } from 'pdfjs-dist'; import { TextItem } from 'pdfjs-dist/types/src/display/api'; -export function webOpenOpenFileDialog({ filterPattern, fnStartLoading }: { filterPattern: string, fnStartLoading: Function | null }): Promise<{ blob: Blob, content?: string }> { +export function webOpenOpenFileDialog(filterPattern: string, fnStartLoading: Function | undefined): Promise<{ + blob: Blob, + content?: string +}> { return new Promise((resolve, reject) => { const input = document.createElement('input'); input.type = 'file'; input.accept = filterPattern .replaceAll('*.txt', 'text/plain') + .replace('*.midi', 'audio/midi') + .replace('*.mid', 'audio/midi') .replaceAll('*.', 'application/') .replaceAll(';', ','); @@ -15,7 +20,7 @@ export function webOpenOpenFileDialog({ filterPattern, fnStartLoading }: { filte const file: Blob = e.target?.files[0]; if (fnStartLoading && typeof fnStartLoading === 'function') fnStartLoading(); - if (!GlobalWorkerOptions.workerSrc) + if (!GlobalWorkerOptions.workerSrc && file.type === 'application/pdf') // @ts-ignore GlobalWorkerOptions.workerSrc = await import('pdfjs-dist/build/pdf.worker.min.mjs'); if (file.type === 'text/plain') {