Skip to content

Commit 424227b

Browse files
author
lucifer
committed
feat: 0.8.12
1 parent b76733e commit 424227b

10 files changed

+598
-61
lines changed

‎babel.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};

‎leetcode-cheat-0.8.10.zip

-4.31 MB
Binary file not shown.

‎leetcode-cheat-0.8.12.zip

4.13 MB
Binary file not shown.

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"dependencies": {
99
"@ant-design/icons": "^4.2.2",
10-
"@excalidraw/excalidraw": "^0.2.0",
10+
"@excalidraw/excalidraw": "^0.4.3",
1111
"@matejmazur/react-katex": "^3.1.3",
1212
"@testing-library/jest-dom": "^4.2.4",
1313
"@testing-library/react": "^9.3.2",
@@ -16,7 +16,7 @@
1616
"react": "^17.0.1",
1717
"react-debounce-render": "^7.0.0",
1818
"react-dom": "^17.0.1",
19-
"react-markdown": "^4.3.1",
19+
"react-markdown": "^5.0.1",
2020
"react-scripts": "3.4.1",
2121
"react-syntax-highlighter": "^15.4.3",
2222
"remark-math": "^4.0.0",

‎public/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "leetcode cheatsheet",
44
"description": "刷题小助手,made by 力扣加加",
5-
"version": "0.8.10",
5+
"version": "0.8.12",
66
"browser_action": {
77
"default_popup": "index.html",
88
"default_title": "力扣加加"

‎src/App.js

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

44
import "highlight.js/styles/github.css";
@@ -21,10 +21,13 @@ import "antd/dist/antd.css";
2121
import "./App.css";
2222
import CodeTemplates from "./codeTemplates/codeTemplate";
2323
import ComplexityRating from "./complexityRating/index";
24-
import DataStrutureVis from "./dataStructureVis/index";
2524
import SolutionTemplate from "./solutionTemplate/index";
2625
// import { data as a } from "./db/binary-tree";
2726

27+
const DataStrutureVis = isInExtension()
28+
? null
29+
: React.lazy(() => import("./dataStructureVis"));
30+
2831
const { problems, selected } = db;
2932

3033
const { TabPane } = Tabs;
@@ -207,7 +210,9 @@ function App() {
207210
<CodeTemplates tempaltes={tempaltes}></CodeTemplates>
208211
</TabPane>
209212
<TabPane key="data-structure-vis" tab="数据结构可视化">
210-
<DataStrutureVis></DataStrutureVis>
213+
<Suspense fallback={<div>Loading...</div>}>
214+
<DataStrutureVis></DataStrutureVis>
215+
</Suspense>
211216
</TabPane>
212217
{!isInExtension() && (
213218
<TabPane key="solution-template" tab="题解模板">

‎src/codeTemplates/codeTemplate.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import { Button, Collapse, Tabs } from "antd";
3-
3+
import Excalidraw from "@excalidraw/excalidraw";
44
import Codes from "../components/codes";
55

66
import {

‎src/contentScript.js

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
// import React, { PureComponent } from "react";
2-
// import ReactDOM from "react-dom";
3-
import { message } from "antd";
41
// import "./content.css";
5-
import {
6-
copyToClipboard,
7-
不讲武德,
8-
getStorage,
9-
setCloundStorage,
10-
} from "./utils";
2+
// import { message } from "antd";
3+
import { copyToClipboard, bjwd, getStorage, setCloundStorage } from "./utils";
114
import zenAble from "./zen/zenMode";
125

6+
// WTF! ant message didn't go well with chrome extension?
7+
const message = {
8+
success({ content }) {
9+
//
10+
},
11+
warn({ content }) {
12+
window.alert(content);
13+
},
14+
loading(content) {
15+
//
16+
return () => null;
17+
},
18+
};
19+
1320
// import AccessToken from "./components/AccessToken";
1421

1522
// class SolutionButton extends PureComponent {
@@ -154,7 +161,7 @@ function getProviedTestCases() {
154161
if (pres[i].innerText.includes(prefix)) {
155162
const testcase = extractTestCase(pres[i].innerText, prefix);
156163
if (!testcase || testcase.length <= 1) {
157-
不讲武德();
164+
bjwd();
158165
return [];
159166
}
160167
ans.push(normalize(testcase[1]));
@@ -175,7 +182,7 @@ function insertButton() {
175182
copyButton.style["margin-left"] = "10px";
176183
copyButton.onclick = () => {
177184
const cases = getProviedTestCases();
178-
if (cases.filter(Boolean).length === 0) return 不讲武德();
185+
if (cases.filter(Boolean).length === 0) return bjwd();
179186
copyToClipboard(cases.join("\n"));
180187
message.success({
181188
content: "复制成功~",
@@ -282,14 +289,21 @@ function insertButton() {
282289
return false;
283290
}
284291
let inserted = false;
292+
let retried = 0;
293+
const MAX_TRY = 10;
285294
const timerId = setInterval(() => {
286295
if (inserted) return clearInterval(timerId);
296+
if (retried > MAX_TRY) {
297+
clearInterval(timerId);
298+
return console.error("初始化 chrome 插件 content script 失败");
299+
}
287300
if (insertButton()) {
288301
window.location.title = "";
289302
inserted = true;
290303
// 可进入禅定模式
291304
zenAble();
292305
}
306+
retried++;
293307
}, 1000);
294308

295309
// class Main extends React.Component {

‎src/db/root.db.js

+551-31
Large diffs are not rendered by default.

‎src/utils.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from "react";
2-
import { Button, message } from "antd";
31
import { ISSUES_URL } from "./constant/index";
42

53
function TreeNode(value) {
@@ -9,6 +7,11 @@ function TreeNode(value) {
97
value,
108
};
119
}
10+
const message = {
11+
error({ content }) {
12+
window.alert(content);
13+
},
14+
};
1215
const seen = {};
1316
export function getRandomUnique(lower, upper, amount) {
1417
console.log(seen);
@@ -98,17 +101,11 @@ export function buildRandomTree({
98101
return dfs({ upper, lower });
99102
}
100103

101-
export function 不讲武德() {
104+
export function bjwd() {
102105
return message.error({
103-
content: (
104-
<>
105-
力扣不讲武德,不按套路出牌。不过没关系啊,你
106-
<Button type="link" href={ISSUES_URL} target="_blank">
107-
反馈
108-
</Button>
109-
给我,下次一定全部防出去!
110-
</>
111-
),
106+
content: `
107+
力扣不讲武德,不按套路出牌。不过没关系啊,你反馈给我,下次一定全部防出去!反馈到这里:${ISSUES_URL}
108+
`,
112109
});
113110
}
114111
export function getUrlParameter(key) {

0 commit comments

Comments
 (0)