mirror of https://github.com/langgenius/dify.git
fixes #29390: align async window open behavior with inline logic
This commit is contained in:
parent
997ff45e56
commit
de9fae63b8
|
|
@ -17,28 +17,32 @@ export const useAsyncWindowOpen = () => {
|
|||
const {
|
||||
successMessage,
|
||||
errorMessage = 'Failed to open page',
|
||||
windowFeatures = 'noopener,noreferrer',
|
||||
windowFeatures = 'noopener',
|
||||
onError,
|
||||
onSuccess,
|
||||
} = options
|
||||
|
||||
const newWindow = window.open('', '_blank', windowFeatures)
|
||||
|
||||
if (!newWindow) {
|
||||
const error = new Error('Failed to open new window')
|
||||
onError?.(error)
|
||||
Toast.notify({
|
||||
type: 'error',
|
||||
message: errorMessage,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const url = await fetchUrl()
|
||||
|
||||
if (url) {
|
||||
if (newWindow) {
|
||||
try {
|
||||
newWindow.opener = null
|
||||
}
|
||||
catch { /* noop */ }
|
||||
newWindow.location.href = url
|
||||
}
|
||||
else {
|
||||
// Fallback: navigate current tab if we couldn't get a window reference
|
||||
window.location.href = url
|
||||
try {
|
||||
newWindow.opener = null
|
||||
}
|
||||
catch { /* noop */ }
|
||||
newWindow.location.href = url
|
||||
onSuccess?.(url)
|
||||
|
||||
if (successMessage) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue