mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
feat: 添加请求体规则功能和 UI 优化
- 添加 body_rules 支持(set/drop/rename 操作) - 后端 apply_body_rules 函数处理请求体修改 - 保护 model/stream 字段不被修改 - 前端 UI 重构:合并请求头/请求体规则为统一区域 - 使用左边框颜色区分规则类型(H=主题色,B=灰色) Closes #139 Co-authored-by: CC <81609553+hemo94931@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import client from '../client'
|
||||
import type { ProviderEndpoint, ProxyConfig, HeaderRule, FormatAcceptanceConfig } from './types'
|
||||
import type { ProviderEndpoint, ProxyConfig, HeaderRule, BodyRule, FormatAcceptanceConfig } from './types'
|
||||
|
||||
/**
|
||||
* 获取指定 Provider 的所有 Endpoints
|
||||
@@ -28,6 +28,7 @@ export async function createEndpoint(
|
||||
base_url: string
|
||||
custom_path?: string
|
||||
header_rules?: HeaderRule[]
|
||||
body_rules?: BodyRule[]
|
||||
max_retries?: number
|
||||
is_active?: boolean
|
||||
config?: Record<string, any>
|
||||
@@ -48,6 +49,7 @@ export async function updateEndpoint(
|
||||
base_url: string
|
||||
custom_path: string | null
|
||||
header_rules: HeaderRule[] | null
|
||||
body_rules: BodyRule[] | null
|
||||
max_retries: number
|
||||
is_active: boolean
|
||||
config: Record<string, any>
|
||||
|
||||
@@ -114,6 +114,31 @@ export interface HeaderRuleRename {
|
||||
|
||||
export type HeaderRule = HeaderRuleSet | HeaderRuleDrop | HeaderRuleRename
|
||||
|
||||
/**
|
||||
* 请求体规则类型
|
||||
* - set: 设置/覆盖字段
|
||||
* - drop: 删除字段
|
||||
* - rename: 重命名字段(保留原值)
|
||||
*/
|
||||
export interface BodyRuleSet {
|
||||
action: 'set'
|
||||
path: string
|
||||
value: any
|
||||
}
|
||||
|
||||
export interface BodyRuleDrop {
|
||||
action: 'drop'
|
||||
path: string
|
||||
}
|
||||
|
||||
export interface BodyRuleRename {
|
||||
action: 'rename'
|
||||
from: string
|
||||
to: string
|
||||
}
|
||||
|
||||
export type BodyRule = BodyRuleSet | BodyRuleDrop | BodyRuleRename
|
||||
|
||||
/**
|
||||
* 格式接受策略配置
|
||||
* 用于控制端点是否接受来自不同 API 格式的请求,并自动进行格式转换
|
||||
@@ -133,6 +158,8 @@ export interface ProviderEndpoint {
|
||||
custom_path?: string // 自定义请求路径(可选,为空则使用 API 格式默认路径)
|
||||
// 请求头配置
|
||||
header_rules?: HeaderRule[] // 请求头规则列表,支持 set/drop/rename 操作
|
||||
// 请求体配置
|
||||
body_rules?: BodyRule[] // 请求体规则列表,支持 set/drop/rename 操作
|
||||
max_retries: number
|
||||
is_active: boolean
|
||||
config?: Record<string, any>
|
||||
|
||||
Reference in New Issue
Block a user