Skip to content

Commit

Permalink
Merge pull request #34 from rennzhang/feat-lang
Browse files Browse the repository at this point in the history
  • Loading branch information
azl397985856 authored Nov 8, 2023
2 parents 324d1a2 + 81fb74e commit 2ae4809
Show file tree
Hide file tree
Showing 10 changed files with 453 additions and 218 deletions.
8 changes: 4 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, Suspense } from "react";
import React, { useState, Suspense, useEffect } from "react";
import { Button, Table, Empty, Tabs, Image } from "antd";

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

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

const [hasSolution, setHasSolution] = useState(false);
Expand Down Expand Up @@ -243,7 +243,7 @@ function App() {
<Button
type="link"
target="_blank"
href="https://leetcode-pp.github.io/leetcode-cheat/?tab=data-structure-vis"
href={`https://leetcode-pp.github.io/leetcode-cheat/?tab=data-structure-vis&lang=${lang}`}
>
{t("Locale.app.goToTheWebsiteToUse")}
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/codeTemplates/codeTemplate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function CodeTemplate({ templates }) {

return (
<div>
<Tabs activeKey={tab}>
<Tabs activeKey={tab} onChange={setTab}>
{tempaltesState.map((tempalte) => (
<TabPane
tab={
Expand Down Expand Up @@ -74,7 +74,7 @@ export default function CodeTemplate({ templates }) {
size="small"
style={{ marginLeft: "10px" }}
>
{t("Locale.app.toWriteSilently")}
{t("Locale.app.goForDictation")}
</Button>
</li>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/codeTemplates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import handWriting from "./hand-writing";
import rotate from "./rotate";
import grapth from "./grapth";
import prime from "./prime";
console.log(binarySearch,"123");

const templates = [
preSum,
grapth,
Expand Down
15 changes: 9 additions & 6 deletions src/complexityRating/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Button, Table } from "antd";

import { t } from "../locales";
import "./index.less";

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

const columns = [
const getColumns = () => [
{
key: "size",
dataIndex: "size",
title: "数据规模",
// title: "数据规模",
title: t("Locale.complexityQuickCheck.dataScale"),
align: "center",
},
{
key: "complexity",
dataIndex: "complexity",
title: "算法可接受时间复杂度",
// title: "算法可接受时间复杂度",
title: t("Locale.complexityQuickCheck.timeComplexity"),
align: "center",
render: (t) => {
if (t === "O(sqrt(n))")
Expand Down Expand Up @@ -82,10 +84,11 @@ export default function ComplexityRating() {
href="https://lucifer.ren/blog/2020/12/21/shuati-silu3/"
target="_blank"
>
不懂为什么?点这里
{/* 不懂为什么?点这里 */}
{t("Locale.complexityQuickCheck.tips")}
</Button>

<Table columns={columns} dataSource={data} />
<Table columns={getColumns()} dataSource={data} />
</div>
);
}
178 changes: 178 additions & 0 deletions src/dataStructureVis/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import treeLevel2 from "../db/dataStructureVis/tree-level-2";
import treeLevel3 from "../db/dataStructureVis/tree-level-3";
import treeLevel4 from "../db/dataStructureVis/tree-level-4";
import trigeminal from "../db/dataStructureVis/trigeminal";
import graph1 from "../db/dataStructureVis/graph-1";
import recurTree1 from "../db/dataStructureVis/recur-tree-1.js";
import array1 from "../db/dataStructureVis/array-1.js";
import board1 from "../db/dataStructureVis/board-1.js";
import official from "../db/dataStructureVis/leetcode-official";
import calm from "../db/dataStructureVis/calm";

export const initialDataSource = {
presets: [
{
title: "力扣官方",
data: official,
desc: "力扣官方题解主题(持续更新)",
type: "leetcode-official",
typeName: "力扣官方",
},
{
title: "calm",
data: calm,
desc: "稳重色系(目前只完成了树,后续更新其他数据结构)",
type: "theme",
typeName: "色系",
},
{
title: "二层二叉树",
data: treeLevel2,
desc: "",
cover: "",
type: "tree",
typeName: "树",
},
{
title: "三层二叉树",
data: treeLevel3,
desc: "",
cover: "",
type: "tree",
typeName: "树",
},
{
title: "四层二叉树",
data: treeLevel4,
desc: "",
cover: "",
type: "tree",
typeName: "树",
},
{
title: "三叉树",
data: trigeminal,
desc: "",
cover: "",
type: "tree",
typeName: "树",
},
{
title: "递归树",
data: recurTree1,
desc: "",
cover: "",
type: "tree",
typeName: "树",
},
{
title: "简单数组",
data: array1,
desc: "",
cover: "",
type: "array",
typeName: "数组",
},
{
title: "简单二维矩阵",
data: board1,
desc: "",
cover: "",
type: "board",
typeName: "二维矩阵(或邻接矩阵)",
},
{
title: "简单图",
data: graph1,
desc: "",
cover: "",
type: "graph",
typeName: "图",
},
],
custom: [],
};

export const initialDataSourceEn = {
presets: [
{
title: "LeetCode Official",
data: official,
desc: "Official LeetCode solution topics (continuously updated)",
type: "leetcode-official",
typeName: "LeetCode Official",
},
{
title: "Calm",
data: calm,
desc: "Serene color scheme (currently only completed for trees, more data structures to be updated)",
type: "theme",
typeName: "Color Scheme",
},
{
title: "Binary Tree - Level 2",
data: treeLevel2,
desc: "",
cover: "",
type: "tree",
typeName: "Tree",
},
{
title: "Binary Tree - Level 3",
data: treeLevel3,
desc: "",
cover: "",
type: "tree",
typeName: "Tree",
},
{
title: "Binary Tree - Level 4",
data: treeLevel4,
desc: "",
cover: "",
type: "tree",
typeName: "Tree",
},
{
title: "Ternary Tree",
data: trigeminal,
desc: "",
cover: "",
type: "tree",
typeName: "Tree",
},
{
title: "Recursive Tree",
data: recurTree1,
desc: "",
cover: "",
type: "tree",
typeName: "Tree",
},
{
title: "Simple Array",
data: array1,
desc: "",
cover: "",
type: "array",
typeName: "Array",
},
{
title: "Simple 2D Matrix",
data: board1,
desc: "",
cover: "",
type: "board",
typeName: "2D Matrix (or Adjacency Matrix)",
},
{
title: "Simple Graph",
data: graph1,
desc: "",
cover: "",
type: "graph",
typeName: "Graph",
},
],
custom: [],
};
Loading

0 comments on commit 2ae4809

Please sign in to comment.