mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
feat: remove client-side cache-busting query parameters
Remove getRandParam() and urlWithTimestamp that added cache-busting query params (&rand=... and &t=...) to output URLs. This is now handled by the backend generating unique filenames with timestamps (ComfyUI PR pending). Updated files: - app.ts: removed getRandParam() method - queueStore.ts: removed urlWithTimestamp getter - imagePreviewStore.ts: removed unused imports - useCompletionSummary.ts: use .url instead of .urlWithTimestamp - imageCompare.ts, useMaskEditorLoader.ts, audioUtils.ts, Load3dUtils.ts: removed getRandParam() usage Amp-Thread-ID: https://ampcode.com/threads/T-019c17e5-1c0a-736f-970d-e411aae222fc
This commit is contained in:
@@ -59,10 +59,7 @@ function mkFileUrl(props: { ref: ImageRef; preview?: boolean }): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pathPlusQueryParams = api.apiURL(
|
const pathPlusQueryParams = api.apiURL(
|
||||||
'/view?' +
|
'/view?' + params.toString() + app.getPreviewFormatParam()
|
||||||
params.toString() +
|
|
||||||
app.getPreviewFormatParam() +
|
|
||||||
app.getRandParam()
|
|
||||||
)
|
)
|
||||||
const imageElement = new Image()
|
const imageElement = new Image()
|
||||||
imageElement.crossOrigin = 'anonymous'
|
imageElement.crossOrigin = 'anonymous'
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ type MockTask = {
|
|||||||
executionEndTimestamp?: number
|
executionEndTimestamp?: number
|
||||||
previewOutput?: {
|
previewOutput?: {
|
||||||
isImage: boolean
|
isImage: boolean
|
||||||
urlWithTimestamp: string
|
url: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ describe('useCompletionSummary', () => {
|
|||||||
if (previewUrl) {
|
if (previewUrl) {
|
||||||
task.previewOutput = {
|
task.previewOutput = {
|
||||||
isImage,
|
isImage,
|
||||||
urlWithTimestamp: previewUrl
|
url: previewUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export const useCompletionSummary = () => {
|
|||||||
completedCount++
|
completedCount++
|
||||||
const preview = task.previewOutput
|
const preview = task.previewOutput
|
||||||
if (preview?.isImage) {
|
if (preview?.isImage) {
|
||||||
imagePreviews.push(preview.urlWithTimestamp)
|
imagePreviews.push(preview.url)
|
||||||
}
|
}
|
||||||
} else if (state === 'failed') {
|
} else if (state === 'failed') {
|
||||||
failedCount++
|
failedCount++
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import type { NodeOutputWith } from '@/schemas/apiSchema'
|
import type { NodeOutputWith } from '@/schemas/apiSchema'
|
||||||
import { api } from '@/scripts/api'
|
import { api } from '@/scripts/api'
|
||||||
import { app } from '@/scripts/app'
|
|
||||||
import { useExtensionService } from '@/services/extensionService'
|
import { useExtensionService } from '@/services/extensionService'
|
||||||
|
|
||||||
type ImageCompareOutput = NodeOutputWith<{
|
type ImageCompareOutput = NodeOutputWith<{
|
||||||
@@ -23,15 +22,14 @@ useExtensionService().registerExtension({
|
|||||||
onExecuted?.call(this, output)
|
onExecuted?.call(this, output)
|
||||||
|
|
||||||
const { a_images: aImages, b_images: bImages } = output
|
const { a_images: aImages, b_images: bImages } = output
|
||||||
const rand = app.getRandParam()
|
|
||||||
|
|
||||||
const beforeUrl =
|
const beforeUrl =
|
||||||
aImages && aImages.length > 0
|
aImages && aImages.length > 0
|
||||||
? api.apiURL(`/view?${new URLSearchParams(aImages[0])}${rand}`)
|
? api.apiURL(`/view?${new URLSearchParams(aImages[0])}`)
|
||||||
: ''
|
: ''
|
||||||
const afterUrl =
|
const afterUrl =
|
||||||
bImages && bImages.length > 0
|
bImages && bImages.length > 0
|
||||||
? api.apiURL(`/view?${new URLSearchParams(bImages[0])}${rand}`)
|
? api.apiURL(`/view?${new URLSearchParams(bImages[0])}`)
|
||||||
: ''
|
: ''
|
||||||
|
|
||||||
const widget = node.widgets?.find((w) => w.type === 'imagecompare')
|
const widget = node.widgets?.find((w) => w.type === 'imagecompare')
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type Load3d from '@/extensions/core/load3d/Load3d'
|
|||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
import { useToastStore } from '@/platform/updates/common/toastStore'
|
import { useToastStore } from '@/platform/updates/common/toastStore'
|
||||||
import { api } from '@/scripts/api'
|
import { api } from '@/scripts/api'
|
||||||
import { app } from '@/scripts/app'
|
|
||||||
|
|
||||||
class Load3dUtils {
|
class Load3dUtils {
|
||||||
static async generateThumbnailIfNeeded(
|
static async generateThumbnailIfNeeded(
|
||||||
@@ -133,8 +132,7 @@ class Load3dUtils {
|
|||||||
const params = [
|
const params = [
|
||||||
'filename=' + encodeURIComponent(filename),
|
'filename=' + encodeURIComponent(filename),
|
||||||
'type=' + type,
|
'type=' + type,
|
||||||
'subfolder=' + subfolder,
|
'subfolder=' + subfolder
|
||||||
app.getRandParam().substring(1)
|
|
||||||
].join('&')
|
].join('&')
|
||||||
|
|
||||||
return `/view?${params}`
|
return `/view?${params}`
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { ResultItemType } from '@/schemas/apiSchema'
|
import type { ResultItemType } from '@/schemas/apiSchema'
|
||||||
import { app } from '@/scripts/app'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format time in MM:SS format
|
* Format time in MM:SS format
|
||||||
@@ -20,8 +19,7 @@ export function getResourceURL(
|
|||||||
const params = [
|
const params = [
|
||||||
'filename=' + encodeURIComponent(filename),
|
'filename=' + encodeURIComponent(filename),
|
||||||
'type=' + type,
|
'type=' + type,
|
||||||
'subfolder=' + subfolder,
|
'subfolder=' + subfolder
|
||||||
app.getRandParam().substring(1)
|
|
||||||
].join('&')
|
].join('&')
|
||||||
|
|
||||||
return `/view?${params}`
|
return `/view?${params}`
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import {
|
|||||||
} from '@/lib/litegraph/src/litegraph'
|
} from '@/lib/litegraph/src/litegraph'
|
||||||
import type { Vector2 } from '@/lib/litegraph/src/litegraph'
|
import type { Vector2 } from '@/lib/litegraph/src/litegraph'
|
||||||
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
|
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
|
||||||
import { isCloud } from '@/platform/distribution/types'
|
|
||||||
import { useSettingStore } from '@/platform/settings/settingStore'
|
import { useSettingStore } from '@/platform/settings/settingStore'
|
||||||
import { useTelemetry } from '@/platform/telemetry'
|
import { useTelemetry } from '@/platform/telemetry'
|
||||||
import type { WorkflowOpenSource } from '@/platform/telemetry/types'
|
import type { WorkflowOpenSource } from '@/platform/telemetry/types'
|
||||||
@@ -333,11 +332,6 @@ export class ComfyApp {
|
|||||||
else return ''
|
else return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
getRandParam() {
|
|
||||||
if (isCloud) return ''
|
|
||||||
return '&rand=' + Math.random()
|
|
||||||
}
|
|
||||||
|
|
||||||
static onClipspaceEditorSave() {
|
static onClipspaceEditorSave() {
|
||||||
if (ComfyApp.clipspace_return_node) {
|
if (ComfyApp.clipspace_return_node) {
|
||||||
ComfyApp.pasteFromClipspace(ComfyApp.clipspace_return_node)
|
ComfyApp.pasteFromClipspace(ComfyApp.clipspace_return_node)
|
||||||
|
|||||||
@@ -112,12 +112,11 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
|
|||||||
const outputs = getNodeOutputs(node)
|
const outputs = getNodeOutputs(node)
|
||||||
if (!outputs?.images?.length) return
|
if (!outputs?.images?.length) return
|
||||||
|
|
||||||
const rand = app.getRandParam()
|
|
||||||
const previewParam = getPreviewParam(node, outputs)
|
const previewParam = getPreviewParam(node, outputs)
|
||||||
|
|
||||||
return outputs.images.map((image) => {
|
return outputs.images.map((image) => {
|
||||||
const imgUrlPart = new URLSearchParams(image)
|
const imgUrlPart = new URLSearchParams(image)
|
||||||
return api.apiURL(`/view?${imgUrlPart}${previewParam}${rand}`)
|
return api.apiURL(`/view?${imgUrlPart}${previewParam}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,10 +84,6 @@ export class ResultItemImpl {
|
|||||||
return api.apiURL('/view?' + this.urlParams)
|
return api.apiURL('/view?' + this.urlParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
get urlWithTimestamp(): string {
|
|
||||||
return `${this.url}&t=${+new Date()}`
|
|
||||||
}
|
|
||||||
|
|
||||||
get isVhsFormat(): boolean {
|
get isVhsFormat(): boolean {
|
||||||
return !!this.format && !!this.frame_rate
|
return !!this.format && !!this.frame_rate
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user