fix: windows style

This commit is contained in:
GyDi 2022-03-22 01:36:06 +08:00
parent dd605e2610
commit bd0a959e18
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084
3 changed files with 25 additions and 7 deletions

View File

@ -80,8 +80,12 @@
} }
} }
.windows.layout { .linux,
.layout__right .the-content { .windows,
top: 30px; .unknown {
&.layout {
.layout__right .the-content {
top: 30px;
}
} }
} }

View File

@ -16,11 +16,12 @@ import LayoutItem from "../components/layout/layout-item";
import LayoutControl from "../components/layout/layout-control"; import LayoutControl from "../components/layout/layout-control";
import LayoutTraffic from "../components/layout/layout-traffic"; import LayoutTraffic from "../components/layout/layout-traffic";
import UpdateButton from "../components/layout/update-button"; import UpdateButton from "../components/layout/update-button";
import getSystem from "../utils/get-system";
import "dayjs/locale/zh-cn"; import "dayjs/locale/zh-cn";
dayjs.extend(relativeTime); dayjs.extend(relativeTime);
const isWinOs = /win64|win32/i.test(navigator.userAgent); const OS = getSystem();
const Layout = () => { const Layout = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -85,11 +86,11 @@ const Layout = () => {
<Paper <Paper
square square
elevation={0} elevation={0}
className={`${isWinOs ? "windows " : ""}layout`} className={`${OS} layout`}
onPointerDown={onDragging} onPointerDown={onDragging}
onContextMenu={(e) => { onContextMenu={(e) => {
// only prevent it on Windows // only prevent it on Windows
if (isWinOs) e.preventDefault(); if (OS === "windows") e.preventDefault();
}} }}
sx={[ sx={[
(theme) => ({ (theme) => ({
@ -118,7 +119,7 @@ const Layout = () => {
</div> </div>
<div className="layout__right" data-windrag> <div className="layout__right" data-windrag>
{isWinOs && ( {OS === "windows" && (
<div className="the-bar"> <div className="the-bar">
<LayoutControl /> <LayoutControl />
</div> </div>

13
src/utils/get-system.ts Normal file
View File

@ -0,0 +1,13 @@
// get the system os
// according to UA
export default function getSystem() {
const ua = navigator.userAgent;
if (ua.includes("Mac OS X")) return "macos";
if (/win64|win32/i.test(ua)) return "windows";
if (/linux/i.test(ua)) return "linux";
return "unknown";
}