Skip to content

Commit c680c55

Browse files
author
robot
committed
feat: 图
1 parent a7770e4 commit c680c55

File tree

5 files changed

+384
-4
lines changed

5 files changed

+384
-4
lines changed

‎src/codeTemplates/codeTemplate.jsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import {
1010
const { TabPane } = Tabs;
1111
const { Panel } = Collapse;
1212

13+
function computedURL(problem) {
14+
if (problem.id.startsWith("http://") || problem.id.startsWith("https://"))
15+
return problem.id;
16+
return `${LEETCODE_CN_URL}/problems/${problem.id}`;
17+
}
18+
1319
export default function CodeTemplate({ tempaltes }) {
1420
return (
1521
<div>
@@ -44,8 +50,8 @@ export default function CodeTemplate({ tempaltes }) {
4450
)}
4551
{tempalte.list.map(({ text, problems, codes }) => (
4652
<Collapse key={text}>
47-
<Panel header={<div>{text}</div>} key={text}>
48-
<div>
53+
<Panel header={<span>{text}</span>} key={text}>
54+
<div style={problems.length > 0 ? {} : { display: "none" }}>
4955
推荐题目:
5056
<ul>
5157
{problems.map((problem) => (
@@ -54,7 +60,7 @@ export default function CodeTemplate({ tempaltes }) {
5460
<Button
5561
onClick={(e) => e.stopPropagation()}
5662
type="link"
57-
href={`${LEETCODE_CN_URL}/problems/${problem.id}`}
63+
href={computedURL(problem)}
5864
target="_blank"
5965
size="small"
6066
style={{ marginLeft: "10px" }}

0 commit comments

Comments
 (0)