[bugfix] Fix corner rounded bug.
before: win10, corner rounded true. win 11 corner rounded true and when window maximized likewise. after: win10, corner rounded false. win 11 corner rounded true but turn to false when window maximized.
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
|||||||
UiSizeController,
|
UiSizeController,
|
||||||
FontFamilyController,
|
FontFamilyController,
|
||||||
TransparencyController,
|
TransparencyController,
|
||||||
|
CornerRadiusController,
|
||||||
PluginsController,
|
PluginsController,
|
||||||
} from "./_app_controllers/index.js";
|
} from "./_app_controllers/index.js";
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ export const App = () => {
|
|||||||
<UiSizeController />
|
<UiSizeController />
|
||||||
<FontFamilyController />
|
<FontFamilyController />
|
||||||
<TransparencyController />
|
<TransparencyController />
|
||||||
|
<CornerRadiusController />
|
||||||
|
|
||||||
{(currentIsBackendReady.data === false || currentIsVrctAvailable.data === false)
|
{(currentIsBackendReady.data === false || currentIsVrctAvailable.data === false)
|
||||||
? <SplashComponent />
|
? <SplashComponent />
|
||||||
|
|||||||
53
src-ui/app/_app_controllers/CornerRadiusController.jsx
Normal file
53
src-ui/app/_app_controllers/CornerRadiusController.jsx
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
|
|
||||||
|
export const CornerRadiusController = () => {
|
||||||
|
const [is_win11, setIsWin11] = useState(false);
|
||||||
|
const [is_maximized, setIsMaximized] = useState(false);
|
||||||
|
|
||||||
|
// OS 判定(Win11 なら platformVersion の major ≥13)
|
||||||
|
useEffect(() => {
|
||||||
|
if (navigator.userAgentData?.getHighEntropyValues) {
|
||||||
|
navigator.userAgentData
|
||||||
|
.getHighEntropyValues(["platformVersion"])
|
||||||
|
.then(({ platformVersion }) => {
|
||||||
|
const major = parseInt(platformVersion.split(".")[0], 10);
|
||||||
|
setIsWin11(major >= 13);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setIsWin11(false);
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// フォールバックで Win10 扱い
|
||||||
|
setIsWin11(false);
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let unlisten;
|
||||||
|
const setup = async () => {
|
||||||
|
const window = await getCurrentWindow();
|
||||||
|
// 初期状態取得
|
||||||
|
setIsMaximized(await window.isMaximized());
|
||||||
|
// リサイズ時にも再取得
|
||||||
|
const updateMax = () => window.isMaximized().then(setIsMaximized);
|
||||||
|
unlisten = await window.listen("tauri://resize", updateMax);
|
||||||
|
}
|
||||||
|
setup();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (unlisten) {
|
||||||
|
unlisten();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 角丸の適用
|
||||||
|
useEffect(() => {
|
||||||
|
const radius = is_win11 && !is_maximized ? "10px" : "0";
|
||||||
|
document.body.style.borderRadius = radius;
|
||||||
|
}, [is_win11, is_maximized]);
|
||||||
|
|
||||||
|
return null;;
|
||||||
|
}
|
||||||
@@ -7,3 +7,4 @@ export { UiSizeController } from "./UiSizeController";
|
|||||||
export { FontFamilyController } from "./FontFamilyController";
|
export { FontFamilyController } from "./FontFamilyController";
|
||||||
export { TransparencyController } from "./TransparencyController";
|
export { TransparencyController } from "./TransparencyController";
|
||||||
export { PluginsController } from "./PluginsController";
|
export { PluginsController } from "./PluginsController";
|
||||||
|
export { CornerRadiusController } from "./CornerRadiusController";
|
||||||
Reference in New Issue
Block a user