Skip to content

Commit f1366f4

Browse files
committed
perf: fix some bugs
1 parent a3d1235 commit f1366f4

17 files changed

+434
-1707
lines changed

.eslintrc.json

+13-17
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"plugin:react/jsx-runtime",
2323
"plugin:import/recommended",
2424
"plugin:compat/recommended",
25-
"plugin:prettier/recommended",
2625
"plugin:eslint-comments/recommended"
2726
],
2827
"parser": "@typescript-eslint/parser",
@@ -79,13 +78,24 @@
7978
"newlines-between": "ignore"
8079
}
8180
],
81+
"quotes": [
82+
"error",
83+
"single"
84+
],
85+
"quote-props": [
86+
"error",
87+
"as-needed"
88+
],
8289
"semi": [
8390
"error",
8491
"always"
8592
],
86-
"quotes": [
93+
"semi-spacing": [
8794
"error",
88-
"single"
95+
{
96+
"before": false,
97+
"after": true
98+
}
8999
],
90100
"no-trailing-spaces": "error",
91101
"@typescript-eslint/no-unused-vars": [
@@ -96,20 +106,6 @@
96106
],
97107
"max-len": ["error", { "code": 120, "ignoreComments": true }],
98108
"object-curly-spacing": ["error", "always"],
99-
"prettier/prettier": [
100-
"error",
101-
{
102-
"printWidth": 80,
103-
"tabWidth": 2,
104-
"useTabs": false,
105-
"semi": true,
106-
"singleQuote": true,
107-
"trailingComma": "all",
108-
"bracketSpacing": true,
109-
"jsxBracketSameLine": false,
110-
"arrowParens": "avoid"
111-
}
112-
],
113109
"react/jsx-indent": ["error", 2],
114110
"react/jsx-indent-props": ["error", 2],
115111
"react/jsx-tag-spacing": "error",

config/i18n.json

+4
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,9 @@
5454
"confirm_reset_code": {
5555
"en": "Are you sure to reset code?",
5656
"zh-CN": "确认重置代码?"
57+
},
58+
"no_question": {
59+
"en": "No Result",
60+
"zh-CN": "暂无数据"
5761
}
5862
}

package.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,19 @@
4848
"react-syntax-highlighter": "^15.5.0",
4949
"rehype-katex": "^6.0.3",
5050
"rehype-raw": "^7.0.0",
51+
"remark-gfm": "^3.0.1",
5152
"remark-math": "^6.0.0",
52-
"styled-components": "^6.1.0",
5353
"ts-deepmerge": "^7.0.0",
5454
"type-assertions": "^1.1.0"
5555
},
5656
"devDependencies": {
5757
"@rspack/cli": "^0.6.5",
5858
"@rspack/core": "^0.6.5",
5959
"@rspack/plugin-html": "^0.5.8",
60-
"@svgr/webpack": "^8.1.0",
6160
"@types/event-emitter": "^0.3.4",
6261
"@types/js-yaml": "^4.0.9",
6362
"@types/lodash.debounce": "^4.0.7",
6463
"@types/node": "^20.8.9",
65-
"@types/prompts": "^2.4.9",
6664
"@types/react": "^17.0.67",
6765
"@types/react-copy-to-clipboard": "^5.0.6",
6866
"@types/react-dom": "^17.0.21",
@@ -85,9 +83,7 @@
8583
"less-loader": "^11.1.3",
8684
"lint-staged": "^14.0.1",
8785
"monaco-editor": "^0.44.0",
88-
"prettier": "^3.0.3",
89-
"prompts": "^2.4.2",
90-
"ts-node": "^10.9.1",
86+
"ts-node": "^10.9.2",
9187
"typescript": "^5.2.2"
9288
},
9389
"resolutions": {

src/App.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { getQuestionList } from '@src/utils/type-challenges';
1818
import styles from './index.module.less';
1919
import './global.less';
2020

21+
function getPopupContainer() {
22+
return document.getElementById('root') || document.body;
23+
}
24+
2125
function App() {
2226
const [context, setContext] = useState(getContext());
2327

@@ -63,7 +67,11 @@ function App() {
6367

6468
return (
6569
<ConfigProvider
66-
getPopupContainer={() => document.getElementById('root') || document.body}
70+
componentConfig={{
71+
Modal: { getPopupContainer },
72+
Drawer: { getPopupContainer },
73+
}}
74+
getPopupContainer={getPopupContainer}
6775
>
6876
<Context.Provider value={contextValue}>
6977
<Layout className={styles.container}>

src/components/CustomTabs/index.module.less

+28-22
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,37 @@
22
width: 100%;
33
height: 100%;
44
border: none;
5-
:global(.arco-tabs-header-wrapper) {
6-
height: 36px;
7-
padding: 4px;
8-
box-sizing: border-box;
9-
:global(.arco-tabs-header-title) {
10-
height: 100%;
11-
padding: 8px;
5+
:global {
6+
.arco-tabs-header-wrapper {
7+
height: 36px;
8+
padding: 4px;
129
box-sizing: border-box;
13-
border: none;
14-
user-select: none;
15-
display: inline-flex;
16-
align-items: center;
17-
justify-content: center;
18-
border-radius: 4px;
19-
font-size: 16px;
10+
.arco-tabs-header-title {
11+
height: 100%;
12+
padding: 8px;
13+
box-sizing: border-box;
14+
border: none;
15+
user-select: none;
16+
display: inline-flex;
17+
align-items: center;
18+
justify-content: center;
19+
border-radius: 4px;
20+
font-size: 16px;
21+
}
22+
.arco-tabs-header-title-active {
23+
font-weight: 400;
24+
&:hover {
25+
background-color: var(--color-fill-3);
26+
}
27+
}
2028
}
21-
:global(.arco-tabs-header-title-active) {
22-
font-weight: 400;
23-
&:hover {
24-
background-color: var(--color-fill-3);
29+
.arco-tabs-content {
30+
width: 100%;
31+
padding: 0;
32+
border: none;
33+
.arco-tabs-content-inner, .arco-tabs-content-item, .arco-tabs-pane {
34+
height: 100%;
2535
}
2636
}
2737
}
28-
:global(.arco-tabs-content) {
29-
border: none;
30-
padding: 0;
31-
}
3238
}
+47-27
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,53 @@
1-
blockquote {
2-
margin: 0;
3-
padding: 8px;
4-
background-color: var(--color-neutral-2);
5-
border-left: 4px solid var(--color-neutral-3);
6-
border-radius: 4px;
7-
* {
1+
.markdown-wrapper {
2+
blockquote {
83
margin: 0;
4+
padding: 8px;
5+
background-color: var(--color-neutral-2);
6+
border-left: 4px solid var(--color-neutral-3);
7+
border-radius: 4px;
8+
* {
9+
margin: 0;
10+
}
11+
p:not(:last-child) {
12+
margin-bottom: 4px;
13+
}
914
}
10-
p:not(:last-child) {
11-
margin-bottom: 4px;
15+
p > code {
16+
margin: 0 2px;
17+
padding: 2px 4px;
18+
vertical-align: middle;
19+
font-size: 14px;
20+
line-height: 14px;
21+
background-color: var(--color-neutral-2);
1222
}
13-
}
14-
p > code {
15-
margin: 0 2px;
16-
padding: 2px 4px;
17-
vertical-align: middle;
18-
font-size: 14px;
19-
line-height: 14px;
20-
background-color: var(--color-neutral-2);
21-
}
22-
.markdown-code {
23-
font-size: 14px;
24-
:global(.react-syntax-highlighter-line-number) {
25-
min-width: 32px !important;
23+
a {
24+
color: rgb(var(--primary-6)) !important;
25+
&:hover {
26+
opacity: 0.8;
27+
}
2628
}
27-
}
28-
.markdown-wrapper a {
29-
color: rgb(var(--primary-6)) !important;
30-
&:hover {
31-
opacity: 0.8;
29+
table {
30+
width: 100%;
31+
display: block;
32+
overflow: auto;
33+
border-spacing: 0;
34+
border-collapse: collapse;
35+
th, td {
36+
padding: 6px 13px;
37+
border: 1px solid #afb8c133;
38+
code {
39+
padding: 4px;
40+
font-size: 85%;
41+
white-space: break-spaces;
42+
background-color: #afb8c133;
43+
border-radius: 4px;
44+
}
45+
}
46+
}
47+
.markdown-code {
48+
font-size: 14px;
49+
:global(.react-syntax-highlighter-line-number) {
50+
min-width: 32px !important;
51+
}
3252
}
3353
}

src/components/Markdown/index.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ReactMarkdown from 'react-markdown';
88
import remarkMath from 'remark-math';
99
import rehypeKatex from 'rehype-katex';
1010
import rehypeRaw from 'rehype-raw';
11+
import remarkGfm from 'remark-gfm';
1112
import { Setting } from '@src/utils/setting';
1213
import styles from './index.module.less';
1314
import 'katex/dist/katex.min.css';
@@ -23,20 +24,20 @@ const Markdown = function (props: {
2324
return (
2425
<ReactMarkdown
2526
className={styles['markdown-wrapper']}
26-
remarkPlugins={[remarkMath]}
27-
rehypePlugins={[rehypeRaw as any, rehypeKatex]}
27+
remarkPlugins={[remarkMath, remarkGfm]}
28+
rehypePlugins={[rehypeKatex, rehypeRaw as any]}
2829
components={{
2930
code(props) {
3031
const { children, className, inline, node, ...rest } = props;
3132
const match = /language-(typescript|ts)/.exec(className || '');
32-
return match ? (
33+
return !inline ? (
3334
<SyntaxHighlighter
3435
{...rest}
3536
node={node}
3637
inline={inline}
3738
className={styles['markdown-code']}
3839
style={theme === 'light' ? oneLight : oneDark}
39-
language={match[1]}
40+
language={match?.[1]}
4041
showLineNumbers={true}
4142
wrapLines={true}
4243
>

src/modules/Editor/index.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function Editor() {
1717
const [raw, setRaw] = useState(DEFAULT_RAW);
1818
const [loading, setLoading] = useState(true);
1919
const [{ setting, currentQuestion }] = useContext(Context);
20+
const { language } = setting;
2021

2122
function onChange(filename: QuestionFiles, content: string) {
2223
if (!raw || filename !== QuestionFiles.template) return;
@@ -43,10 +44,10 @@ function Editor() {
4344

4445
function resetCode() {
4546
const modal = Modal.confirm({
46-
title: i18nJson['confirm_title'][setting.language],
47-
content: i18nJson['confirm_reset_code'][setting.language],
48-
okText: i18nJson['confirm_btn'][setting.language],
49-
cancelText: i18nJson['cancel_btn'][setting.language],
47+
title: i18nJson['confirm_title'][language],
48+
content: i18nJson['confirm_reset_code'][language],
49+
okText: i18nJson['confirm_btn'][language],
50+
cancelText: i18nJson['cancel_btn'][language],
5051
onOk: async function () {
5152
setLoading(true);
5253
localCache.setQuestionCache(currentQuestion, {
@@ -70,9 +71,7 @@ function Editor() {
7071
<div className={styles.container}>
7172
<div className={styles.header}>
7273
<IconCode />
73-
<span style={{ marginLeft: 5 }}>
74-
{i18nJson['code'][setting.language]}
75-
</span>
74+
<span style={{ marginLeft: 5 }}>{i18nJson['code'][language]}</span>
7675
<a onClick={resetCode} className={styles.reset}>
7776
<Tooltip mini={true} content={'reset'}>
7877
<IconUndo />

0 commit comments

Comments
 (0)