Skip to content

Commit 0d70da6

Browse files
committed
fix: 修复编译错误和lint错误,优化微信二维码图片路径
1 parent 00507a5 commit 0d70da6

29 files changed

+1640
-1273
lines changed

.github/workflows/deploy.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
cache: 'npm'
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Build
35+
run: npm run build
36+
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v4
39+
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
path: './dist'
44+
45+
deploy:
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
runs-on: ubuntu-latest
50+
needs: build
51+
steps:
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v4

public/wechat-qr.png

328 KB
Loading

src/App.css

Lines changed: 33 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/* Global styles */
22
:root {
3-
--primary-color: #4682b4;
4-
--secondary-color: #2c3e50;
5-
--success-color: #28a745;
6-
--danger-color: #dc3545;
3+
--primary-color: #2196F3;
4+
--primary-dark: #1976D2;
5+
--success-color: #4CAF50;
6+
--danger-color: #F44336;
7+
--warning-color: #FF9800;
78
--light-color: #f8f9fa;
8-
--dark-color: #343a40;
9-
--border-color: #ddd;
10-
--header-height: 0px;
11-
--content-height: 100vh;
9+
--dark-color: #333;
10+
--border-color: #e0e0e0;
1211
}
1312

1413
* {
@@ -36,109 +35,53 @@ body {
3635
}
3736

3837
.app {
39-
min-height: 100vh;
40-
display: flex;
41-
flex-direction: column;
42-
}
43-
44-
.app-header {
45-
background: linear-gradient(135deg, #2196F3, #1976D2);
46-
color: white;
47-
padding: 20px;
48-
text-align: center;
49-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
50-
}
51-
52-
.app-header h1 {
53-
margin: 0;
54-
font-size: 2rem;
55-
font-weight: 700;
56-
}
57-
58-
.subtitle {
59-
margin: 10px 0 0;
60-
font-size: 1rem;
61-
opacity: 0.9;
62-
}
63-
64-
.app-main {
65-
flex: 1;
66-
padding: 20px;
67-
max-width: 1200px;
68-
margin: 0 auto;
69-
width: 100%;
70-
box-sizing: border-box;
71-
}
72-
73-
.app-footer {
74-
background-color: #f0f0f0;
75-
text-align: center;
76-
padding: 15px;
77-
color: #555;
78-
font-size: 0.85rem;
79-
border-top: 1px solid #ddd;
38+
height: 100vh;
39+
width: 100vw;
40+
overflow: hidden;
8041
}
8142

82-
/* Button styles */
43+
/* Button base styles */
8344
button {
8445
cursor: pointer;
8546
outline: none;
47+
font-family: inherit;
8648
}
8749

8850
button:focus {
8951
outline: none;
9052
}
9153

92-
/* 移除不需要的样式 */
93-
#root {
94-
width: 100%;
95-
margin: 0;
96-
padding: 0;
54+
/* Scrollbar styles */
55+
::-webkit-scrollbar {
56+
width: 8px;
57+
height: 8px;
9758
}
9859

99-
/* 响应式调整 */
100-
@media (max-width: 768px) {
101-
.app-header h1 {
102-
font-size: 1.5rem;
103-
}
104-
105-
.app-main {
106-
padding: 15px;
107-
}
60+
::-webkit-scrollbar-track {
61+
background: #f1f1f1;
62+
border-radius: 4px;
10863
}
10964

110-
.logo {
111-
height: 6em;
112-
padding: 1.5em;
113-
will-change: filter;
114-
transition: filter 300ms;
115-
}
116-
.logo:hover {
117-
filter: drop-shadow(0 0 2em #646cffaa);
118-
}
119-
.logo.react:hover {
120-
filter: drop-shadow(0 0 2em #61dafbaa);
65+
::-webkit-scrollbar-thumb {
66+
background: #c1c1c1;
67+
border-radius: 4px;
12168
}
12269

123-
@keyframes logo-spin {
124-
from {
125-
transform: rotate(0deg);
126-
}
127-
to {
128-
transform: rotate(360deg);
129-
}
70+
::-webkit-scrollbar-thumb:hover {
71+
background: #a8a8a8;
13072
}
13173

132-
@media (prefers-reduced-motion: no-preference) {
133-
a:nth-of-type(2) .logo {
134-
animation: logo-spin infinite 20s linear;
135-
}
74+
/* Selection styles */
75+
::selection {
76+
background: rgba(33, 150, 243, 0.3);
13677
}
13778

138-
.card {
139-
padding: 2em;
79+
/* Link styles */
80+
a {
81+
color: var(--primary-color);
82+
text-decoration: none;
14083
}
14184

142-
.read-the-docs {
143-
color: #888;
85+
a:hover {
86+
text-decoration: underline;
14487
}

src/App.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ import './App.css';
55
const App: React.FC = () => {
66
return (
77
<div className="app">
8-
<header className="app-header">
9-
<h1>对称二叉树可视化</h1>
10-
<p className="subtitle">通过直观的动画和解释理解二叉树对称性判断算法</p>
11-
</header>
12-
<main className="app-main">
13-
<SymmetricTree />
14-
</main>
15-
<footer className="app-footer">
16-
<p>基于React和D3实现的算法可视化项目 | 2024</p>
17-
</footer>
8+
<SymmetricTree />
189
</div>
1910
);
2011
};

src/components/tree/AlgorithmController.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useState, useEffect } from 'react';
22
import { TreeNode } from '../../models/TreeNode';
3-
import { isMirror } from '../../utils/TreeUtils';
43
import './AlgorithmController.css';
54

65
interface AlgorithmStep {
@@ -79,7 +78,7 @@ const AlgorithmController: React.FC<AlgorithmControllerProps> = ({
7978
const steps: AlgorithmStep[] = [];
8079

8180
// 查找节点ID的辅助函数
82-
const findNodeId = (node: TreeNode | null, isLeft: boolean): string | null => {
81+
const findNodeId = (node: TreeNode | null): string | null => {
8382
if (!node) return null;
8483

8584
// 遍历映射查找匹配的节点
@@ -96,8 +95,8 @@ const AlgorithmController: React.FC<AlgorithmControllerProps> = ({
9695
const collectSteps = (left: TreeNode | null, right: TreeNode | null, level: number = 0): boolean => {
9796
// 两个节点都为空,对称
9897
if (!left && !right) {
99-
const leftId = findNodeId(left, true);
100-
const rightId = findNodeId(right, false);
98+
const leftId = findNodeId(left);
99+
const rightId = findNodeId(right);
101100
steps.push({
102101
leftNodeId: leftId,
103102
rightNodeId: rightId,
@@ -110,8 +109,8 @@ const AlgorithmController: React.FC<AlgorithmControllerProps> = ({
110109

111110
// 一个节点为空,另一个不为空,不对称
112111
if (!left || !right) {
113-
const leftId = findNodeId(left, true);
114-
const rightId = findNodeId(right, false);
112+
const leftId = findNodeId(left);
113+
const rightId = findNodeId(right);
115114
steps.push({
116115
leftNodeId: leftId,
117116
rightNodeId: rightId,
@@ -123,8 +122,8 @@ const AlgorithmController: React.FC<AlgorithmControllerProps> = ({
123122
}
124123

125124
// 找到节点的ID
126-
const leftId = findNodeId(left, true);
127-
const rightId = findNodeId(right, false);
125+
const leftId = findNodeId(left);
126+
const rightId = findNodeId(right);
128127

129128
// 节点值不相等,不对称
130129
if (left.val !== right.val) {

0 commit comments

Comments
 (0)