mirror of
				https://github.com/whyour/qinglong.git
				synced 2025-11-04 20:06:08 +08:00 
			
		
		
		
	环境变量支持搜索
This commit is contained in:
		
							parent
							
								
									6c943ac97a
								
							
						
					
					
						commit
						49ab1ad93a
					
				| 
						 | 
					@ -13,7 +13,7 @@ export default (app: Router) => {
 | 
				
			||||||
      const logger: Logger = Container.get('logger');
 | 
					      const logger: Logger = Container.get('logger');
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
        const envService = Container.get(EnvService);
 | 
					        const envService = Container.get(EnvService);
 | 
				
			||||||
        const data = await envService.envs('', { position: -1 });
 | 
					        const data = await envService.envs(req.query.searchValue as string);
 | 
				
			||||||
        return res.send({ code: 200, data });
 | 
					        return res.send({ code: 200, data });
 | 
				
			||||||
      } catch (e) {
 | 
					      } catch (e) {
 | 
				
			||||||
        logger.error('🔥 error: %o', e);
 | 
					        logger.error('🔥 error: %o', e);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -109,7 +109,7 @@ export default class EnvService {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public async envs(
 | 
					  public async envs(
 | 
				
			||||||
    searchText?: string,
 | 
					    searchText: string = '',
 | 
				
			||||||
    sort: any = { position: -1 },
 | 
					    sort: any = { position: -1 },
 | 
				
			||||||
    query: any = {},
 | 
					    query: any = {},
 | 
				
			||||||
  ): Promise<Env[]> {
 | 
					  ): Promise<Env[]> {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										21
									
								
								src/pages/env/index.tsx
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								src/pages/env/index.tsx
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -8,6 +8,7 @@ import {
 | 
				
			||||||
  Space,
 | 
					  Space,
 | 
				
			||||||
  Typography,
 | 
					  Typography,
 | 
				
			||||||
  Tooltip,
 | 
					  Tooltip,
 | 
				
			||||||
 | 
					  Input,
 | 
				
			||||||
} from 'antd';
 | 
					} from 'antd';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  EditOutlined,
 | 
					  EditOutlined,
 | 
				
			||||||
| 
						 | 
					@ -26,6 +27,7 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
 | 
				
			||||||
import './index.less';
 | 
					import './index.less';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { Text } = Typography;
 | 
					const { Text } = Typography;
 | 
				
			||||||
 | 
					const { Search } = Input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum Status {
 | 
					enum Status {
 | 
				
			||||||
  '已启用',
 | 
					  '已启用',
 | 
				
			||||||
| 
						 | 
					@ -198,11 +200,12 @@ const Env = () => {
 | 
				
			||||||
  const [isEditNameModalVisible, setIsEditNameModalVisible] = useState(false);
 | 
					  const [isEditNameModalVisible, setIsEditNameModalVisible] = useState(false);
 | 
				
			||||||
  const [editedEnv, setEditedEnv] = useState();
 | 
					  const [editedEnv, setEditedEnv] = useState();
 | 
				
			||||||
  const [selectedRowIds, setSelectedRowIds] = useState<string[]>([]);
 | 
					  const [selectedRowIds, setSelectedRowIds] = useState<string[]>([]);
 | 
				
			||||||
 | 
					  const [searchText, setSearchText] = useState('');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const getEnvs = () => {
 | 
					  const getEnvs = () => {
 | 
				
			||||||
    setLoading(true);
 | 
					    setLoading(true);
 | 
				
			||||||
    request
 | 
					    request
 | 
				
			||||||
      .get(`${config.apiPrefix}envs`)
 | 
					      .get(`${config.apiPrefix}envs?searchValue=${searchText}`)
 | 
				
			||||||
      .then((data: any) => {
 | 
					      .then((data: any) => {
 | 
				
			||||||
        setValue(data.data);
 | 
					        setValue(data.data);
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
| 
						 | 
					@ -409,6 +412,14 @@ const Env = () => {
 | 
				
			||||||
    setIsEditNameModalVisible(true);
 | 
					    setIsEditNameModalVisible(true);
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const onSearch = (value: string) => {
 | 
				
			||||||
 | 
					    setSearchText(value);
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  useEffect(() => {
 | 
				
			||||||
 | 
					    getEnvs();
 | 
				
			||||||
 | 
					  }, [searchText]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  useEffect(() => {
 | 
					  useEffect(() => {
 | 
				
			||||||
    if (document.body.clientWidth < 768) {
 | 
					    if (document.body.clientWidth < 768) {
 | 
				
			||||||
      setWidth('auto');
 | 
					      setWidth('auto');
 | 
				
			||||||
| 
						 | 
					@ -419,7 +430,6 @@ const Env = () => {
 | 
				
			||||||
      setMarginLeft(0);
 | 
					      setMarginLeft(0);
 | 
				
			||||||
      setMarginTop(-72);
 | 
					      setMarginTop(-72);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    getEnvs();
 | 
					 | 
				
			||||||
  }, []);
 | 
					  }, []);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
| 
						 | 
					@ -427,6 +437,13 @@ const Env = () => {
 | 
				
			||||||
      className="env-wrapper"
 | 
					      className="env-wrapper"
 | 
				
			||||||
      title="环境变量"
 | 
					      title="环境变量"
 | 
				
			||||||
      extra={[
 | 
					      extra={[
 | 
				
			||||||
 | 
					        <Search
 | 
				
			||||||
 | 
					          placeholder="请输入名称/值/备注"
 | 
				
			||||||
 | 
					          style={{ width: 'auto' }}
 | 
				
			||||||
 | 
					          enterButton
 | 
				
			||||||
 | 
					          loading={loading}
 | 
				
			||||||
 | 
					          onSearch={onSearch}
 | 
				
			||||||
 | 
					        />,
 | 
				
			||||||
        <Button key="2" type="primary" onClick={() => addEnv()}>
 | 
					        <Button key="2" type="primary" onClick={() => addEnv()}>
 | 
				
			||||||
          添加Env
 | 
					          添加Env
 | 
				
			||||||
        </Button>,
 | 
					        </Button>,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user