mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-06 13:50:28 +08:00
fix(frontend): prevent selecting theme from causing segfault on Linux (#2502)
This commit is contained in:
@@ -5,6 +5,7 @@ import React, {
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import { isLinux } from "@/lib/platform";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
type Theme = "light" | "dark" | "system";
|
||||
@@ -147,7 +148,12 @@ export function ThemeProvider({
|
||||
);
|
||||
|
||||
// Use View Transitions API if available, otherwise fall back to instant change
|
||||
if (document.startViewTransition) {
|
||||
// Disable for Linux, since WebKitGTK crashes on `document.startViewTransition`
|
||||
if (
|
||||
typeof document !== "undefined" &&
|
||||
document.startViewTransition &&
|
||||
!isLinux()
|
||||
) {
|
||||
document.startViewTransition(() => {
|
||||
setThemeState(nextTheme);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user