mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
fix url navigation (#353)
This commit is contained in:
parent
5e80aeb22a
commit
f62d96ae99
@ -177,7 +177,7 @@ export class WebViewModel implements ViewModel {
|
|||||||
const waveEvent = adaptFromReactOrNativeKeyEvent(event);
|
const waveEvent = adaptFromReactOrNativeKeyEvent(event);
|
||||||
if (checkKeyPressed(waveEvent, "Enter")) {
|
if (checkKeyPressed(waveEvent, "Enter")) {
|
||||||
const url = globalStore.get(this.url);
|
const url = globalStore.get(this.url);
|
||||||
this.loadUrl(url);
|
this.loadUrl(url, "enter");
|
||||||
this.urlInputRef.current?.blur();
|
this.urlInputRef.current?.blur();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -254,14 +254,17 @@ export class WebViewModel implements ViewModel {
|
|||||||
* Load a new URL in the webview.
|
* Load a new URL in the webview.
|
||||||
* @param newUrl The new URL to load in the webview.
|
* @param newUrl The new URL to load in the webview.
|
||||||
*/
|
*/
|
||||||
loadUrl(newUrl: string) {
|
loadUrl(newUrl: string, reason: string) {
|
||||||
console.log("loadUrl", newUrl);
|
|
||||||
const nextUrl = this.ensureUrlScheme(newUrl);
|
const nextUrl = this.ensureUrlScheme(newUrl);
|
||||||
const normalizedNextUrl = this.normalizeUrl(nextUrl);
|
console.log("webview loadUrl", reason, nextUrl, "cur=", this.webviewRef?.current.getURL());
|
||||||
const normalizedCurUrl = this.normalizeUrl(globalStore.get(this.url));
|
if (newUrl != nextUrl) {
|
||||||
|
globalStore.set(this.url, nextUrl);
|
||||||
if (normalizedCurUrl !== normalizedNextUrl) {
|
}
|
||||||
this.webviewRef?.current.loadURL(normalizedNextUrl);
|
if (!this.webviewRef.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.webviewRef.current.getURL() != nextUrl) {
|
||||||
|
this.webviewRef.current.loadURL(nextUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +348,7 @@ const WebView = memo(({ model }: WebViewProps) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (metaUrlRef.current != metaUrl) {
|
if (metaUrlRef.current != metaUrl) {
|
||||||
metaUrlRef.current = metaUrl;
|
metaUrlRef.current = metaUrl;
|
||||||
model.loadUrl(metaUrl);
|
model.loadUrl(metaUrl, "meta");
|
||||||
}
|
}
|
||||||
}, [metaUrl]);
|
}, [metaUrl]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user