feat(config): Update encryption fields in configuration form and refactor OAuth callback parameters

This commit is contained in:
web@ppanel
2025-01-20 22:23:04 +07:00
parent d1f5a9b825
commit 652e0323fd
5 changed files with 69 additions and 22 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
// @ts-ignore
// API 更新时间:
// API 唯一标识:
import * as announcement from './announcement';
+1 -1
View File
@@ -1,5 +1,5 @@
// @ts-ignore
// API 更新时间:
// API 唯一标识:
import * as auth from './auth';
+36 -2
View File
@@ -3,9 +3,36 @@
import request from '@/utils/request';
/** Apple Login Callback POST /v1/auth/oauth/callback/apple */
export async function appleLoginCallback(options?: { [key: string]: any }) {
export async function appleLoginCallback(
body: {
code: string;
id_token: string;
state: string;
},
options?: { [key: string]: any },
) {
const formData = new FormData();
Object.keys(body).forEach((ele) => {
const item = (body as any)[ele];
if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
formData.append(ele, JSON.stringify(item));
}
} else {
formData.append(ele, item);
}
}
});
return request<API.Response & { data?: any }>('/v1/auth/oauth/callback/apple', {
method: 'POST',
data: formData,
requestType: 'form',
...(options || {}),
});
}
@@ -19,9 +46,16 @@ export async function facebookLoginCallback(options?: { [key: string]: any }) {
}
/** Google Login Callback GET /v1/auth/oauth/callback/google */
export async function googleLoginCallback(options?: { [key: string]: any }) {
export async function googleLoginCallback(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.GoogleLoginCallbackParams,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/auth/oauth/callback/google', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
+16
View File
@@ -10,6 +10,12 @@ declare namespace API {
updated_at: number;
};
type AppleLoginCallbackRequest = {
code: string;
id_token: string;
state: string;
};
type Application = {
id: number;
icon: string;
@@ -172,6 +178,16 @@ declare namespace API {
tos_content: string;
};
type GoogleLoginCallbackParams = {
code: string;
state: string;
};
type GoogleLoginCallbackRequest = {
code: string;
state: string;
};
type Hysteria2 = {
port: number;
hop_ports: string;