fix: cannot select code language automatically / code editor height auto-fit into view height

This commit is contained in:
HFO4 2022-04-29 19:53:39 +08:00
parent bda2e2758a
commit 16df89188a
2 changed files with 9 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import CustomPaginationItem from "./PaginationItem";
import { setPagination } from "../../redux/viewUpdate/action";
import AutoHidden from "../Dial/AutoHidden";
import statusHelper from "../../utils/page";
import { useLocation } from "react-router-dom";
const useStyles = makeStyles((theme) => ({
root: {
@ -31,6 +32,7 @@ export default function PaginationFooter() {
const folders = useSelector((state) => state.explorer.dirList);
const pagination = useSelector((state) => state.viewUpdate.pagination);
const loading = useSelector((state) => state.viewUpdate.navigatorLoading);
const location = useLocation();
const SetPagination = useCallback((p) => dispatch(setPagination(p)), [
dispatch,
@ -46,11 +48,14 @@ export default function PaginationFooter() {
);
const isMobile = statusHelper.isMobile();
const isSharePage = statusHelper.isSharePage(location.pathname);
if (count > 1 && !loading) {
return (
<>
{!isMobile && <div className={classes.placeholder} />}
{!isMobile && !isSharePage && (
<div className={classes.placeholder} />
)}
<AutoHidden enable>
<div className={classes.root}>
<Pagination

View File

@ -32,7 +32,7 @@ const useStyles = makeStyles((theme) => ({
marginLeft: "auto",
marginRight: "auto",
},
marginBottom: 50,
marginBottom: 40,
},
editor: {
borderRadius: "4px",
@ -79,7 +79,7 @@ export default function CodeViewer() {
const extension = title.split(".");
setSuffix(codePreviewSuffix[extension.pop()]);
// eslint-disable-next-line
}, []);
}, [title]);
useEffect(() => {
let requestURL = "/file/content/" + query.get("id");
@ -171,7 +171,7 @@ export default function CodeViewer() {
{!loading && (
<Suspense fallback={<TextLoading />}>
<MonacoEditor
height="600"
height="calc(100vh - 198px)"
language={suffix}
theme={
theme.palette.type === "dark" ? "vs-dark" : "vs"