mirror of
https://github.com/langgenius/dify.git
synced 2025-12-19 22:28:46 +00:00
Fix immediate window open defaults and error handling (#29417)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -17,8 +17,18 @@ export const useAsyncWindowOpen = () => useCallback(async (getUrl: GetUrl, optio
|
||||
onError,
|
||||
} = options ?? {}
|
||||
|
||||
const secureImmediateFeatures = features ? `${features},noopener,noreferrer` : 'noopener,noreferrer'
|
||||
|
||||
if (immediateUrl) {
|
||||
window.open(immediateUrl, target, features)
|
||||
const newWindow = window.open(immediateUrl, target, secureImmediateFeatures)
|
||||
if (!newWindow) {
|
||||
onError?.(new Error('Failed to open new window'))
|
||||
return
|
||||
}
|
||||
try {
|
||||
newWindow.opener = null
|
||||
}
|
||||
catch { /* noop */ }
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user