mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
remove file ext refactor
This commit is contained in:
@@ -38,10 +38,9 @@ export const useJobErrorReporting = ({
|
|||||||
|
|
||||||
const reportJobError = () => {
|
const reportJobError = () => {
|
||||||
const task = taskForJob.value
|
const task = taskForJob.value
|
||||||
if (!task) return
|
|
||||||
|
|
||||||
// Use execution_error from list response if available (includes prompt_id, timestamp)
|
// Use execution_error from list response if available (includes prompt_id, timestamp)
|
||||||
const executionError = task.executionError
|
const executionError = task?.executionError
|
||||||
if (executionError) {
|
if (executionError) {
|
||||||
dialog.showExecutionErrorDialog(executionError as ExecutionErrorWsMessage)
|
dialog.showExecutionErrorDialog(executionError as ExecutionErrorWsMessage)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -96,27 +96,91 @@ export class ResultItemImpl {
|
|||||||
return !!this.format && !!this.frame_rate
|
return !!this.format && !!this.frame_rate
|
||||||
}
|
}
|
||||||
|
|
||||||
get isVideoBySuffix(): boolean {
|
get htmlVideoType(): string | undefined {
|
||||||
return getMediaTypeFromFilename(this.filename) === 'video'
|
if (this.isWebm) {
|
||||||
|
return 'video/webm'
|
||||||
|
}
|
||||||
|
if (this.isMp4) {
|
||||||
|
return 'video/mp4'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isVhsFormat) {
|
||||||
|
if (this.format?.endsWith('webm')) {
|
||||||
|
return 'video/webm'
|
||||||
|
}
|
||||||
|
if (this.format?.endsWith('mp4')) {
|
||||||
|
return 'video/mp4'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
get isAudioBySuffix(): boolean {
|
get htmlAudioType(): string | undefined {
|
||||||
return getMediaTypeFromFilename(this.filename) === 'audio'
|
if (this.isMp3) {
|
||||||
|
return 'audio/mpeg'
|
||||||
|
}
|
||||||
|
if (this.isWav) {
|
||||||
|
return 'audio/wav'
|
||||||
|
}
|
||||||
|
if (this.isOgg) {
|
||||||
|
return 'audio/ogg'
|
||||||
|
}
|
||||||
|
if (this.isFlac) {
|
||||||
|
return 'audio/flac'
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
get isGif(): boolean {
|
||||||
|
return this.filename.endsWith('.gif')
|
||||||
|
}
|
||||||
|
|
||||||
|
get isWebp(): boolean {
|
||||||
|
return this.filename.endsWith('.webp')
|
||||||
|
}
|
||||||
|
|
||||||
|
get isWebm(): boolean {
|
||||||
|
return this.filename.endsWith('.webm')
|
||||||
|
}
|
||||||
|
|
||||||
|
get isMp4(): boolean {
|
||||||
|
return this.filename.endsWith('.mp4')
|
||||||
|
}
|
||||||
|
|
||||||
|
get isVideoBySuffix(): boolean {
|
||||||
|
return this.isWebm || this.isMp4
|
||||||
}
|
}
|
||||||
|
|
||||||
get isImageBySuffix(): boolean {
|
get isImageBySuffix(): boolean {
|
||||||
return getMediaTypeFromFilename(this.filename) === 'image'
|
return this.isGif || this.isWebp
|
||||||
|
}
|
||||||
|
|
||||||
|
get isMp3(): boolean {
|
||||||
|
return this.filename.endsWith('.mp3')
|
||||||
|
}
|
||||||
|
|
||||||
|
get isWav(): boolean {
|
||||||
|
return this.filename.endsWith('.wav')
|
||||||
|
}
|
||||||
|
|
||||||
|
get isOgg(): boolean {
|
||||||
|
return this.filename.endsWith('.ogg')
|
||||||
|
}
|
||||||
|
|
||||||
|
get isFlac(): boolean {
|
||||||
|
return this.filename.endsWith('.flac')
|
||||||
|
}
|
||||||
|
|
||||||
|
get isAudioBySuffix(): boolean {
|
||||||
|
return this.isMp3 || this.isWav || this.isOgg || this.isFlac
|
||||||
}
|
}
|
||||||
|
|
||||||
get isVideo(): boolean {
|
get isVideo(): boolean {
|
||||||
|
const isVideoByType =
|
||||||
|
this.mediaType === 'video' || !!this.format?.startsWith('video/')
|
||||||
return (
|
return (
|
||||||
this.isVideoBySuffix ||
|
this.isVideoBySuffix ||
|
||||||
this.isVhsFormat ||
|
(isVideoByType && !this.isImageBySuffix && !this.isAudioBySuffix)
|
||||||
// Note: VHS gifs are always previewed in the video player even if they
|
|
||||||
// are not VHS format. We could consider previewing them as images instead.
|
|
||||||
(this.mediaType === 'gifs' &&
|
|
||||||
!this.isImageBySuffix &&
|
|
||||||
!this.isAudioBySuffix)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,43 +209,6 @@ export class ResultItemImpl {
|
|||||||
get supportsPreview(): boolean {
|
get supportsPreview(): boolean {
|
||||||
return this.isImage || this.isVideo || this.isAudio || this.is3D
|
return this.isImage || this.isVideo || this.isAudio || this.is3D
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* HTML video MIME type for video elements
|
|
||||||
*/
|
|
||||||
get htmlVideoType(): string {
|
|
||||||
if (this.isVhsFormat) {
|
|
||||||
return 'video/webm'
|
|
||||||
}
|
|
||||||
const extension = this.filename.split('.').pop()?.toLowerCase()
|
|
||||||
const mimeTypes: Record<string, string> = {
|
|
||||||
mp4: 'video/mp4',
|
|
||||||
webm: 'video/webm',
|
|
||||||
ogg: 'video/ogg',
|
|
||||||
mov: 'video/quicktime',
|
|
||||||
avi: 'video/x-msvideo',
|
|
||||||
mkv: 'video/x-matroska',
|
|
||||||
gif: 'image/gif'
|
|
||||||
}
|
|
||||||
return mimeTypes[extension ?? ''] ?? 'video/mp4'
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HTML audio MIME type for audio elements
|
|
||||||
*/
|
|
||||||
get htmlAudioType(): string {
|
|
||||||
const extension = this.filename.split('.').pop()?.toLowerCase()
|
|
||||||
const mimeTypes: Record<string, string> = {
|
|
||||||
mp3: 'audio/mpeg',
|
|
||||||
wav: 'audio/wav',
|
|
||||||
ogg: 'audio/ogg',
|
|
||||||
flac: 'audio/flac',
|
|
||||||
aac: 'audio/aac',
|
|
||||||
m4a: 'audio/mp4',
|
|
||||||
webm: 'audio/webm'
|
|
||||||
}
|
|
||||||
return mimeTypes[extension ?? ''] ?? 'audio/mpeg'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TaskItemImpl {
|
export class TaskItemImpl {
|
||||||
|
|||||||
Reference in New Issue
Block a user