mirror of
				https://github.com/whyour/qinglong.git
				synced 2025-11-04 20:06:08 +08:00 
			
		
		
		
	
							parent
							
								
									920efb8fab
								
							
						
					
					
						commit
						8079e4e7b8
					
				| 
						 | 
					@ -1,3 +1,11 @@
 | 
				
			||||||
.ant-table-pagination.ant-pagination {
 | 
					.ant-table-pagination.ant-pagination {
 | 
				
			||||||
  margin-bottom: 0 !important;
 | 
					  margin-bottom: 0 !important;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					tr {
 | 
				
			||||||
 | 
					  td:nth-child(2) {
 | 
				
			||||||
 | 
					    span {
 | 
				
			||||||
 | 
					      cursor: pointer;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,7 @@ import CronLogModal from './logModal';
 | 
				
			||||||
import cron_parser from 'cron-parser';
 | 
					import cron_parser from 'cron-parser';
 | 
				
			||||||
import { diffTime } from '@/utils/date';
 | 
					import { diffTime } from '@/utils/date';
 | 
				
			||||||
import { getTableScroll } from '@/utils/index';
 | 
					import { getTableScroll } from '@/utils/index';
 | 
				
			||||||
 | 
					import { history } from 'umi';
 | 
				
			||||||
import './index.less';
 | 
					import './index.less';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { Text } = Typography;
 | 
					const { Text } = Typography;
 | 
				
			||||||
| 
						 | 
					@ -76,7 +77,11 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
 | 
				
			||||||
      width: 150,
 | 
					      width: 150,
 | 
				
			||||||
      align: 'center' as const,
 | 
					      align: 'center' as const,
 | 
				
			||||||
      render: (text: string, record: any) => (
 | 
					      render: (text: string, record: any) => (
 | 
				
			||||||
        <span>
 | 
					        <span
 | 
				
			||||||
 | 
					          onClick={() => {
 | 
				
			||||||
 | 
					            goToScriptManager(record);
 | 
				
			||||||
 | 
					          }}
 | 
				
			||||||
 | 
					        >
 | 
				
			||||||
          {record.name || record._id}{' '}
 | 
					          {record.name || record._id}{' '}
 | 
				
			||||||
          {record.isPinned ? (
 | 
					          {record.isPinned ? (
 | 
				
			||||||
            <span>
 | 
					            <span>
 | 
				
			||||||
| 
						 | 
					@ -329,6 +334,20 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
 | 
				
			||||||
  const [pageSize, setPageSize] = useState(20);
 | 
					  const [pageSize, setPageSize] = useState(20);
 | 
				
			||||||
  const [tableScrollHeight, setTableScrollHeight] = useState<number>();
 | 
					  const [tableScrollHeight, setTableScrollHeight] = useState<number>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const goToScriptManager = (record: any) => {
 | 
				
			||||||
 | 
					    const cmd = record.command.split(' ');
 | 
				
			||||||
 | 
					    if (cmd[0] === 'task') {
 | 
				
			||||||
 | 
					      let [p, s] = cmd[1].split('/');
 | 
				
			||||||
 | 
					      if (!s) {
 | 
				
			||||||
 | 
					        s = p;
 | 
				
			||||||
 | 
					        p = '';
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      history.push(`/script?p=${p}&s=${s}`);
 | 
				
			||||||
 | 
					    } else if (cmd[1] === 'repo') {
 | 
				
			||||||
 | 
					      location.href = cmd[2];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const getCrons = () => {
 | 
					  const getCrons = () => {
 | 
				
			||||||
    setLoading(true);
 | 
					    setLoading(true);
 | 
				
			||||||
    request
 | 
					    request
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,6 +31,8 @@ import {
 | 
				
			||||||
  UserOutlined,
 | 
					  UserOutlined,
 | 
				
			||||||
} from '@ant-design/icons';
 | 
					} from '@ant-design/icons';
 | 
				
			||||||
import EditScriptNameModal from './editNameModal';
 | 
					import EditScriptNameModal from './editNameModal';
 | 
				
			||||||
 | 
					import debounce from 'lodash/debounce';
 | 
				
			||||||
 | 
					import { history } from 'umi';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { Text } = Typography;
 | 
					const { Text } = Typography;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,7 +97,10 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
 | 
				
			||||||
        setData(data.data);
 | 
					        setData(data.data);
 | 
				
			||||||
        setFilterData(data.data);
 | 
					        setFilterData(data.data);
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
      .finally(() => setLoading(false));
 | 
					      .finally(() => {
 | 
				
			||||||
 | 
					        setLoading(false);
 | 
				
			||||||
 | 
					        initGetScript();
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const getDetail = (node: any) => {
 | 
					  const getDetail = (node: any) => {
 | 
				
			||||||
| 
						 | 
					@ -106,6 +111,22 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const initGetScript = () => {
 | 
				
			||||||
 | 
					    const { p, s } = history.location.query as any;
 | 
				
			||||||
 | 
					    if (s) {
 | 
				
			||||||
 | 
					      const obj = {
 | 
				
			||||||
 | 
					        node: {
 | 
				
			||||||
 | 
					          title: s,
 | 
				
			||||||
 | 
					          value: s,
 | 
				
			||||||
 | 
					          key: p ? `${p}-${s}` : s,
 | 
				
			||||||
 | 
					          parent: p,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
 | 
					      setExpandedKeys([p]);
 | 
				
			||||||
 | 
					      onTreeSelect([`${p}-${s}`], obj);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const onSelect = (value: any, node: any) => {
 | 
					  const onSelect = (value: any, node: any) => {
 | 
				
			||||||
    if (node.key === select || !value) {
 | 
					    if (node.key === select || !value) {
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
| 
						 | 
					@ -119,6 +140,10 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
 | 
				
			||||||
    getDetail(node);
 | 
					    getDetail(node);
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const onExpand = (expKeys: any) => {
 | 
				
			||||||
 | 
					    setExpandedKeys(expKeys);
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const onTreeSelect = useCallback(
 | 
					  const onTreeSelect = useCallback(
 | 
				
			||||||
    (keys: Key[], e: any) => {
 | 
					    (keys: Key[], e: any) => {
 | 
				
			||||||
      const content = editorRef.current
 | 
					      const content = editorRef.current
 | 
				
			||||||
| 
						 | 
					@ -147,6 +172,13 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
 | 
				
			||||||
  const onSearch = useCallback(
 | 
					  const onSearch = useCallback(
 | 
				
			||||||
    (e) => {
 | 
					    (e) => {
 | 
				
			||||||
      const keyword = e.target.value;
 | 
					      const keyword = e.target.value;
 | 
				
			||||||
 | 
					      debounceSearch(keyword);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    [data, setFilterData],
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const debounceSearch = useCallback(
 | 
				
			||||||
 | 
					    debounce((keyword) => {
 | 
				
			||||||
      setSearchValue(keyword);
 | 
					      setSearchValue(keyword);
 | 
				
			||||||
      const { tree, expandedKeys } = getFilterData(
 | 
					      const { tree, expandedKeys } = getFilterData(
 | 
				
			||||||
        keyword.toLocaleLowerCase(),
 | 
					        keyword.toLocaleLowerCase(),
 | 
				
			||||||
| 
						 | 
					@ -154,7 +186,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      setExpandedKeys(expandedKeys);
 | 
					      setExpandedKeys(expandedKeys);
 | 
				
			||||||
      setFilterData(tree);
 | 
					      setFilterData(tree);
 | 
				
			||||||
    },
 | 
					    }, 300),
 | 
				
			||||||
    [data, setFilterData],
 | 
					    [data, setFilterData],
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -451,6 +483,8 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
 | 
				
			||||||
                  showIcon={true}
 | 
					                  showIcon={true}
 | 
				
			||||||
                  height={height}
 | 
					                  height={height}
 | 
				
			||||||
                  selectedKeys={[select]}
 | 
					                  selectedKeys={[select]}
 | 
				
			||||||
 | 
					                  expandedKeys={expandedKeys}
 | 
				
			||||||
 | 
					                  onExpand={onExpand}
 | 
				
			||||||
                  showLine={{ showLeafIcon: true }}
 | 
					                  showLine={{ showLeafIcon: true }}
 | 
				
			||||||
                  onSelect={onTreeSelect}
 | 
					                  onSelect={onTreeSelect}
 | 
				
			||||||
                ></Tree>
 | 
					                ></Tree>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user