mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 03:32:36 +08:00
feat: support blur window
This commit is contained in:
parent
8f5b2b4a0e
commit
df5953dd7b
12
src-tauri/Cargo.lock
generated
12
src-tauri/Cargo.lock
generated
|
@ -54,6 +54,7 @@ dependencies = [
|
||||||
"tauri",
|
"tauri",
|
||||||
"tauri-build",
|
"tauri-build",
|
||||||
"tauri-plugin-shadows",
|
"tauri-plugin-shadows",
|
||||||
|
"tauri-plugin-vibrancy",
|
||||||
"tokio",
|
"tokio",
|
||||||
"warp",
|
"warp",
|
||||||
"winreg 0.10.1",
|
"winreg 0.10.1",
|
||||||
|
@ -3369,6 +3370,17 @@ dependencies = [
|
||||||
"windows 0.29.0",
|
"windows 0.29.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tauri-plugin-vibrancy"
|
||||||
|
version = "0.0.0"
|
||||||
|
source = "git+https://github.com/tauri-apps/tauri-plugin-vibrancy#b4fceab0d4a6d024f1b9916c126f10f513101128"
|
||||||
|
dependencies = [
|
||||||
|
"cocoa",
|
||||||
|
"objc",
|
||||||
|
"tauri",
|
||||||
|
"windows 0.29.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime"
|
name = "tauri-runtime"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
|
|
@ -22,6 +22,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||||
# tauri = { git = "https://github.com/tauri-apps/tauri", rev = "5e0d59ec", features = ["api-all", "system-tray"] }
|
# tauri = { git = "https://github.com/tauri-apps/tauri", rev = "5e0d59ec", features = ["api-all", "system-tray"] }
|
||||||
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next", features = ["api-all", "system-tray", "updater"] }
|
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next", features = ["api-all", "system-tray", "updater"] }
|
||||||
tauri-plugin-shadows = { git = "https://github.com/tauri-apps/tauri-plugin-shadows", features = ["tauri-impl"] }
|
tauri-plugin-shadows = { git = "https://github.com/tauri-apps/tauri-plugin-shadows", features = ["tauri-impl"] }
|
||||||
|
tauri-plugin-vibrancy = { git = "https://github.com/tauri-apps/tauri-plugin-vibrancy", features = ["tauri-impl"] }
|
||||||
|
|
||||||
reqwest = { version = "0.11", features = ["json"] }
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
|
|
@ -9,6 +9,10 @@ pub struct VergeConfig {
|
||||||
/// `light` or `dark`
|
/// `light` or `dark`
|
||||||
pub theme_mode: Option<String>,
|
pub theme_mode: Option<String>,
|
||||||
|
|
||||||
|
/// enable blur mode
|
||||||
|
/// maybe be able to set the alpha
|
||||||
|
pub theme_blur: Option<bool>,
|
||||||
|
|
||||||
/// can the app auto startup
|
/// can the app auto startup
|
||||||
pub enable_self_startup: Option<bool>,
|
pub enable_self_startup: Option<bool>,
|
||||||
|
|
||||||
|
@ -157,6 +161,9 @@ impl Verge {
|
||||||
if patch.theme_mode.is_some() {
|
if patch.theme_mode.is_some() {
|
||||||
self.config.theme_mode = patch.theme_mode;
|
self.config.theme_mode = patch.theme_mode;
|
||||||
}
|
}
|
||||||
|
if patch.theme_blur.is_some() {
|
||||||
|
self.config.theme_blur = patch.theme_blur;
|
||||||
|
}
|
||||||
|
|
||||||
// should update system startup
|
// should update system startup
|
||||||
if patch.enable_self_startup.is_some() {
|
if patch.enable_self_startup.is_some() {
|
||||||
|
|
|
@ -9,6 +9,15 @@ pub fn resolve_setup(app: &App) {
|
||||||
let window = app.get_window("main").unwrap();
|
let window = app.get_window("main").unwrap();
|
||||||
window.set_shadow(true);
|
window.set_shadow(true);
|
||||||
|
|
||||||
|
use tauri_plugin_vibrancy::Vibrancy;
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
window.apply_blur();
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
use tauri_plugin_vibrancy::MacOSVibrancy;
|
||||||
|
window.apply_vibrancy(MacOSVibrancy::AppearanceBased);
|
||||||
|
}
|
||||||
|
|
||||||
// setup a simple http server for singleton
|
// setup a simple http server for singleton
|
||||||
server::embed_server(&app.handle());
|
server::embed_server(&app.handle());
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
"resizable": true,
|
"resizable": true,
|
||||||
"fullscreen": false,
|
"fullscreen": false,
|
||||||
"decorations": false,
|
"decorations": false,
|
||||||
"transparent": false,
|
"transparent": true,
|
||||||
"minWidth": 600,
|
"minWidth": 600,
|
||||||
"minHeight": 520
|
"minHeight": 520
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ const SettingVerge = ({ onError }: Props) => {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
theme_mode: mode = "light",
|
theme_mode: mode = "light",
|
||||||
|
theme_blur: blur = false,
|
||||||
enable_self_startup: startup = false,
|
enable_self_startup: startup = false,
|
||||||
enable_system_proxy: proxy = false,
|
enable_system_proxy: proxy = false,
|
||||||
} = vergeConfig ?? {};
|
} = vergeConfig ?? {};
|
||||||
|
@ -54,6 +55,20 @@ const SettingVerge = ({ onError }: Props) => {
|
||||||
</GuardState>
|
</GuardState>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
|
||||||
|
<SettingItem>
|
||||||
|
<ListItemText primary="Theme Blur" />
|
||||||
|
<GuardState
|
||||||
|
value={blur}
|
||||||
|
valueProps="checked"
|
||||||
|
onCatch={onError}
|
||||||
|
onFormat={onSwitchFormat}
|
||||||
|
onChange={(e) => onChangeData({ theme_blur: e })}
|
||||||
|
onGuard={(e) => patchVergeConfig({ theme_blur: e })}
|
||||||
|
>
|
||||||
|
<Switch edge="end" />
|
||||||
|
</GuardState>
|
||||||
|
</SettingItem>
|
||||||
|
|
||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText primary="Self Startup" />
|
<ListItemText primary="Self Startup" />
|
||||||
<GuardState
|
<GuardState
|
||||||
|
|
|
@ -3,6 +3,7 @@ import useSWR, { SWRConfig } from "swr";
|
||||||
import { Route, Routes } from "react-router-dom";
|
import { Route, Routes } from "react-router-dom";
|
||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
import {
|
import {
|
||||||
|
alpha,
|
||||||
Button,
|
Button,
|
||||||
createTheme,
|
createTheme,
|
||||||
IconButton,
|
IconButton,
|
||||||
|
@ -12,7 +13,7 @@ import {
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { HorizontalRuleRounded, CloseRounded } from "@mui/icons-material";
|
import { HorizontalRuleRounded, CloseRounded } from "@mui/icons-material";
|
||||||
import { checkUpdate } from "@tauri-apps/api/updater";
|
import { checkUpdate } from "@tauri-apps/api/updater";
|
||||||
import { atomPaletteMode } from "../states/setting";
|
import { atomPaletteMode, atomThemeBlur } from "../states/setting";
|
||||||
import { getVergeConfig, windowDrag, windowHide } from "../services/cmds";
|
import { getVergeConfig, windowDrag, windowHide } from "../services/cmds";
|
||||||
import LogoSvg from "../assets/image/logo.svg";
|
import LogoSvg from "../assets/image/logo.svg";
|
||||||
import LogPage from "./log";
|
import LogPage from "./log";
|
||||||
|
@ -54,6 +55,7 @@ const routers = [
|
||||||
|
|
||||||
const Layout = () => {
|
const Layout = () => {
|
||||||
const [mode, setMode] = useRecoilState(atomPaletteMode);
|
const [mode, setMode] = useRecoilState(atomPaletteMode);
|
||||||
|
const [blur, setBlur] = useRecoilState(atomThemeBlur);
|
||||||
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
|
const { data: vergeConfig } = useSWR("getVergeConfig", getVergeConfig);
|
||||||
const { data: updateInfo } = useSWR("checkUpdate", checkUpdate, {
|
const { data: updateInfo } = useSWR("checkUpdate", checkUpdate, {
|
||||||
errorRetryCount: 2,
|
errorRetryCount: 2,
|
||||||
|
@ -63,8 +65,10 @@ const Layout = () => {
|
||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setMode(vergeConfig?.theme_mode ?? "light");
|
if (!vergeConfig) return;
|
||||||
}, [vergeConfig?.theme_mode]);
|
setBlur(!!vergeConfig.theme_blur);
|
||||||
|
setMode(vergeConfig.theme_mode ?? "light");
|
||||||
|
}, [vergeConfig]);
|
||||||
|
|
||||||
const theme = useMemo(() => {
|
const theme = useMemo(() => {
|
||||||
// const background = mode === "light" ? "#f5f5f5" : "#000";
|
// const background = mode === "light" ? "#f5f5f5" : "#000";
|
||||||
|
@ -89,7 +93,16 @@ const Layout = () => {
|
||||||
return (
|
return (
|
||||||
<SWRConfig value={{}}>
|
<SWRConfig value={{}}>
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
<Paper square elevation={0} className="layout">
|
<Paper
|
||||||
|
square
|
||||||
|
elevation={0}
|
||||||
|
className="layout"
|
||||||
|
sx={[
|
||||||
|
(theme) => ({
|
||||||
|
bgcolor: alpha(theme.palette.background.paper, blur ? 0.85 : 1),
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
<div className="layout__left">
|
<div className="layout__left">
|
||||||
<div className="the-logo">
|
<div className="the-logo">
|
||||||
<img
|
<img
|
||||||
|
|
|
@ -110,6 +110,7 @@ export namespace CmdType {
|
||||||
|
|
||||||
export interface VergeConfig {
|
export interface VergeConfig {
|
||||||
theme_mode?: "light" | "dark";
|
theme_mode?: "light" | "dark";
|
||||||
|
theme_blur?: boolean;
|
||||||
enable_self_startup?: boolean;
|
enable_self_startup?: boolean;
|
||||||
enable_system_proxy?: boolean;
|
enable_system_proxy?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,3 +4,8 @@ export const atomPaletteMode = atom<"light" | "dark">({
|
||||||
key: "atomPaletteMode",
|
key: "atomPaletteMode",
|
||||||
default: "light",
|
default: "light",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const atomThemeBlur = atom<boolean>({
|
||||||
|
key: "atomThemeBlur",
|
||||||
|
default: false,
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user