fix: can not paste a text in env vars input box

This commit is contained in:
jialin
2025-03-19 20:09:43 +08:00
parent 2ceefab18c
commit b8f58b2cc1
4 changed files with 28 additions and 53 deletions
+3 -3
View File
@@ -44,6 +44,7 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
[setLabelList] [setLabelList]
); );
const handleLabelsChange = (data: Record<string, any>) => { const handleLabelsChange = (data: Record<string, any>) => {
console.log('handleLabelsChange', data);
setLabelsData(data); setLabelsData(data);
onChange?.(data); onChange?.(data);
}; };
@@ -52,10 +53,9 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
e: React.ClipboardEvent<HTMLTextAreaElement>, e: React.ClipboardEvent<HTMLTextAreaElement>,
index: number index: number
) => { ) => {
e.preventDefault();
const clipboardText = e.clipboardData.getData('text'); const clipboardText = e.clipboardData.getData('text');
if (!clipboardText) return; if (!clipboardText || clipboardText.indexOf('=') === -1) return;
e.preventDefault();
const lines = clipboardText const lines = clipboardText
.split(/\r?\n/) .split(/\r?\n/)
-1
View File
@@ -26,7 +26,6 @@ export function patchRoutes({ routes, initialState }) {
export function renderMenuIcon(icon: string) { export function renderMenuIcon(icon: string) {
const upperIcon = formatIcon(icon); const upperIcon = formatIcon(icon);
console.log('upperIcon', icon, upperIcon);
if (icons[upperIcon] || icons[upperIcon + 'Outlined']) { if (icons[upperIcon] || icons[upperIcon + 'Outlined']) {
return React.createElement( return React.createElement(
icons[upperIcon] || icons[upperIcon + 'Outlined'] icons[upperIcon] || icons[upperIcon + 'Outlined']
+19 -1
View File
@@ -3,7 +3,8 @@ import HotKeys from '@/config/hotkeys';
import { import {
DeleteOutlined, DeleteOutlined,
EditOutlined, EditOutlined,
ExperimentOutlined ExperimentOutlined,
ThunderboltOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import _ from 'lodash'; import _ from 'lodash';
import React from 'react'; import React from 'react';
@@ -13,6 +14,7 @@ const icons = {
EditOutlined: React.createElement(EditOutlined), EditOutlined: React.createElement(EditOutlined),
ExperimentOutlined: React.createElement(ExperimentOutlined), ExperimentOutlined: React.createElement(ExperimentOutlined),
DeleteOutlined: React.createElement(DeleteOutlined), DeleteOutlined: React.createElement(DeleteOutlined),
ThunderboltOutlined: React.createElement(ThunderboltOutlined),
Stop: React.createElement(IconFont, { type: 'icon-stop1' }), Stop: React.createElement(IconFont, { type: 'icon-stop1' }),
Play: React.createElement(IconFont, { type: 'icon-outline-play' }), Play: React.createElement(IconFont, { type: 'icon-outline-play' }),
Catalog: React.createElement(IconFont, { type: 'icon-catalog' }), Catalog: React.createElement(IconFont, { type: 'icon-catalog' }),
@@ -184,6 +186,22 @@ export const setModelActionList = (record: any) => {
}); });
}; };
export const modelFileActions = [
{
label: 'common.button.deploy',
key: 'deploy',
icon: icons.ThunderboltOutlined
},
{
label: 'common.button.delete',
key: 'delete',
props: {
danger: true
},
icon: icons.DeleteOutlined
}
];
export const categoryToPathMap: Record<string, string> = { export const categoryToPathMap: Record<string, string> = {
[modelCategoriesMap.llm]: '/playground/chat', [modelCategoriesMap.llm]: '/playground/chat',
[modelCategoriesMap.image]: '/playground/text-to-image', [modelCategoriesMap.image]: '/playground/text-to-image',
+6 -48
View File
@@ -7,64 +7,22 @@ import StatusTag from '@/components/status-tag';
import useTableFetch from '@/hooks/use-table-fetch'; import useTableFetch from '@/hooks/use-table-fetch';
import { modelSourceMap } from '@/pages/llmodels/config'; import { modelSourceMap } from '@/pages/llmodels/config';
import { import {
generateSource,
modalConfig, modalConfig,
modelFileActions,
onLineSourceOptions onLineSourceOptions
} from '@/pages/llmodels/config/button-actions'; } from '@/pages/llmodels/config/button-actions';
import DownloadModal from '@/pages/llmodels/download'; import DownloadModal from '@/pages/llmodels/download';
import { import { DeleteOutlined, DownOutlined, SyncOutlined } from '@ant-design/icons';
DeleteOutlined,
DownOutlined,
SyncOutlined,
ThunderboltOutlined
} from '@ant-design/icons';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import React, { import { Button, ConfigProvider, Empty, Input, Space, Table } from 'antd';
Button,
ConfigProvider,
Empty,
Input,
Space,
Table
} from 'antd';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { useState } from 'react'; import { useState } from 'react';
import { deleteWorker, queryWorkersList } from '../apis'; import { deleteWorker, queryWorkersList } from '../apis';
import { WorkerStatusMapValue, status } from '../config'; import { WorkerStatusMapValue, status } from '../config';
import { ModelFile as ListItem } from '../config/types'; import { ModelFile as ListItem } from '../config/types';
const ActionList = [ const ModelFiles = () => {
{
label: 'common.button.deploy',
key: 'deploy',
icon: <ThunderboltOutlined />
},
{
label: 'common.button.delete',
key: 'delete',
props: {
danger: true
},
icon: <DeleteOutlined />
}
];
const generateSource = (record: ListItem) => {
if (record.source === modelSourceMap.modelscope_value) {
return `${modelSourceMap.modelScope}/${record.model_scope_model_id}`;
}
if (record.source === modelSourceMap.huggingface_value) {
return `${modelSourceMap.huggingface}/${record.huggingface_repo_id}`;
}
if (record.source === modelSourceMap.local_path_value) {
return `${record.local_path}`;
}
if (record.source === modelSourceMap.ollama_library_value) {
return `${modelSourceMap.ollama_library}/${record.ollama_library_model_name}`;
}
return '';
};
const ModelFiles: React.FC = () => {
const { const {
dataSource, dataSource,
rowSelection, rowSelection,
@@ -208,7 +166,7 @@ const ModelFiles: React.FC = () => {
dataIndex: 'operation', dataIndex: 'operation',
render: (text: string, record: ListItem) => ( render: (text: string, record: ListItem) => (
<DropdownButtons <DropdownButtons
items={ActionList} items={modelFileActions}
onSelect={(val) => handleSelect(val, record)} onSelect={(val) => handleSelect(val, record)}
></DropdownButtons> ></DropdownButtons>
) )