🐛 fix(oauth): Refactor OAuth configuration types and update related API methods
This commit is contained in:
parent
18ee600836
commit
6227ba91d0
@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { getOAuthConfig, oAuthCreateConfig, updateOAuthConfig } from '@/services/admin/system';
|
import { getOAuthByPlatform, updateOAuthConfig } from '@/services/admin/system';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { Label } from '@workspace/ui/components/label';
|
import { Label } from '@workspace/ui/components/label';
|
||||||
import { Switch } from '@workspace/ui/components/switch';
|
import { Switch } from '@workspace/ui/components/switch';
|
||||||
@ -14,28 +14,22 @@ export default function Page() {
|
|||||||
const t = useTranslations('apple');
|
const t = useTranslations('apple');
|
||||||
|
|
||||||
const { data, refetch } = useQuery({
|
const { data, refetch } = useQuery({
|
||||||
queryKey: ['getOAuthConfig', 'apple'],
|
queryKey: ['getOAuthByPlatform', 'apple'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await getOAuthConfig();
|
const { data } = await getOAuthByPlatform({
|
||||||
return data.data?.list.find((item) => item.platform === 'apple') as API.OAuthConfig;
|
platform: 'apple',
|
||||||
|
});
|
||||||
|
return data.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async function updateConfig(key: keyof API.OAuthConfig, value: unknown) {
|
async function updateConfig(key: keyof API.UpdateOAuthConfig, value: unknown) {
|
||||||
if (data?.[key] === value) return;
|
if (data?.[key] === value) return;
|
||||||
try {
|
try {
|
||||||
if (data?.id) {
|
await updateOAuthConfig({
|
||||||
await oAuthCreateConfig({
|
...data,
|
||||||
...data,
|
[key]: value,
|
||||||
platform: 'apple',
|
} as API.UpdateOAuthConfig);
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
} else {
|
|
||||||
await updateOAuthConfig({
|
|
||||||
...data,
|
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
}
|
|
||||||
toast.success(t('saveSuccess'));
|
toast.success(t('saveSuccess'));
|
||||||
refetch();
|
refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -66,21 +60,13 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='ABCDE1FGHI'
|
placeholder='ABCDE1FGHI'
|
||||||
value={data?.team_id}
|
value={data?.config?.team_id}
|
||||||
onValueBlur={(value) => updateConfig('team_id', value)}
|
onValueBlur={(value) => {
|
||||||
/>
|
updateConfig('config', {
|
||||||
</TableCell>
|
...data?.config,
|
||||||
</TableRow>
|
team_id: value,
|
||||||
<TableRow>
|
});
|
||||||
<TableCell>
|
}}
|
||||||
<Label>{t('clientId')}</Label>
|
|
||||||
<p className='text-muted-foreground text-xs'>{t('clientIdDescription')}</p>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell className='text-right'>
|
|
||||||
<EnhancedInput
|
|
||||||
placeholder='com.your.app.service'
|
|
||||||
value={data?.client_id}
|
|
||||||
onValueBlur={(value) => updateConfig('client_id', value)}
|
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@ -92,8 +78,31 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='ABC1234567'
|
placeholder='ABC1234567'
|
||||||
value={data?.key_id}
|
value={data?.config?.key_id}
|
||||||
onValueBlur={(value) => updateConfig('key_id', value)}
|
onValueBlur={(value) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
key_id: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell>
|
||||||
|
<Label>{t('clientId')}</Label>
|
||||||
|
<p className='text-muted-foreground text-xs'>{t('clientIdDescription')}</p>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className='text-right'>
|
||||||
|
<EnhancedInput
|
||||||
|
placeholder='com.your.app.service'
|
||||||
|
value={data?.config?.client_id}
|
||||||
|
onValueBlur={(value) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
client_id: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@ -106,8 +115,13 @@ export default function Page() {
|
|||||||
<Textarea
|
<Textarea
|
||||||
className='h-20'
|
className='h-20'
|
||||||
placeholder={`-----BEGIN PRIVATE KEY-----\nMIGTAgEA...\n-----END PRIVATE KEY-----`}
|
placeholder={`-----BEGIN PRIVATE KEY-----\nMIGTAgEA...\n-----END PRIVATE KEY-----`}
|
||||||
value={data?.client_secret}
|
value={data?.config?.client_secret}
|
||||||
onBlur={(e) => updateConfig('client_secret', e.target.value)}
|
onBlur={(e) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
client_secret: e.target.value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { getOAuthConfig, oAuthCreateConfig, updateOAuthConfig } from '@/services/admin/system';
|
import { getOAuthByPlatform, updateOAuthConfig } from '@/services/admin/system';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { Label } from '@workspace/ui/components/label';
|
import { Label } from '@workspace/ui/components/label';
|
||||||
import { Switch } from '@workspace/ui/components/switch';
|
import { Switch } from '@workspace/ui/components/switch';
|
||||||
@ -13,28 +13,22 @@ export default function Page() {
|
|||||||
const t = useTranslations('facebook');
|
const t = useTranslations('facebook');
|
||||||
|
|
||||||
const { data, refetch } = useQuery({
|
const { data, refetch } = useQuery({
|
||||||
queryKey: ['getOAuthConfig', 'facebook'],
|
queryKey: ['getOAuthByPlatform', 'facebook'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await getOAuthConfig();
|
const { data } = await getOAuthByPlatform({
|
||||||
return data.data?.list.find((item) => item.platform === 'facebook') as API.OAuthConfig;
|
platform: 'facebook',
|
||||||
|
});
|
||||||
|
return data.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async function updateConfig(key: keyof API.OAuthConfig, value: unknown) {
|
async function updateConfig(key: keyof API.UpdateOAuthConfig, value: unknown) {
|
||||||
if (data?.[key] === value) return;
|
if (data?.[key] === value) return;
|
||||||
try {
|
try {
|
||||||
if (data?.id) {
|
await updateOAuthConfig({
|
||||||
await oAuthCreateConfig({
|
...data,
|
||||||
...data,
|
[key]: value,
|
||||||
platform: 'facebook',
|
} as API.UpdateOAuthConfig);
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
} else {
|
|
||||||
await updateOAuthConfig({
|
|
||||||
...data,
|
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
}
|
|
||||||
toast.success(t('saveSuccess'));
|
toast.success(t('saveSuccess'));
|
||||||
refetch();
|
refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -65,8 +59,13 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='1234567890123456'
|
placeholder='1234567890123456'
|
||||||
value={data?.client_id}
|
value={data?.config?.client_id}
|
||||||
onValueBlur={(value) => updateConfig('client_id', value)}
|
onValueBlur={(value) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
client_id: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@ -78,8 +77,13 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='1234567890abcdef1234567890abcdef'
|
placeholder='1234567890abcdef1234567890abcdef'
|
||||||
value={data?.client_secret}
|
value={data?.config?.client_secret}
|
||||||
onValueBlur={(value) => updateConfig('client_secret', value)}
|
onValueBlur={(value) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
client_secret: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { getOAuthConfig, oAuthCreateConfig, updateOAuthConfig } from '@/services/admin/system';
|
import { getOAuthByPlatform, updateOAuthConfig } from '@/services/admin/system';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { Label } from '@workspace/ui/components/label';
|
import { Label } from '@workspace/ui/components/label';
|
||||||
import { Switch } from '@workspace/ui/components/switch';
|
import { Switch } from '@workspace/ui/components/switch';
|
||||||
@ -13,35 +13,28 @@ export default function Page() {
|
|||||||
const t = useTranslations('github');
|
const t = useTranslations('github');
|
||||||
|
|
||||||
const { data, refetch } = useQuery({
|
const { data, refetch } = useQuery({
|
||||||
queryKey: ['getOAuthConfig', 'github'],
|
queryKey: ['getOAuthByPlatform', 'github'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await getOAuthConfig();
|
const { data } = await getOAuthByPlatform({
|
||||||
return data.data?.list.find((item) => item.platform === 'github') as API.OAuthConfig;
|
platform: 'github',
|
||||||
|
});
|
||||||
|
return data.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async function updateConfig(key: keyof API.OAuthConfig, value: unknown) {
|
async function updateConfig(key: keyof API.UpdateOAuthConfig, value: unknown) {
|
||||||
if (data?.[key] === value) return;
|
if (data?.[key] === value) return;
|
||||||
try {
|
try {
|
||||||
if (data?.id) {
|
await updateOAuthConfig({
|
||||||
await oAuthCreateConfig({
|
...data,
|
||||||
...data,
|
[key]: value,
|
||||||
platform: 'github',
|
} as API.UpdateOAuthConfig);
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
} else {
|
|
||||||
await updateOAuthConfig({
|
|
||||||
...data,
|
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
}
|
|
||||||
toast.success(t('saveSuccess'));
|
toast.success(t('saveSuccess'));
|
||||||
refetch();
|
refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(t('saveFailed'));
|
toast.error(t('saveFailed'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
@ -65,8 +58,13 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='e.g., Iv1.1234567890abcdef'
|
placeholder='e.g., Iv1.1234567890abcdef'
|
||||||
value={data?.client_id}
|
value={data?.config?.client_id}
|
||||||
onValueBlur={(value) => updateConfig('client_id', value)}
|
onValueBlur={(value) =>
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
client_id: value,
|
||||||
|
})
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@ -78,8 +76,13 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='e.g., 1234567890abcdef1234567890abcdef12345678'
|
placeholder='e.g., 1234567890abcdef1234567890abcdef12345678'
|
||||||
value={data?.client_secret}
|
value={data?.config?.client_secret}
|
||||||
onValueBlur={(value) => updateConfig('client_secret', value)}
|
onValueBlur={(value) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
client_secret: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { getOAuthConfig, oAuthCreateConfig, updateOAuthConfig } from '@/services/admin/system';
|
import { getOAuthByPlatform, updateOAuthConfig } from '@/services/admin/system';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { Label } from '@workspace/ui/components/label';
|
import { Label } from '@workspace/ui/components/label';
|
||||||
import { Switch } from '@workspace/ui/components/switch';
|
import { Switch } from '@workspace/ui/components/switch';
|
||||||
@ -13,28 +13,22 @@ export default function Page() {
|
|||||||
const t = useTranslations('google');
|
const t = useTranslations('google');
|
||||||
|
|
||||||
const { data, refetch } = useQuery({
|
const { data, refetch } = useQuery({
|
||||||
queryKey: ['getOAuthConfig', 'google'],
|
queryKey: ['getOAuthByPlatform', 'google'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await getOAuthConfig();
|
const { data } = await getOAuthByPlatform({
|
||||||
return data.data?.list.find((item) => item.platform === 'google') as API.OAuthConfig;
|
platform: 'google',
|
||||||
|
});
|
||||||
|
return data.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async function updateConfig(key: keyof API.OAuthConfig, value: unknown) {
|
async function updateConfig(key: keyof API.UpdateOAuthConfig, value: unknown) {
|
||||||
if (data?.[key] === value) return;
|
if (data?.[key] === value) return;
|
||||||
try {
|
try {
|
||||||
if (data?.id) {
|
await updateOAuthConfig({
|
||||||
await oAuthCreateConfig({
|
...data,
|
||||||
...data,
|
[key]: value,
|
||||||
platform: 'google',
|
} as API.UpdateOAuthConfig);
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
} else {
|
|
||||||
await updateOAuthConfig({
|
|
||||||
...data,
|
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
}
|
|
||||||
toast.success(t('saveSuccess'));
|
toast.success(t('saveSuccess'));
|
||||||
refetch();
|
refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -65,8 +59,13 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='123456789-abc123def456.apps.googleusercontent.com'
|
placeholder='123456789-abc123def456.apps.googleusercontent.com'
|
||||||
value={data?.client_id}
|
value={data?.config?.client_id}
|
||||||
onValueBlur={(value) => updateConfig('client_id', value)}
|
onValueBlur={(value) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
client_id: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@ -78,8 +77,13 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='GOCSPX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
placeholder='GOCSPX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
||||||
value={data?.client_secret}
|
value={data?.config?.client_secret}
|
||||||
onValueBlur={(value) => updateConfig('client_secret', value)}
|
onValueBlur={(value) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
client_secret: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { getOAuthConfig, oAuthCreateConfig, updateOAuthConfig } from '@/services/admin/system';
|
import { getOAuthByPlatform, updateOAuthConfig } from '@/services/admin/system';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { Label } from '@workspace/ui/components/label';
|
import { Label } from '@workspace/ui/components/label';
|
||||||
import { Switch } from '@workspace/ui/components/switch';
|
import { Switch } from '@workspace/ui/components/switch';
|
||||||
@ -13,28 +13,22 @@ export default function Page() {
|
|||||||
const t = useTranslations('telegram');
|
const t = useTranslations('telegram');
|
||||||
|
|
||||||
const { data, refetch } = useQuery({
|
const { data, refetch } = useQuery({
|
||||||
queryKey: ['getOAuthConfig', 'telegram'],
|
queryKey: ['getOAuthByPlatform', 'telegram'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await getOAuthConfig();
|
const { data } = await getOAuthByPlatform({
|
||||||
return data.data?.list.find((item) => item.platform === 'telegram') as API.OAuthConfig;
|
platform: 'telegram',
|
||||||
|
});
|
||||||
|
return data.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async function updateConfig(key: keyof API.OAuthConfig, value: unknown) {
|
async function updateConfig(key: keyof API.UpdateOAuthConfig, value: unknown) {
|
||||||
if (data?.[key] === value) return;
|
if (data?.[key] === value) return;
|
||||||
try {
|
try {
|
||||||
if (data?.id) {
|
await updateOAuthConfig({
|
||||||
await oAuthCreateConfig({
|
...data,
|
||||||
...data,
|
[key]: value,
|
||||||
platform: 'telegram',
|
} as API.UpdateOAuthConfig);
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
} else {
|
|
||||||
await updateOAuthConfig({
|
|
||||||
...data,
|
|
||||||
[key]: value,
|
|
||||||
} as API.OAuthConfig);
|
|
||||||
}
|
|
||||||
toast.success(t('saveSuccess'));
|
toast.success(t('saveSuccess'));
|
||||||
refetch();
|
refetch();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -65,8 +59,13 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='6123456789'
|
placeholder='6123456789'
|
||||||
value={data?.client_id}
|
value={data?.config?.bot}
|
||||||
onValueBlur={(value) => updateConfig('client_id', value)}
|
onValueBlur={(value) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
bot: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@ -78,8 +77,13 @@ export default function Page() {
|
|||||||
<TableCell className='text-right'>
|
<TableCell className='text-right'>
|
||||||
<EnhancedInput
|
<EnhancedInput
|
||||||
placeholder='6123456789:AAHn_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
placeholder='6123456789:AAHn_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
||||||
value={data?.client_secret}
|
value={data?.config?.bot_token}
|
||||||
onValueBlur={(value) => updateConfig('client_secret', value)}
|
onValueBlur={(value) => {
|
||||||
|
updateConfig('config', {
|
||||||
|
...data?.config,
|
||||||
|
bot_token: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@ -226,9 +226,9 @@ export async function updateNodeConfig(body: API.NodeConfig, options?: { [key: s
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get OAuth config GET /v1/admin/system/oauth_config */
|
/** Get oauth config GET /v1/admin/system/oauth_config */
|
||||||
export async function getOAuthConfig(options?: { [key: string]: any }) {
|
export async function getOAuthConfig(options?: { [key: string]: any }) {
|
||||||
return request<API.Response & { data?: API.OAuthQueryResponse }>(
|
return request<API.Response & { data?: API.GetOAuthConfigResponse }>(
|
||||||
'/v1/admin/system/oauth_config',
|
'/v1/admin/system/oauth_config',
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@ -238,7 +238,10 @@ export async function getOAuthConfig(options?: { [key: string]: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Update oauth config PUT /v1/admin/system/oauth_config */
|
/** Update oauth config PUT /v1/admin/system/oauth_config */
|
||||||
export async function updateOAuthConfig(body: API.OAuthConfig, options?: { [key: string]: any }) {
|
export async function updateOAuthConfig(
|
||||||
|
body: API.UpdateOAuthConfig,
|
||||||
|
options?: { [key: string]: any },
|
||||||
|
) {
|
||||||
return request<API.Response & { data?: any }>('/v1/admin/system/oauth_config', {
|
return request<API.Response & { data?: any }>('/v1/admin/system/oauth_config', {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
@ -249,17 +252,17 @@ export async function updateOAuthConfig(body: API.OAuthConfig, options?: { [key:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** OAuth create config POST /v1/admin/system/oauth_config */
|
/** Get OAuth Config By Platform GET /v1/admin/system/oauth/platform */
|
||||||
export async function oAuthCreateConfig(
|
export async function getOAuthByPlatform(
|
||||||
body: API.OAuthCreateRequest,
|
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||||
|
params: API.GetOAuthByPlatformParams,
|
||||||
options?: { [key: string]: any },
|
options?: { [key: string]: any },
|
||||||
) {
|
) {
|
||||||
return request<API.Response & { data?: any }>('/v1/admin/system/oauth_config', {
|
return request<API.Response & { data?: API.OAuthMethod }>('/v1/admin/system/oauth/platform', {
|
||||||
method: 'POST',
|
method: 'GET',
|
||||||
headers: {
|
params: {
|
||||||
'Content-Type': 'application/json',
|
...params,
|
||||||
},
|
},
|
||||||
data: body,
|
|
||||||
...(options || {}),
|
...(options || {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
46
apps/admin/services/admin/typings.d.ts
vendored
46
apps/admin/services/admin/typings.d.ts
vendored
@ -27,6 +27,7 @@ declare namespace API {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type ApplicationConfig = {
|
type ApplicationConfig = {
|
||||||
|
encryption: boolean;
|
||||||
domains: string[];
|
domains: string[];
|
||||||
startup_picture: string;
|
startup_picture: string;
|
||||||
startup_picture_skip_time: number;
|
startup_picture_skip_time: number;
|
||||||
@ -457,6 +458,18 @@ declare namespace API {
|
|||||||
list: Server[];
|
list: Server[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type GetOAuthByPlatformParams = {
|
||||||
|
platform: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type GetOAuthByPlatformRequest = {
|
||||||
|
platform: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type GetOAuthConfigResponse = {
|
||||||
|
list: OAuthMethod[];
|
||||||
|
};
|
||||||
|
|
||||||
type GetOrderListParams = {
|
type GetOrderListParams = {
|
||||||
page: number;
|
page: number;
|
||||||
size: number;
|
size: number;
|
||||||
@ -619,29 +632,14 @@ declare namespace API {
|
|||||||
last_at: number;
|
last_at: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OAuthConfig = {
|
type OAuthMethod = {
|
||||||
id: number;
|
id: number;
|
||||||
platform: 'github' | 'google' | 'apple' | 'qq' | 'wechat' | 'telegram' | 'facebook';
|
platform: string;
|
||||||
team_id: string;
|
config: Record<string, any>;
|
||||||
key_id: string;
|
|
||||||
client_id: string;
|
|
||||||
client_secret: string;
|
|
||||||
redirect: string;
|
redirect: string;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
};
|
created_at: number;
|
||||||
|
updated_at: number;
|
||||||
type OAuthCreateRequest = {
|
|
||||||
platform: 'github' | 'google' | 'apple' | 'qq' | 'wechat' | 'telegram' | 'facebook';
|
|
||||||
team_id: string;
|
|
||||||
key_id: string;
|
|
||||||
client_id: string;
|
|
||||||
client_secret: string;
|
|
||||||
enabled: boolean;
|
|
||||||
redirect: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type OAuthQueryResponse = {
|
|
||||||
list: OAuthConfig[];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type OnlineUser = {
|
type OnlineUser = {
|
||||||
@ -1126,6 +1124,14 @@ declare namespace API {
|
|||||||
sort: number;
|
sort: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type UpdateOAuthConfig = {
|
||||||
|
id: number;
|
||||||
|
platform: string;
|
||||||
|
config: Record<string, any>;
|
||||||
|
redirect: string;
|
||||||
|
enabled: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
type UpdateOrderStatusRequest = {
|
type UpdateOrderStatusRequest = {
|
||||||
id: number;
|
id: number;
|
||||||
status: number;
|
status: number;
|
||||||
|
|||||||
22
apps/admin/services/common/typings.d.ts
vendored
22
apps/admin/services/common/typings.d.ts
vendored
@ -19,6 +19,7 @@ declare namespace API {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type ApplicationConfig = {
|
type ApplicationConfig = {
|
||||||
|
encryption: boolean;
|
||||||
domains: string[];
|
domains: string[];
|
||||||
startup_picture: string;
|
startup_picture: string;
|
||||||
startup_picture_skip_time: number;
|
startup_picture_skip_time: number;
|
||||||
@ -210,21 +211,20 @@ declare namespace API {
|
|||||||
method: string;
|
method: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OAuthConfig = {
|
|
||||||
id: number;
|
|
||||||
platform: 'github' | 'google' | 'apple' | 'qq' | 'wechat' | 'telegram' | 'facebook';
|
|
||||||
team_id: string;
|
|
||||||
key_id: string;
|
|
||||||
client_id: string;
|
|
||||||
client_secret: string;
|
|
||||||
redirect: string;
|
|
||||||
enabled: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type OAuthLoginResponse = {
|
type OAuthLoginResponse = {
|
||||||
redirect: string;
|
redirect: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type OAuthMethod = {
|
||||||
|
id: number;
|
||||||
|
platform: string;
|
||||||
|
config: Record<string, any>;
|
||||||
|
redirect: string;
|
||||||
|
enabled: boolean;
|
||||||
|
created_at: number;
|
||||||
|
updated_at: number;
|
||||||
|
};
|
||||||
|
|
||||||
type OnlineUser = {
|
type OnlineUser = {
|
||||||
uid: number;
|
uid: number;
|
||||||
ip: string;
|
ip: string;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user