fix: oauth error
This commit is contained in:
parent
e74391562b
commit
3d16c735d9
@ -163,9 +163,9 @@ export class WindowService {
|
|||||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||||
const { url } = details
|
const { url } = details
|
||||||
|
|
||||||
const oauthProviderUrls = ['https://account.siliconflow.cn']
|
const oauthProviderUrls = ['https://account.siliconflow.cn/oauth']
|
||||||
|
|
||||||
if (oauthProviderUrls.some((url) => url.startsWith(url))) {
|
if (oauthProviderUrls.some((link) => url.startsWith(link))) {
|
||||||
return {
|
return {
|
||||||
action: 'allow',
|
action: 'allow',
|
||||||
overrideBrowserWindowOptions: {
|
overrideBrowserWindowOptions: {
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { useProvider } from '@renderer/hooks/useProvider'
|
|
||||||
import { Provider } from '@renderer/types'
|
import { Provider } from '@renderer/types'
|
||||||
import { oauthWithAihubmix, oauthWithSiliconFlow } from '@renderer/utils/oauth'
|
import { oauthWithAihubmix, oauthWithSiliconFlow } from '@renderer/utils/oauth'
|
||||||
import { Button, ButtonProps } from 'antd'
|
import { Button, ButtonProps } from 'antd'
|
||||||
@ -7,16 +6,16 @@ import { useTranslation } from 'react-i18next'
|
|||||||
|
|
||||||
interface Props extends ButtonProps {
|
interface Props extends ButtonProps {
|
||||||
provider: Provider
|
provider: Provider
|
||||||
|
onSuccess?: (key: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const OAuthButton: FC<Props> = (props) => {
|
const OAuthButton: FC<Props> = ({ provider, ...props }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { provider, updateProvider } = useProvider(props.provider.id)
|
|
||||||
|
|
||||||
const onAuth = () => {
|
const onAuth = () => {
|
||||||
const onSuccess = (key: string) => {
|
const onSuccess = (key: string) => {
|
||||||
if (key.trim()) {
|
if (key.trim()) {
|
||||||
updateProvider({ ...provider, apiKey: key })
|
props.onSuccess?.(key)
|
||||||
window.message.success(t('auth.get_key_success'))
|
window.message.success(t('auth.get_key_success'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -240,7 +240,7 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
|||||||
type="password"
|
type="password"
|
||||||
autoFocus={provider.enabled && apiKey === ''}
|
autoFocus={provider.enabled && apiKey === ''}
|
||||||
/>
|
/>
|
||||||
{isProviderSupportAuth(provider) && <OAuthButton provider={provider} />}
|
{isProviderSupportAuth(provider) && <OAuthButton provider={provider} onSuccess={setApiKey} />}
|
||||||
<Button
|
<Button
|
||||||
type={apiValid ? 'primary' : 'default'}
|
type={apiValid ? 'primary' : 'default'}
|
||||||
ghost={apiValid}
|
ghost={apiValid}
|
||||||
@ -266,7 +266,9 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
|||||||
onBlur={onUpdateApiHost}
|
onBlur={onUpdateApiHost}
|
||||||
/>
|
/>
|
||||||
{!isEmpty(configedApiHost) && apiHost !== configedApiHost && (
|
{!isEmpty(configedApiHost) && apiHost !== configedApiHost && (
|
||||||
<Button onClick={onReset}>{t('settings.provider.api.url.reset')}</Button>
|
<Button danger onClick={onReset}>
|
||||||
|
{t('settings.provider.api.url.reset')}
|
||||||
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Space.Compact>
|
</Space.Compact>
|
||||||
{isOpenAIProvider(provider) && (
|
{isOpenAIProvider(provider) && (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user