-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat aiproxy admin panel and user client phase II (#5299)
* init admin layout * add admin sidebar * change dir name * ok * ok * add select combox * add dashboard * add config * v1 * refactor api * ok * ok * add global-config api * ok * ok * ok * ok * ok * ok * ok * ok * ok * ok * ok * ok * refact user logs * frontend(aiproxy): refact user logs * fix dynamic render * add dashboard * add react echart * chore * phase 2 * chore adjust ui * chore * temp user realname * Optimize real-name verification logic * chore * chore * chore * chore * fix admin channel create multiple input * Add Invitation Event Popup
- Loading branch information
Showing
136 changed files
with
14,482 additions
and
2,011 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,124 @@ | ||
import { KeysSearchResponse } from '@/app/api/get-keys/route' | ||
import { QueryParams, SearchResponse } from '@/app/api/get-logs/route' | ||
import { QueryParams as KeysQueryParams } from '@/app/api/get-keys/route' | ||
import { GET, POST, DELETE } from '@/utils/request' | ||
import { ModelPrice } from '@/types/backend' | ||
import { GET, POST, DELETE, PUT } from '@/utils/frontend/request' | ||
import { ChannelQueryParams, GetChannelsResponse } from '@/app/api/admin/channel/route' | ||
import { ChannelStatus, CreateChannelRequest } from '@/types/admin/channels/channelInfo' | ||
import { ApiResp } from '@/types/api' | ||
import { GetOptionResponse } from '@/app/api/admin/option/route' | ||
import { BatchOptionData } from '@/types/admin/option' | ||
import { GetEnabledModelsResponse } from '@/app/api/models/enabled/route' | ||
import { GetTokensQueryParams, GetTokensResponse } from '@/app/api/user/token/route' | ||
import { TokenInfo } from '@/types/user/token' | ||
import { UserLogSearchResponse } from '@/app/api/user/log/route' | ||
import { UserLogQueryParams } from '@/app/api/user/log/route' | ||
import { GlobalLogQueryParams, GlobalLogSearchResponse } from '@/app/api/admin/log/route' | ||
import { GetAllChannelEnabledModelsResponse } from '@/app/api/models/builtin/channel/route' | ||
import { GetDefaultModelAndModeMappingResponse } from '@/app/api/models/default/route' | ||
import { GetChannelTypeNamesResponse } from '@/app/api/admin/channel/type-name/route' | ||
import { GroupQueryParams, GroupStatus } from '@/types/admin/group' | ||
import { GroupSearchResponse } from '@/app/api/admin/group/route' | ||
import { GetAllChannelResponse } from '@/app/api/admin/channel/all/route' | ||
import { DashboardQueryParams } from '@/app/api/user/dashboard/route' | ||
import { DashboardResponse } from '@/types/user/dashboard' | ||
import { UserLogDetailResponse } from '@/app/api/user/log/detail/[log_id]/route' | ||
|
||
export const initAppConfig = () => | ||
GET<{ aiproxyBackend: string; currencySymbol: 'shellCoin' | 'cny' | 'usd' }>( | ||
'/api/init-app-config' | ||
) | ||
GET<{ | ||
aiproxyBackend: string | ||
currencySymbol: 'shellCoin' | 'cny' | 'usd' | ||
docUrl: string | ||
isInvitationActive: boolean | ||
invitationUrl: string | ||
}>('/api/init-app-config') | ||
|
||
export const getModels = () => GET<string[]>('/api/get-models') | ||
// <user> | ||
export const getEnabledMode = () => GET<GetEnabledModelsResponse['data']>('/api/models/enabled') | ||
|
||
export const getModelPrices = () => GET<ModelPrice[]>('/api/get-mode-price') | ||
// log | ||
export const getUserLogs = (params: UserLogQueryParams) => | ||
GET<UserLogSearchResponse['data']>('/api/user/log', params) | ||
|
||
export const getLogs = (params: QueryParams) => GET<SearchResponse['data']>('/api/get-logs', params) | ||
export const getUserLogDetail = (log_id: number) => | ||
GET<UserLogDetailResponse['data']>(`/api/user/log/detail/${log_id}`) | ||
|
||
export const getKeys = (params: KeysQueryParams) => | ||
GET<KeysSearchResponse['data']>('/api/get-keys', params) | ||
// token | ||
export const getTokens = (params: GetTokensQueryParams) => | ||
GET<GetTokensResponse['data']>('/api/user/token', params) | ||
|
||
export const createKey = (name: string) => POST('/api/create-key', { name }) | ||
export const createToken = (name: string) => | ||
POST<ApiResp<TokenInfo>['data']>('/api/user/token', { name }) | ||
|
||
export const deleteKey = (id: number) => DELETE(`/api/delete-key/${id}`) | ||
export const deleteToken = (id: number) => DELETE(`/api/user/token/${id}`) | ||
|
||
export const updateKey = (id: number, status: number) => POST(`/api/update-key/${id}`, { status }) | ||
export const updateToken = (id: number, status: number) => | ||
POST<ApiResp>(`/api/user/token/${id}`, { status: status }) | ||
|
||
// dashboard | ||
export const getDashboardData = (params: DashboardQueryParams) => | ||
GET<DashboardResponse['data']>('/api/user/dashboard', params) | ||
// ------------------------------------------------------------ | ||
// <admin> | ||
|
||
export const getChannels = (params: ChannelQueryParams) => | ||
GET<GetChannelsResponse['data']>('/api/admin/channel', params) | ||
|
||
// channel | ||
export const createChannel = (params: CreateChannelRequest) => | ||
POST<ApiResp>('/api/admin/channel', params) | ||
|
||
export const updateChannel = (params: CreateChannelRequest, id: string) => | ||
PUT<ApiResp>(`/api/admin/channel/${id}`, params) | ||
|
||
export const updateChannelStatus = (id: string, status: ChannelStatus) => | ||
POST<ApiResp>(`/api/admin/channel/${id}/status`, { status }) | ||
|
||
export const getChannelTypeNames = () => | ||
GET<GetChannelTypeNamesResponse['data']>('/api/admin/channel/type-name') | ||
|
||
export const getAllChannels = () => GET<GetAllChannelResponse['data']>('/api/admin/channel/all') | ||
|
||
export const deleteChannel = (id: string) => DELETE(`/api/admin/channel/${id}`) | ||
|
||
export const uploadChannels = (formData: FormData) => | ||
POST<ApiResp>('/api/admin/channel/upload', formData, { | ||
headers: { | ||
// Don't set Content-Type header here, it will be automatically set with the correct boundary | ||
} | ||
}) | ||
|
||
// channel built-in support models and default model default mode mapping | ||
export const getChannelBuiltInSupportModels = () => | ||
GET<GetAllChannelEnabledModelsResponse['data']>('/api/models/builtin/channel') | ||
|
||
export const getChannelDefaultModelAndDefaultModeMapping = () => | ||
GET<GetDefaultModelAndModeMappingResponse['data']>('/api/models/default') | ||
|
||
// option | ||
export const getOption = () => GET<GetOptionResponse['data']>('/api/admin/option') | ||
|
||
export const updateOption = (params: { key: string; value: string }) => | ||
PUT<ApiResp>(`/api/admin/option/`, params) | ||
|
||
export const batchOption = (params: BatchOptionData) => | ||
PUT<ApiResp>(`/api/admin/option/batch`, params) | ||
|
||
export const uploadOptions = (formData: FormData) => | ||
POST<ApiResp>('/api/admin/option/upload', formData, { | ||
headers: { | ||
// Don't set Content-Type header here, it will be automatically set with the correct boundary | ||
} | ||
}) | ||
|
||
// log | ||
export const getGlobalLogs = (params: GlobalLogQueryParams) => | ||
GET<GlobalLogSearchResponse['data']>('/api/admin/log', params) | ||
|
||
// group | ||
export const getGroups = (params: GroupQueryParams) => | ||
GET<GroupSearchResponse['data']>('/api/admin/group', params) | ||
|
||
export const updateGroupStatus = (id: string, status: GroupStatus) => | ||
POST<ApiResp>(`/api/admin/group/${id}/status`, { status }) | ||
|
||
export const updateGroupQpm = (id: string, qpm: number) => | ||
POST<ApiResp>(`/api/admin/group/${id}/qpm`, { qpm }) | ||
|
||
export const deleteGroup = (id: string) => DELETE(`/api/admin/group/${id}`) |
Oops, something went wrong.