Skip to content

Commit 67ec2d4

Browse files
perf: scroll to top listener
1 parent 9146332 commit 67ec2d4

5 files changed

Lines changed: 238 additions & 25 deletions

File tree

.gitattributes

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
## GITATTRIBUTES FOR WEB PROJECTS
2+
#
3+
# These settings are for any web project.
4+
#
5+
# Details per file setting:
6+
# text These files should be normalized (i.e. convert CRLF to LF).
7+
# binary These files are binary and should be left untouched.
8+
#
9+
# Note that binary is a macro for -text -diff.
10+
######################################################################
11+
12+
# Auto detect
13+
## Handle line endings automatically for files detected as
14+
## text and leave all files detected as binary untouched.
15+
## This will handle all files NOT defined below.
16+
* text=auto
17+
18+
# Source code
19+
*.bash text eol=lf
20+
*.bat text eol=crlf
21+
*.cmd text eol=crlf
22+
*.coffee text
23+
*.css text diff=css
24+
*.htm text diff=html
25+
*.html text diff=html
26+
*.inc text
27+
*.ini text
28+
*.js text
29+
*.mjs text
30+
*.cjs text
31+
*.json text
32+
*.jsx text
33+
*.less text
34+
*.ls text
35+
*.map text -diff
36+
*.od text
37+
*.onlydata text
38+
*.php text diff=php
39+
*.pl text
40+
*.ps1 text eol=crlf
41+
*.py text diff=python
42+
*.rb text diff=ruby
43+
*.sass text
44+
*.scm text
45+
*.scss text diff=css
46+
*.sh text eol=lf
47+
.husky/* text eol=lf
48+
*.sql text
49+
*.styl text
50+
*.tag text
51+
*.ts text
52+
*.tsx text
53+
*.xml text
54+
*.xhtml text diff=html
55+
56+
# Docker
57+
Dockerfile text
58+
59+
# Documentation
60+
*.ipynb text eol=lf
61+
*.markdown text diff=markdown
62+
*.md text diff=markdown
63+
*.mdwn text diff=markdown
64+
*.mdown text diff=markdown
65+
*.mkd text diff=markdown
66+
*.mkdn text diff=markdown
67+
*.mdtxt text
68+
*.mdtext text
69+
*.txt text
70+
AUTHORS text
71+
CHANGELOG text
72+
CHANGES text
73+
CONTRIBUTING text
74+
COPYING text
75+
copyright text
76+
*COPYRIGHT* text
77+
INSTALL text
78+
license text
79+
LICENSE text
80+
NEWS text
81+
readme text
82+
*README* text
83+
TODO text
84+
85+
# Templates
86+
*.dot text
87+
*.ejs text
88+
*.erb text
89+
*.haml text
90+
*.handlebars text
91+
*.hbs text
92+
*.hbt text
93+
*.jade text
94+
*.latte text
95+
*.mustache text
96+
*.njk text
97+
*.phtml text
98+
*.svelte text
99+
*.tmpl text
100+
*.tpl text
101+
*.twig text
102+
*.vue text
103+
104+
# Configs
105+
*.cnf text
106+
*.conf text
107+
*.config text
108+
.editorconfig text
109+
*.env text
110+
.gitattributes text
111+
.gitconfig text
112+
.htaccess text
113+
*.lock text -diff
114+
package.json text eol=lf
115+
package-lock.json text eol=lf -diff
116+
pnpm-lock.yaml text eol=lf -diff
117+
.prettierrc text
118+
yarn.lock text -diff
119+
*.toml text
120+
*.yaml text
121+
*.yml text
122+
browserslist text
123+
Makefile text
124+
makefile text
125+
# Fixes syntax highlighting on GitHub to allow comments
126+
tsconfig.json linguist-language=JSON-with-Comments
127+
128+
# Heroku
129+
Procfile text
130+
131+
# Graphics
132+
*.ai binary
133+
*.bmp binary
134+
*.eps binary
135+
*.gif binary
136+
*.gifv binary
137+
*.ico binary
138+
*.jng binary
139+
*.jp2 binary
140+
*.jpg binary
141+
*.jpeg binary
142+
*.jpx binary
143+
*.jxr binary
144+
*.pdf binary
145+
*.png binary
146+
*.psb binary
147+
*.psd binary
148+
# SVG treated as an asset (binary) by default.
149+
*.svg text
150+
# If you want to treat it as binary,
151+
# use the following line instead.
152+
# *.svg binary
153+
*.svgz binary
154+
*.tif binary
155+
*.tiff binary
156+
*.wbmp binary
157+
*.webp binary
158+
159+
# Audio
160+
*.kar binary
161+
*.m4a binary
162+
*.mid binary
163+
*.midi binary
164+
*.mp3 binary
165+
*.ogg binary
166+
*.ra binary
167+
168+
# Video
169+
*.3gpp binary
170+
*.3gp binary
171+
*.as binary
172+
*.asf binary
173+
*.asx binary
174+
*.avi binary
175+
*.fla binary
176+
*.flv binary
177+
*.m4v binary
178+
*.mng binary
179+
*.mov binary
180+
*.mp4 binary
181+
*.mpeg binary
182+
*.mpg binary
183+
*.ogv binary
184+
*.swc binary
185+
*.swf binary
186+
*.webm binary
187+
188+
# Archives
189+
*.7z binary
190+
*.gz binary
191+
*.jar binary
192+
*.rar binary
193+
*.tar binary
194+
*.zip binary
195+
196+
# Fonts
197+
*.ttf binary
198+
*.eot binary
199+
*.otf binary
200+
*.woff binary
201+
*.woff2 binary
202+
203+
# Executables
204+
*.exe binary
205+
*.pyc binary
206+
# Prevents massive diffs caused by vendored, minified files
207+
**/.yarn/releases/** binary
208+
**/.yarn/plugins/** binary
209+
210+
# RC files (like .babelrc or .eslintrc)
211+
*.*rc text
212+
213+
# Ignore files (like .npmignore or .gitignore)
214+
*.*ignore text
215+
216+
# Prevents massive diffs from built files
217+
dist/** binary

README.md

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,6 @@ MajdataNet v2. 你可以在 [Branch Legacy](https://github.com/TeamMajdata/Majda
1616
- Framer Motion (动画)
1717
- i18n (国际化支持)
1818

19-
## 主要功能
20-
21-
### 核心功能
22-
- 谱面上传与管理
23-
- 谱面浏览与下载
24-
- 谱面评论与互动
25-
- 用户注册与登录
26-
- 个人空间管理
27-
28-
### 社区功能
29-
- 活动系统与活动标签
30-
- 排行榜系统
31-
- MMFC (Full Combo) 排行榜
32-
- 用户排行榜
33-
- 谱面互动计数
34-
35-
### 其他功能
36-
- 小游戏集成
37-
- 多语言支持 (中文、英文、日文、韩文)
38-
- PWA支持
39-
- 响应式设计
40-
4119
## 快速开始
4220

4321
### 环境要求
@@ -57,7 +35,7 @@ pnpm install
5735
pnpm dev
5836
```
5937

60-
访问 http://localhost:5173 查看应用。
38+
访问 <http://localhost:3000> 查看应用。
6139

6240
### 构建生产版本
6341

@@ -179,7 +157,9 @@ API相关配置位于 `src/config/` 目录:
179157

180158
## 许可证
181159

182-
本项目仅供学习交流使用。
160+
[GNU](./LICENSE)
161+
162+
gitattributes file is from [gitattributes/gitattributes](https://github.com/gitattributes/gitattributes/blob/master/Web.gitattributes)
183163

184164
## 联系方式
185165

src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
22
import { HelmetProvider } from 'react-helmet-async';
33
import { I18nProvider } from './contexts/I18nContext';
44
import { UserProvider } from '@/contexts/UserContext';
5-
import { TooltipProvider, ProtectedRoute } from '@/components';
5+
import { TooltipProvider, ProtectedRoute, ScrollToTopListener } from '@/components';
66
import HomePage from './pages/HomePage';
77
import ForginsterPage from './pages/ForginsterPage';
88
import EditPage from './pages/EditPage';
@@ -32,6 +32,7 @@ function App() {
3232
<I18nProvider>
3333
<UserProvider>
3434
<Router>
35+
<ScrollToTopListener />
3536
<Routes>
3637
<Route path="/" element={<HomePage />} />
3738
<Route path="/login" element={<ForginsterPage />} />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { useEffect } from 'react';
2+
import { useLocation } from 'react-router-dom';
3+
import { scrollToTop } from '@/utils/scrollUtils';
4+
5+
export default function ScrollToTopListener() {
6+
const { pathname } = useLocation();
7+
8+
useEffect(() => {
9+
scrollToTop();
10+
}, [pathname]);
11+
12+
return null;
13+
}

src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ export { default as CollectionModal } from './collection/CollectionModal';
5252

5353
// 路由守卫
5454
export { default as ProtectedRoute } from './ProtectedRoute';
55+
56+
export { default as ScrollToTopListener } from './ScrollToTopListener';

0 commit comments

Comments
 (0)