Skip to content

Commit 2ae4809

Browse files
authored
Merge pull request #34 from rennzhang/feat-lang
2 parents 324d1a2 + 81fb74e commit 2ae4809

File tree

10 files changed

+453
-218
lines changed

10 files changed

+453
-218
lines changed

‎src/App.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, Suspense } from "react";
1+
import React, { useState, Suspense, useEffect } from "react";
22
import { Button, Table, Empty, Tabs, Image } from "antd";
33

44
import "highlight.js/styles/github.css";
@@ -109,8 +109,8 @@ function App() {
109109
// setHasSolution(!!problems[problemId]);
110110
// }, 1000);
111111

112-
// 开发环境不需要依赖 chrome 插件 query 函数
113-
const [langReady, setLangReady] = useState(isDev);
112+
// 开发环境和直接进入网站的方式不需要依赖 chrome 插件 query 函数
113+
const [langReady, setLangReady] = useState(isDev||!isInExtension());
114114
const [problemId, setProblemId] = useState("");
115115

116116
const [hasSolution, setHasSolution] = useState(false);
@@ -243,7 +243,7 @@ function App() {
243243
<Button
244244
type="link"
245245
target="_blank"
246-
href="https://leetcode-pp.github.io/leetcode-cheat/?tab=data-structure-vis"
246+
href={`https://leetcode-pp.github.io/leetcode-cheat/?tab=data-structure-vis&lang=${lang}`}
247247
>
248248
{t("Locale.app.goToTheWebsiteToUse")}
249249
</Button>

‎src/codeTemplates/codeTemplate.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function CodeTemplate({ templates }) {
2828

2929
return (
3030
<div>
31-
<Tabs activeKey={tab}>
31+
<Tabs activeKey={tab} onChange={setTab}>
3232
{tempaltesState.map((tempalte) => (
3333
<TabPane
3434
tab={
@@ -74,7 +74,7 @@ export default function CodeTemplate({ templates }) {
7474
size="small"
7575
style={{ marginLeft: "10px" }}
7676
>
77-
{t("Locale.app.toWriteSilently")}
77+
{t("Locale.app.goForDictation")}
7878
</Button>
7979
</li>
8080
))}

‎src/codeTemplates/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import handWriting from "./hand-writing";
1111
import rotate from "./rotate";
1212
import grapth from "./grapth";
1313
import prime from "./prime";
14-
console.log(binarySearch,"123");
14+
1515
const templates = [
1616
preSum,
1717
grapth,

‎src/complexityRating/index.jsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import { Button, Table } from "antd";
3-
3+
import { t } from "../locales";
44
import "./index.less";
55

66
// | 数据规模 | 算法可接受时间复杂度 |
@@ -15,17 +15,19 @@ import "./index.less";
1515
// | <=10^14 | $O(\sqrt{n})$ |
1616
// | - | $O(logn)$ |
1717

18-
const columns = [
18+
const getColumns = () => [
1919
{
2020
key: "size",
2121
dataIndex: "size",
22-
title: "数据规模",
22+
// title: "数据规模",
23+
title: t("Locale.complexityQuickCheck.dataScale"),
2324
align: "center",
2425
},
2526
{
2627
key: "complexity",
2728
dataIndex: "complexity",
28-
title: "算法可接受时间复杂度",
29+
// title: "算法可接受时间复杂度",
30+
title: t("Locale.complexityQuickCheck.timeComplexity"),
2931
align: "center",
3032
render: (t) => {
3133
if (t === "O(sqrt(n))")
@@ -82,10 +84,11 @@ export default function ComplexityRating() {
8284
href="https://lucifer.ren/blog/2020/12/21/shuati-silu3/"
8385
target="_blank"
8486
>
85-
不懂为什么?点这里
87+
{/* 不懂为什么?点这里 */}
88+
{t("Locale.complexityQuickCheck.tips")}
8689
</Button>
8790

88-
<Table columns={columns} dataSource={data} />
91+
<Table columns={getColumns()} dataSource={data} />
8992
</div>
9093
);
9194
}

‎src/dataStructureVis/data.js

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
import treeLevel2 from "../db/dataStructureVis/tree-level-2";
2+
import treeLevel3 from "../db/dataStructureVis/tree-level-3";
3+
import treeLevel4 from "../db/dataStructureVis/tree-level-4";
4+
import trigeminal from "../db/dataStructureVis/trigeminal";
5+
import graph1 from "../db/dataStructureVis/graph-1";
6+
import recurTree1 from "../db/dataStructureVis/recur-tree-1.js";
7+
import array1 from "../db/dataStructureVis/array-1.js";
8+
import board1 from "../db/dataStructureVis/board-1.js";
9+
import official from "../db/dataStructureVis/leetcode-official";
10+
import calm from "../db/dataStructureVis/calm";
11+
12+
export const initialDataSource = {
13+
presets: [
14+
{
15+
title: "力扣官方",
16+
data: official,
17+
desc: "力扣官方题解主题(持续更新)",
18+
type: "leetcode-official",
19+
typeName: "力扣官方",
20+
},
21+
{
22+
title: "calm",
23+
data: calm,
24+
desc: "稳重色系(目前只完成了树,后续更新其他数据结构)",
25+
type: "theme",
26+
typeName: "色系",
27+
},
28+
{
29+
title: "二层二叉树",
30+
data: treeLevel2,
31+
desc: "",
32+
cover: "",
33+
type: "tree",
34+
typeName: "树",
35+
},
36+
{
37+
title: "三层二叉树",
38+
data: treeLevel3,
39+
desc: "",
40+
cover: "",
41+
type: "tree",
42+
typeName: "树",
43+
},
44+
{
45+
title: "四层二叉树",
46+
data: treeLevel4,
47+
desc: "",
48+
cover: "",
49+
type: "tree",
50+
typeName: "树",
51+
},
52+
{
53+
title: "三叉树",
54+
data: trigeminal,
55+
desc: "",
56+
cover: "",
57+
type: "tree",
58+
typeName: "树",
59+
},
60+
{
61+
title: "递归树",
62+
data: recurTree1,
63+
desc: "",
64+
cover: "",
65+
type: "tree",
66+
typeName: "树",
67+
},
68+
{
69+
title: "简单数组",
70+
data: array1,
71+
desc: "",
72+
cover: "",
73+
type: "array",
74+
typeName: "数组",
75+
},
76+
{
77+
title: "简单二维矩阵",
78+
data: board1,
79+
desc: "",
80+
cover: "",
81+
type: "board",
82+
typeName: "二维矩阵(或邻接矩阵)",
83+
},
84+
{
85+
title: "简单图",
86+
data: graph1,
87+
desc: "",
88+
cover: "",
89+
type: "graph",
90+
typeName: "图",
91+
},
92+
],
93+
custom: [],
94+
};
95+
96+
export const initialDataSourceEn = {
97+
presets: [
98+
{
99+
title: "LeetCode Official",
100+
data: official,
101+
desc: "Official LeetCode solution topics (continuously updated)",
102+
type: "leetcode-official",
103+
typeName: "LeetCode Official",
104+
},
105+
{
106+
title: "Calm",
107+
data: calm,
108+
desc: "Serene color scheme (currently only completed for trees, more data structures to be updated)",
109+
type: "theme",
110+
typeName: "Color Scheme",
111+
},
112+
{
113+
title: "Binary Tree - Level 2",
114+
data: treeLevel2,
115+
desc: "",
116+
cover: "",
117+
type: "tree",
118+
typeName: "Tree",
119+
},
120+
{
121+
title: "Binary Tree - Level 3",
122+
data: treeLevel3,
123+
desc: "",
124+
cover: "",
125+
type: "tree",
126+
typeName: "Tree",
127+
},
128+
{
129+
title: "Binary Tree - Level 4",
130+
data: treeLevel4,
131+
desc: "",
132+
cover: "",
133+
type: "tree",
134+
typeName: "Tree",
135+
},
136+
{
137+
title: "Ternary Tree",
138+
data: trigeminal,
139+
desc: "",
140+
cover: "",
141+
type: "tree",
142+
typeName: "Tree",
143+
},
144+
{
145+
title: "Recursive Tree",
146+
data: recurTree1,
147+
desc: "",
148+
cover: "",
149+
type: "tree",
150+
typeName: "Tree",
151+
},
152+
{
153+
title: "Simple Array",
154+
data: array1,
155+
desc: "",
156+
cover: "",
157+
type: "array",
158+
typeName: "Array",
159+
},
160+
{
161+
title: "Simple 2D Matrix",
162+
data: board1,
163+
desc: "",
164+
cover: "",
165+
type: "board",
166+
typeName: "2D Matrix (or Adjacency Matrix)",
167+
},
168+
{
169+
title: "Simple Graph",
170+
data: graph1,
171+
desc: "",
172+
cover: "",
173+
type: "graph",
174+
typeName: "Graph",
175+
},
176+
],
177+
custom: [],
178+
};

0 commit comments

Comments
 (0)