feat: 添加 lint:fix 脚本并优化代码格式

refactor(components): 调整窗口控制图标大小和样式
style: 统一代码格式和缩进
fix(App): 修复路径比较逻辑的空格问题
This commit is contained in:
Linkon
2026-01-20 01:19:12 +08:00
parent 0fa80e419f
commit 6b41ae079a
7 changed files with 38 additions and 18 deletions
+1
View File
@@ -8,6 +8,7 @@
"scripts": {
"format": "prettier --write .",
"lint": "eslint --cache .",
"lint:fix": "eslint --cache . --fix",
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false",
"typecheck": "pnpm -s typecheck:node && pnpm -s typecheck:web",
+2 -1
View File
@@ -86,7 +86,8 @@ const api = {
return () => ipcRenderer.removeListener('app:navigate', subscription)
},
toggleDevTools: () => ipcRenderer.invoke('window:toggle-devtools'),
windowResize: (width: number, height: number) => ipcRenderer.invoke('window:resize', width, height),
windowResize: (width: number, height: number) =>
ipcRenderer.invoke('window:resize', width, height),
// Logger
queryLogs: (lines?: number) => ipcRenderer.invoke('log:query', lines),
+1 -1
View File
@@ -17,7 +17,7 @@ function MainContent(): React.JSX.Element {
// 统一路径格式进行比对,防止 / 和 /home 导致重复跳转
const currentPath = location.pathname === '/' ? '/home' : location.pathname
const targetPath = route === '/' ? '/home' : route
if (currentPath !== targetPath) {
navigate(route)
}
+13 -7
View File
@@ -3,13 +3,19 @@ import { Layout, Space, Button, Tag, Loading } from 'tdesign-react'
import { Routes, Route, Navigate } from 'react-router-dom'
import { WindowControls } from './WindowControls'
const Home = lazy(() => import('./Home').then(m => ({ default: m.Home })))
const StudentManager = lazy(() => import('./StudentManager').then(m => ({ default: m.StudentManager })))
const Settings = lazy(() => import('./Settings').then(m => ({ default: m.Settings })))
const ReasonManager = lazy(() => import('./ReasonManager').then(m => ({ default: m.ReasonManager })))
const ScoreManager = lazy(() => import('./ScoreManager').then(m => ({ default: m.ScoreManager })))
const Leaderboard = lazy(() => import('./Leaderboard').then(m => ({ default: m.Leaderboard })))
const SettlementHistory = lazy(() => import('./SettlementHistory').then(m => ({ default: m.SettlementHistory })))
const Home = lazy(() => import('./Home').then((m) => ({ default: m.Home })))
const StudentManager = lazy(() =>
import('./StudentManager').then((m) => ({ default: m.StudentManager }))
)
const Settings = lazy(() => import('./Settings').then((m) => ({ default: m.Settings })))
const ReasonManager = lazy(() =>
import('./ReasonManager').then((m) => ({ default: m.ReasonManager }))
)
const ScoreManager = lazy(() => import('./ScoreManager').then((m) => ({ default: m.ScoreManager })))
const Leaderboard = lazy(() => import('./Leaderboard').then((m) => ({ default: m.Leaderboard })))
const SettlementHistory = lazy(() =>
import('./SettlementHistory').then((m) => ({ default: m.SettlementHistory }))
)
const { Content } = Layout
+11 -7
View File
@@ -79,7 +79,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
])
if (stuRes.success) {
const enrichedStudents = (stuRes.data as student[]).map(s => ({
const enrichedStudents = (stuRes.data as student[]).map((s) => ({
...s,
pinyinName: pinyin(s.name, { toneType: 'none' }).toLowerCase(),
pinyinFirst: getFirstLetter(s.name)
@@ -120,7 +120,11 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
if (pyLower.includes(q0)) return true
const q1 = q0.replace(/\s+/g, '')
if (q1 && (nameLower.replace(/\s+/g, '').includes(q1) || pyLower.replace(/\s+/g, '').includes(q1))) return true
if (
q1 &&
(nameLower.replace(/\s+/g, '').includes(q1) || pyLower.replace(/\s+/g, '').includes(q1))
)
return true
try {
const m0 = match(s.name, q0)
@@ -167,7 +171,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
const groups: Record<string, student[]> = {}
sortedStudents.forEach((s) => {
const key = sortType === 'alphabet' ? (s.pinyinFirst || '#') : getSurname(s.name)
const key = sortType === 'alphabet' ? s.pinyinFirst || '#' : getSurname(s.name)
if (!groups[key]) groups[key] = []
groups[key].push(s)
})
@@ -312,7 +316,6 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
border: '1px solid var(--ss-border-color)',
overflow: 'visible'
}}
hover
>
{rankBadge && (
<div
@@ -382,7 +385,9 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
<div
key={group.key}
style={{ marginBottom: '32px' }}
ref={(el) => (groupRefs.current[group.key] = el)}
ref={(el) => {
groupRefs.current[group.key] = el
}}
>
{group.key !== 'all' && (
<div
@@ -391,7 +396,6 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
fontWeight: 'bold',
color: 'var(--ss-text-main)',
marginBottom: '16px',
paddingLeft: '4px',
display: 'flex',
alignItems: 'center',
gap: '8px',
@@ -889,4 +893,4 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
</Dialog>
</div>
)
}
}
+5 -1
View File
@@ -109,7 +109,11 @@ export function TitleBar({ children }: TitleBarProps): React.JSX.Element {
onClick={maximize}
style={{ width: '46px', height: '32px', borderRadius: 0 }}
>
{isMaximized ? <FullscreenExitIcon /> : <RectangleIcon />}
{isMaximized ? (
<FullscreenExitIcon style={{ transform: 'scale(0.5)' }} />
) : (
<RectangleIcon />
)}
</Button>
<Button
variant="text"
@@ -56,7 +56,11 @@ export function WindowControls(): React.JSX.Element {
onClick={maximize}
style={{ width: '46px', height: '32px', borderRadius: 0 }}
>
{isMaximized ? <FullscreenExitIcon /> : <RectangleIcon />}
{isMaximized ? (
<FullscreenExitIcon />
) : (
<RectangleIcon style={{ transform: 'scale(0.7)' }} />
)}
</Button>
<Button
variant="text"