Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 工具名称和规则名称统一展示 #54

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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