mirror of
https://github.com/likelovewant/ollama-for-amd.git
synced 2025-12-21 22:33:56 +00:00
app: open app instead of always navigating to / on connect (#13164)
This commit is contained in:
@@ -397,8 +397,8 @@ func checkUserLoggedIn(uiServerPort int) bool {
|
|||||||
// handleConnectURLScheme fetches the connect URL and opens it in the browser
|
// handleConnectURLScheme fetches the connect URL and opens it in the browser
|
||||||
func handleConnectURLScheme() {
|
func handleConnectURLScheme() {
|
||||||
if checkUserLoggedIn(uiServerPort) {
|
if checkUserLoggedIn(uiServerPort) {
|
||||||
slog.Info("user is already logged in, opening settings instead")
|
slog.Info("user is already logged in, opening app instead")
|
||||||
sendUIRequestMessage("/")
|
showWindow(wv.webview.Window())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,6 +466,8 @@ func handleURLSchemeInCurrentInstance(urlSchemeRequest string) {
|
|||||||
if isConnect {
|
if isConnect {
|
||||||
handleConnectURLScheme()
|
handleConnectURLScheme()
|
||||||
} else {
|
} else {
|
||||||
sendUIRequestMessage("/")
|
if wv.webview != nil {
|
||||||
|
showWindow(wv.webview.Window())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,27 +24,14 @@ bool firstTimeRun,startHidden; // Set in run before initialization
|
|||||||
for (NSURL *url in urls) {
|
for (NSURL *url in urls) {
|
||||||
if ([url.scheme isEqualToString:@"ollama"]) {
|
if ([url.scheme isEqualToString:@"ollama"]) {
|
||||||
NSString *path = url.path;
|
NSString *path = url.path;
|
||||||
if (!path || [path isEqualToString:@""]) {
|
|
||||||
// For URLs like ollama://settings (without triple slash),
|
if (path && ([path isEqualToString:@"/connect"] || [url.host isEqualToString:@"connect"])) {
|
||||||
// the "settings" part is parsed as the host, not the path.
|
|
||||||
// We need to convert it to a path by prepending "/"
|
|
||||||
if (url.host && ![url.host isEqualToString:@""]) {
|
|
||||||
path = [@"/" stringByAppendingString:url.host];
|
|
||||||
} else {
|
|
||||||
path = @"/";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([path isEqualToString:@"/connect"] || [url.host isEqualToString:@"connect"]) {
|
|
||||||
// Special case: handle connect by opening browser instead of app
|
// Special case: handle connect by opening browser instead of app
|
||||||
handleConnectURL();
|
handleConnectURL();
|
||||||
} else {
|
} else {
|
||||||
// Set app to be active and visible
|
// Set app to be active and visible
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
|
|
||||||
// Open the path with the UI
|
|
||||||
[self uiRequest:path];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -147,7 +147,9 @@ func handleURLSchemeRequest(urlScheme string) {
|
|||||||
if isConnect {
|
if isConnect {
|
||||||
handleConnectURLScheme()
|
handleConnectURLScheme()
|
||||||
} else {
|
} else {
|
||||||
sendUIRequestMessage("/")
|
if wv.webview != nil {
|
||||||
|
showWindow(wv.webview.Window())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user