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