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