feat(组件): 添加线性进度条组件并替换圆形进度条

重构进度指示器,使用新的LinearProgress组件替换原有的CircularProgress
更新文件管理器中的进度指示器引用
修改首页加载动画为线性进度条样式
This commit is contained in:
2025-10-26 20:23:36 +08:00
parent 59d39fbc11
commit e77b0d7978
4 changed files with 72 additions and 64 deletions

View File

@@ -46,43 +46,39 @@
transform: scale(0.8);
animation: fadeIn 0.6s ease-out 0.3s forwards;
}
#app-loader .spinner {
width: 28px;
height: 28px;
position: relative;
#app-loader .progress-container {
width: 200px;
height: 4px;
background-color: rgba(0, 0, 0, 0.1);
border-radius: 2px;
overflow: hidden;
opacity: 0;
transform: scale(0.8);
animation: fadeIn 0.6s ease-out 0.3s forwards;
}
#app-loader .spinner {
display: inline-block;
width: 40px;
height: 40px;
}
#app-loader .spinner svg {
display: block;
}
#app-loader .spinner .stroke {
stroke: var(--defaultThemeColor);
stroke-linecap: round;
animation: spinDash 1.4s ease-in-out infinite;
}
#app-loader .spinner .background {
stroke: rgba(0, 0, 0, 0.1)
#app-loader .progress-bar {
height: 100%;
background-color: var(--defaultThemeColor);
border-radius: 2px;
animation: linearProgress 1.5s infinite ease-in-out;
}
@keyframes spinDash {
@keyframes linearProgress {
0% {
stroke-dasharray: 1px, 200px;
stroke-dashoffset: 0;
transform: translateX(-100%);
width: 50%;
}
50% {
stroke-dasharray: 100px, 200px;
stroke-dashoffset: -15px;
transform: translateX(100%);
width: 50%;
}
51% {
transform: translateX(100%);
width: 50%;
}
100% {
stroke-dasharray: 1px, 200px;
stroke-dashoffset: -126px;
transform: translateX(-100%);
width: 50%;
}
}
@keyframes fadeIn {
@@ -97,11 +93,8 @@
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="app-loader">
<div class="logo"></div>
<div class="spinner">
<svg viewBox="22 22 44 44">
<circle class="background" cx="44" cy="44" r="20" fill="none" stroke-width="4"></circle>
<circle class="stroke" cx="44" cy="44" r="20" fill="none" stroke-width="4"></circle>
</svg>
<div class="progress-container">
<div class="progress-bar"></div>
</div>
</div>
<script async type="module" src="/src/main.tsx"></script>

View File

@@ -1,39 +1,24 @@
import { Box, CircularProgress, circularProgressClasses, CircularProgressProps } from "@mui/material";
import { Box } from "@mui/material";
import { forwardRef } from "react";
import LinearProgressComponent from "./LinearProgress";
export interface FacebookCircularProgressProps extends CircularProgressProps {
export interface FacebookCircularProgressProps {
sx?: any;
color?: string;
size?: number;
thickness?: number;
bgColor?: string;
fgColor?: string;
}
const FacebookCircularProgress = forwardRef(({ sx, bgColor, fgColor, ...rest }: FacebookCircularProgressProps, ref) => {
const FacebookCircularProgress = forwardRef(
({ sx, color, bgColor, fgColor, ...rest }: FacebookCircularProgressProps, ref) => {
return (
<Box sx={{ position: "relative", ...sx }} ref={ref}>
<CircularProgress
variant="determinate"
sx={{
color: (theme) => bgColor ?? theme.palette.grey[theme.palette.mode === "light" ? 200 : 800],
}}
size={40}
thickness={4}
{...rest}
value={100}
/>
<CircularProgress
sx={{
color: (theme) => fgColor ?? theme.palette.primary.main,
position: "absolute",
left: 0,
[`& .${circularProgressClasses.circle}`]: {
strokeLinecap: "round",
},
}}
size={40}
thickness={4}
{...rest}
/>
<Box sx={{ display: "flex", justifyContent: "center", alignItems: "center", ...sx }} ref={ref}>
<LinearProgressComponent color={color || fgColor} height={8} />
</Box>
);
});
},
);
export default FacebookCircularProgress;

View File

@@ -0,0 +1,30 @@
import { Box, LinearProgress, linearProgressClasses } from "@mui/material";
import { forwardRef } from "react";
export interface LinearProgressProps {
color?: string;
height?: number;
}
const LinearProgressComponent = forwardRef(({ color, height = 8, ...rest }: LinearProgressProps, ref) => {
return (
<Box sx={{ width: "100%", maxWidth: 200, ...rest }} ref={ref}>
<LinearProgress
variant="indeterminate"
sx={{
height: height,
borderRadius: height / 2,
[`&.${linearProgressClasses.colorPrimary}`]: {
backgroundColor: (theme) => theme.palette.grey[theme.palette.mode === "light" ? 200 : 800],
},
[`& .${linearProgressClasses.bar}`]: {
borderRadius: height / 2,
backgroundColor: color || ((theme) => theme.palette.primary.main),
},
}}
/>
</Box>
);
});
export default LinearProgressComponent;

View File

@@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from "../../../redux/hooks.ts";
import { ConfigLoadState } from "../../../redux/siteConfigSlice.ts";
import { openEmptyContextMenu } from "../../../redux/thunks/filemanager.ts";
import { loadSiteConfig } from "../../../redux/thunks/site.ts";
import CircularProgress from "../../Common/CircularProgress.tsx";
import FacebookCircularProgress from "../../Common/CircularProgress.tsx";
import "../../Common/FadeTransition.css";
import { RadiusFrame } from "../../Frame/RadiusFrame.tsx";
import ExplorerError from "./ExplorerError.tsx";
@@ -137,7 +137,7 @@ const Explorer = () => {
alignItems: "center",
}}
>
<CircularProgress />
<FacebookCircularProgress />
</Box>
)}
{index == ExplorerPage.GridView && <GridView />}