feat: duplicate deployment

This commit is contained in:
jialin
2026-02-04 14:58:48 +08:00
parent 5ad9ac277c
commit 05c05419fc
25 changed files with 366 additions and 220 deletions
+12 -11
View File
@@ -36,17 +36,18 @@ export async function deleteModelRoute(id: number) {
});
}
export async function queryRouteTargets(params: { id: number }, options?: any) {
return request<Global.PageResponse<RouteTarget>>(
`${MODEL_ROUTE_TARGETS}?route_id=${params.id}`,
{
method: 'GET',
params: {
page: -1
},
cancelToken: options?.token
}
);
export async function queryRouteTargets(
params: { id?: number },
options?: any
) {
return request<Global.PageResponse<RouteTarget>>(`${MODEL_ROUTE_TARGETS}`, {
method: 'GET',
params: {
route_id: params.id,
page: -1
},
cancelToken: options?.token
});
}
export async function deleteModelRouteTarget(id: number) {
+5
View File
@@ -29,6 +29,11 @@ export const rowActionList = [
key: 'chat',
icon: icons.ExperimentOutlined
},
{
label: 'models.table.button.apiAccessInfo',
key: 'api',
icon: icons.ApiOutlined
},
{
label: 'models.button.accessSettings',
key: 'accessControl',
+2 -5
View File
@@ -38,13 +38,10 @@ export interface RouteTarget {
id: number;
created_at: string;
updated_at: string;
deleted_at: string;
provider_model_name: string;
weight: number | null;
weight: number;
model_id: number;
provider_id: number;
name: string;
route_name: string;
route_id: number;
state: string;
fallback_status_codes: string[];
}
+11 -2
View File
@@ -13,10 +13,19 @@ const Basic = () => {
const { getRuleMessage } = useAppUtils();
return (
<>
<Form.Item name="name" data-field="name">
<Form.Item
name="name"
data-field="name"
rules={[
{
required: true,
message: getRuleMessage('input', 'common.table.name')
}
]}
>
<SealInput.Input
required
label={intl.formatMessage({ id: 'models.table.name' })}
label={intl.formatMessage({ id: 'common.table.name' })}
/>
</Form.Item>
<Form.Item
@@ -18,7 +18,7 @@ const useAccessColumns = (
const filterActions = (record: RouteItem) => {
return rowActionList.filter((action) => {
if (action.key === 'chat') {
if (action.key === 'chat' || action.key === 'api') {
return record.ready_targets > 0;
}
return true;
@@ -0,0 +1,30 @@
import { useState } from 'react';
const useViewApIInfo = () => {
const [apiAccessInfo, setAPIAccessInfo] = useState<any>({
show: false,
data: {}
});
const openViewAPIInfo = (row: any) => {
setAPIAccessInfo({
show: true,
data: row
});
};
const closeViewAPIInfo = () => {
setAPIAccessInfo({
show: false,
data: {}
});
};
return {
apiAccessInfo,
openViewAPIInfo,
closeViewAPIInfo
};
};
export default useViewApIInfo;
+10
View File
@@ -10,6 +10,7 @@ import { TABLE_SORT_DIRECTIONS } from '@/config/settings';
import useExpandedRowKeys from '@/hooks/use-expanded-row-keys';
import useTableFetch from '@/hooks/use-table-fetch';
import useWatchList from '@/hooks/use-watch-list';
import APIAccessInfoModal from '@/pages/llmodels/components/api-access-info';
import { useIntl } from '@umijs/max';
import { useMemoizedFn } from 'ahooks';
import { message } from 'antd';
@@ -39,6 +40,7 @@ import useCreateRoute from './hooks/use-create-route';
import useOpenPlayground from './hooks/use-open-playground';
import useRoutesColumns from './hooks/use-routes-columns';
import useTargetSourceModels from './hooks/use-target-source-models';
import useViewApIInfo from './hooks/use-view-api-info';
const ModelRoutes: React.FC = () => {
const {
@@ -75,6 +77,7 @@ const ModelRoutes: React.FC = () => {
} = useAccessControl();
const { sourceModels, fetchSourceModels } = useTargetSourceModels();
const { handleOpenPlayGround } = useOpenPlayground();
const { apiAccessInfo, openViewAPIInfo, closeViewAPIInfo } = useViewApIInfo();
const [modelList, setModelsList] = useState<Global.BaseOption<number>[]>([]);
useEffect(() => {
@@ -149,6 +152,8 @@ const ModelRoutes: React.FC = () => {
);
} else if (val === 'chat') {
handleOpenPlayGround(row);
} else if (val === 'api') {
openViewAPIInfo(row);
}
});
@@ -316,6 +321,11 @@ const ModelRoutes: React.FC = () => {
currentData={openAccessControlModalStatus.currentData}
action={openAccessControlModalStatus.action}
></AccessControlModal>
<APIAccessInfoModal
open={apiAccessInfo.show}
data={apiAccessInfo.data}
onClose={closeViewAPIInfo}
></APIAccessInfoModal>
<DeleteModal ref={modalRef}></DeleteModal>
</>
);
@@ -0,0 +1,23 @@
import { useQueryDataList } from '@/hooks/use-query-data-list';
import { queryRouteTargets } from '../apis';
import { RouteTarget as ListItem } from '../config/types';
export const useQueryRouteTargets = (optons?: {
getLabel?: (item: ListItem) => string;
getValue?: (item: ListItem) => any;
}) => {
const { dataList, loading, fetchData, cancelRequest } =
useQueryDataList<ListItem>({
key: 'routeTargets',
fetchList: queryRouteTargets
});
return {
dataList,
loading,
fetchData,
cancelRequest
};
};
export default useQueryRouteTargets;