Fix dev startup and channel connect popup

This commit is contained in:
taohe
2026-06-10 21:33:15 +08:00
parent ec5ed185cd
commit 78fbc0abdb
6 changed files with 241 additions and 25 deletions
@@ -24,6 +24,11 @@ import {
useConnectChannelProvider,
useDisconnectChannelConnection,
} from "@/core/channels/hooks";
import {
closeConnectWindow,
openConnectUrl,
prepareConnectWindow,
} from "@/core/channels/open-connect-url";
import type { ChannelConnection, ChannelProvider } from "@/core/channels/types";
import { useI18n } from "@/core/i18n/hooks";
import { cn } from "@/lib/utils";
@@ -32,13 +37,6 @@ import { ChannelProviderIcon } from "../channels/channel-provider-icon";
import { SettingsSection } from "./settings-section";
function openConnectUrl(url: string) {
const opened = window.open(url, "_blank", "noopener,noreferrer");
if (!opened) {
window.location.assign(url);
}
}
function getProviderDescription(
provider: ChannelProvider,
descriptions: Record<string, string>,
@@ -144,8 +142,11 @@ function ChannelProviderItem({
disabled={!canConnect || isConnecting}
title={!provider.configured ? t.channels.unconfigured : undefined}
onClick={() => {
const connectWindow = prepareConnectWindow();
connectMutation.mutate(provider.provider, {
onSuccess: (result) => openConnectUrl(result.url),
onSuccess: (result) =>
openConnectUrl(result.url, connectWindow),
onError: () => closeConnectWindow(connectWindow),
});
}}
>