Skip to content

Commit 3b57155

Browse files
author
lucifer
committed
feat: 公司反向查询
1 parent 357aa3a commit 3b57155

File tree

4 files changed

+9904
-9032
lines changed

4 files changed

+9904
-9032
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"rome": "^10.0.4-beta"
1818
},
1919
"scripts": {
20-
"release": "zip leetcode-cheat.zip build/ && mv leetcode-cheat.zip ../leetcode-cheat-release/ && git commit -am 'feat: release' && git push",
20+
"release": "zip -r leetcode-cheat.zip build/ && mv leetcode-cheat.zip ../leetcode-cheat-release/ && cd ../leetcode-cheat-release && git commit -am 'feat: release' && git push",
2121
"lint": "eslint src",
2222
"start": "react-scripts start",
2323
"build": "react-scripts build",

src/App.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { Panel } = Collapse;
2121

2222
const formatCodeToMarkDown = (code, lang) => `\`\`\`${lang}\n${code}\`\`\`\n`;
2323

24-
const { problems } = db;
24+
const { problems, company } = db;
2525
const dataSource = Object.values(problems);
2626

2727
function inLeetCodeWebsite(url) {
@@ -144,15 +144,25 @@ function App() {
144144
</a>
145145
</Fragment>
146146
)}
147-
{problems[problemId].companies.map(({ name }) => (
148-
<TagOrLink
149-
key={name}
150-
text={name}
151-
link={null}
152-
color={getColor(name)}
153-
style={{ marginBottom: 6 }}
154-
/>
155-
))}
147+
<Collapse>
148+
{problems[problemId].companies.map(({ name }) => (
149+
<Panel header={name} key={name}>
150+
<ul>
151+
{company[name].map((id) => (
152+
<li>
153+
<Button
154+
type="link"
155+
href={`${LEETCODE_CN_URL}/problems/${id}`}
156+
target="_blank"
157+
>
158+
{id}
159+
</Button>
160+
</li>
161+
))}
162+
</ul>
163+
</Panel>
164+
))}
165+
</Collapse>
156166
</TabPane>
157167
<TabPane tab="题解" key="2">
158168
<Button

src/db/db.js

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
11
import { db_collection } from "./root.db";
22

3-
const tags = {
4-
dp: {
5-
id: "dp",
6-
text: "动态规划",
7-
color: "cyan",
8-
link:
9-
"https://github.com/azl397985856/leetcode/blob/master/thinkings/dynamic-programming.md",
10-
},
11-
recursion: {
12-
id: "recursion",
13-
text: "递归",
14-
color: "#f50",
15-
link: null,
16-
},
17-
queue: {
18-
id: "queue",
19-
text: "队列",
20-
color: "#108ee9",
21-
link: null,
22-
},
3+
// const tags = {
4+
// dp: {
5+
// id: "dp",
6+
// text: "动态规划",
7+
// color: "cyan",
8+
// link:
9+
// "https://github.com/azl397985856/leetcode/blob/master/thinkings/dynamic-programming.md",
10+
// },
11+
// recursion: {
12+
// id: "recursion",
13+
// text: "递归",
14+
// color: "#f50",
15+
// link: null,
16+
// },
17+
// queue: {
18+
// id: "queue",
19+
// text: "队列",
20+
// color: "#108ee9",
21+
// link: null,
22+
// },
2323

24-
stack: {
25-
id: "stack",
26-
color: "#87d068",
27-
text: "栈",
28-
link: null,
29-
},
30-
design: {
31-
id: "design",
32-
color: "#2db7f5",
33-
text: "设计题",
34-
link: null,
35-
},
36-
};
24+
// stack: {
25+
// id: "stack",
26+
// color: "#87d068",
27+
// text: "栈",
28+
// link: null,
29+
// },
30+
// design: {
31+
// id: "design",
32+
// color: "#2db7f5",
33+
// text: "设计题",
34+
// link: null,
35+
// },
36+
// };
3737

38-
const company = {
39-
alibaba: {
40-
name: "阿里巴巴",
41-
},
42-
};
38+
const company = {};
39+
40+
Object.values(db_collection).forEach((problem) => {
41+
problem.companies.forEach((c) => {
42+
if (company[c.name] === void 0) company[c.name] = [];
43+
company[c.name].push(problem.name);
44+
});
45+
});
4346

4447
export default {
4548
problems: db_collection,
46-
tags,
49+
// tags,
4750
company,
4851
};

0 commit comments

Comments
 (0)