Skip to content

Commit

Permalink
Merge pull request #54 from nickcdon/dev/migrate-202208311929
Browse files Browse the repository at this point in the history
🎨 工具名称和规则名称统一展示
  • Loading branch information
nickcdon authored Sep 1, 2022
2 parents dfb55ed + 89270a9 commit 5c7fd3e
Show file tree
Hide file tree
Showing 20 changed files with 737 additions and 502 deletions.
53 changes: 53 additions & 0 deletions web/packages/tca-analysis/src/components/react-highlight/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { useRef, useEffect } from 'react';
import hljs from 'highlight.js';


interface HighlightProps {
children: React.ReactNode | React.ReactNode[];
element?: React.ReactNode;
className: any;
}

const Highlight = (props: HighlightProps) => {
const ele = useRef(null);

useEffect(() => {
highlightCode();
});

const highlightCode = () => {
const nodes = ele.current.querySelectorAll('pre code');

nodes?.forEach((element: any) => {
hljs.highlightBlock(element);
});

// for (let i = 0; i < nodes.length; i++) {
// hljs.highlightBlock(nodes[i]);
// }
};

const {
children,
className,
// element: Element = null,
// innerHTML = false,
} = props;
// const eleProps = { ref: ele, className };

// if (innerHTML) {
// eleProps.dangerouslySetInnerHTML = { __html: children };

// if (Element) {
// return <Element {...eleProps} />;
// }
// return <div {...eleProps} />;
// }

// if (Element) {
// return <Element {...eleProps}>{children}</Element>;
// }
return <pre ref={ele}><code className={className}>{children}</code></pre>;
};

export default Highlight;
11 changes: 5 additions & 6 deletions web/packages/tca-analysis/src/modules/projects/issues/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,10 @@ const Issues = (props: IssuesProps) => {
/>
<Column
title="规则"
dataIndex="checkrule_display_name"
key="checkrule_display_name"
dataIndex="checkrule_real_name"
key="checkrule_real_name"
sorter
sortOrder={sort.key === 'checkrule_display_name' ? sort.order : undefined}
sortOrder={sort.key === 'checkrule_real_name' ? sort.order : undefined}
render={(name: any, item: any) => (
<Tooltip title={item.msg}>
<span>{name}</span>
Expand Down Expand Up @@ -440,11 +440,10 @@ const Issues = (props: IssuesProps) => {
</Table>
</div>
<IssueModal
curSchemeId={curScheme}
visible={issueModal.visible}
issueId={issueModal.issueId}
isFirstIssue={issueModal.isFirstIssue}
isLastIssue={issueModal.isLastIssue}
issuesData={data}
listLoading={loading}
params={[orgSid, teamName, repoId, projectId]}
prevIssue={prevIssue}
nextIssue={nextIssue}
Expand Down
Loading

0 comments on commit 5c7fd3e

Please sign in to comment.