mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 18:19:03 +08:00
添加 Android 打包工作流并实现响应式设计
- 在 GitHub Actions 中添加 Android 打包工作流,支持 ARM64、ARMv7 和 x86_64 架构 - 创建 CI 脚本用于解析提交信息和应用版本号 - 移除标题栏的旋转屏幕按钮,简化窗口控制 - 创建响应式设计 hooks (useResponsive) 用于检测屏幕尺寸 - 更新 StudentManager 组件以支持移动端响应式布局 - 在移动设备上自动调整表格列宽、按钮大小和字体大小 - 移动端隐藏标签列以节省空间 - 按钮在移动端使用垂直布局和更小的尺寸
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import { useState, useEffect } from "react"
|
||||
|
||||
export type Breakpoint = "xs" | "sm" | "md" | "lg" | "xl" | "xxl"
|
||||
|
||||
export interface Breakpoints {
|
||||
xs: number
|
||||
sm: number
|
||||
md: number
|
||||
lg: number
|
||||
xl: number
|
||||
xxl: number
|
||||
}
|
||||
|
||||
const defaultBreakpoints: Breakpoints = {
|
||||
xs: 480,
|
||||
sm: 576,
|
||||
md: 768,
|
||||
lg: 992,
|
||||
xl: 1200,
|
||||
xxl: 1600,
|
||||
}
|
||||
|
||||
export function useResponsive(customBreakpoints?: Partial<Breakpoints>): Breakpoint {
|
||||
const [breakpoint, setBreakpoint] = useState<Breakpoint>("lg")
|
||||
const breakpoints = { ...defaultBreakpoints, ...customBreakpoints }
|
||||
|
||||
useEffect(() => {
|
||||
const updateBreakpoint = () => {
|
||||
const width = window.innerWidth
|
||||
|
||||
if (width < breakpoints.xs) {
|
||||
setBreakpoint("xs")
|
||||
} else if (width < breakpoints.sm) {
|
||||
setBreakpoint("sm")
|
||||
} else if (width < breakpoints.md) {
|
||||
setBreakpoint("md")
|
||||
} else if (width < breakpoints.lg) {
|
||||
setBreakpoint("lg")
|
||||
} else if (width < breakpoints.xl) {
|
||||
setBreakpoint("xl")
|
||||
} else {
|
||||
setBreakpoint("xxl")
|
||||
}
|
||||
}
|
||||
|
||||
updateBreakpoint()
|
||||
window.addEventListener("resize", updateBreakpoint)
|
||||
return () => window.removeEventListener("resize", updateBreakpoint)
|
||||
}, [breakpoints])
|
||||
|
||||
return breakpoint
|
||||
}
|
||||
|
||||
export function useScreenSize() {
|
||||
const [screenSize, setScreenSize] = useState({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setScreenSize({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
})
|
||||
}
|
||||
|
||||
window.addEventListener("resize", handleResize)
|
||||
return () => window.removeEventListener("resize", handleResize)
|
||||
}, [])
|
||||
|
||||
return screenSize
|
||||
}
|
||||
|
||||
export function useIsMobile() {
|
||||
const breakpoint = useResponsive()
|
||||
return breakpoint === "xs" || breakpoint === "sm"
|
||||
}
|
||||
|
||||
export function useIsTablet() {
|
||||
const breakpoint = useResponsive()
|
||||
return breakpoint === "md"
|
||||
}
|
||||
|
||||
export function useIsDesktop() {
|
||||
const breakpoint = useResponsive()
|
||||
return breakpoint === "lg" || breakpoint === "xl" || breakpoint === "xxl"
|
||||
}
|
||||
Reference in New Issue
Block a user