Add browser toolbar to auth windows
This commit is contained in:
@@ -521,7 +521,7 @@ function workbenchErrorDataURL(title: string, targetURL: string, message: string
|
||||
<body>
|
||||
<main>
|
||||
<h1>${escapeHtml(title)}加载失败</h1>
|
||||
<p>远程工作台暂时无法打开。可以使用窗口左上方的刷新按钮重试。</p>
|
||||
<p>远程页面暂时无法打开。可以使用窗口左上方的刷新按钮重试。</p>
|
||||
<code>${escapeHtml(host || targetURL)}
|
||||
|
||||
${escapeHtml(message)}</code>
|
||||
@@ -563,6 +563,19 @@ function getRecordForSender(sender: WebContents): WorkbenchWindowRecord | null {
|
||||
return record
|
||||
}
|
||||
|
||||
function getRecordForWindow(window: BrowserWindow): WorkbenchWindowRecord | null {
|
||||
const record = workbenchWindows.get(window.webContents.id)
|
||||
if (
|
||||
!record ||
|
||||
record.window !== window ||
|
||||
record.window.isDestroyed() ||
|
||||
record.view.webContents.isDestroyed()
|
||||
) {
|
||||
return null
|
||||
}
|
||||
return record
|
||||
}
|
||||
|
||||
function defaultNavigationState(): WorkbenchNavigationState {
|
||||
return {
|
||||
canGoBack: false,
|
||||
@@ -740,6 +753,38 @@ async function navigateWorkbenchRemote(
|
||||
}
|
||||
}
|
||||
|
||||
export function getWorkbenchWindowWebContents(window: BrowserWindow): WebContents | null {
|
||||
return getRecordForWindow(window)?.view.webContents ?? null
|
||||
}
|
||||
|
||||
export function isWorkbenchWindowReadyForDetection(window: BrowserWindow): boolean {
|
||||
const record = getRecordForWindow(window)
|
||||
if (!record) {
|
||||
return false
|
||||
}
|
||||
|
||||
const currentURL = record.view.webContents.getURL()
|
||||
return (
|
||||
isRemoteHTTPURL(currentURL) &&
|
||||
!isLocalWorkbenchPage(currentURL) &&
|
||||
!record.loading &&
|
||||
!record.view.webContents.isLoading()
|
||||
)
|
||||
}
|
||||
|
||||
export async function loadWorkbenchWindowURL(
|
||||
window: BrowserWindow,
|
||||
targetURL: string,
|
||||
): Promise<boolean> {
|
||||
const record = getRecordForWindow(window)
|
||||
if (!record) {
|
||||
return false
|
||||
}
|
||||
|
||||
await navigateWorkbenchRemote(record, targetURL)
|
||||
return true
|
||||
}
|
||||
|
||||
export async function openWorkbenchWindow(options: WorkbenchWindowOptions): Promise<BrowserWindow> {
|
||||
registerWorkbenchNavigationHandlers()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user