mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 05:03:45 +08:00
Fix: Custom tray icon not working
1. Contains potential deadlock
This commit is contained in:
parent
414f9e9e96
commit
dffd663d7a
@ -11,6 +11,11 @@
|
|||||||
"identifier": "fs:scope",
|
"identifier": "fs:scope",
|
||||||
"allow": ["$APPDATA/**", "$RESOURCE/../**", "**"]
|
"allow": ["$APPDATA/**", "$RESOURCE/../**", "**"]
|
||||||
},
|
},
|
||||||
|
"fs:allow-write-file",
|
||||||
|
{
|
||||||
|
"identifier": "fs:scope",
|
||||||
|
"allow": ["$APPDATA/**", "$RESOURCE/../**", "**"]
|
||||||
|
},
|
||||||
"core:window:allow-create",
|
"core:window:allow-create",
|
||||||
"core:window:allow-center",
|
"core:window:allow-center",
|
||||||
"core:window:allow-request-user-attention",
|
"core:window:allow-request-user-attention",
|
||||||
|
@ -57,7 +57,7 @@ impl Handle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_systray() -> Result<()> {
|
pub fn update_systray() -> Result<()> {
|
||||||
let app_handle = Self::global().app_handle.lock();
|
let app_handle = Self::global().app_handle.lock().clone();
|
||||||
if app_handle.is_none() {
|
if app_handle.is_none() {
|
||||||
bail!("update_systray unhandled error");
|
bail!("update_systray unhandled error");
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ impl Handle {
|
|||||||
|
|
||||||
/// update the system tray state
|
/// update the system tray state
|
||||||
pub fn update_systray_part() -> Result<()> {
|
pub fn update_systray_part() -> Result<()> {
|
||||||
let app_handle = Self::global().app_handle.lock();
|
let app_handle = Self::global().app_handle.lock().clone();
|
||||||
if app_handle.is_none() {
|
if app_handle.is_none() {
|
||||||
bail!("update_systray unhandled error");
|
bail!("update_systray unhandled error");
|
||||||
}
|
}
|
||||||
|
@ -244,13 +244,10 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
|
|||||||
|| common_tray_icon.is_some()
|
|| common_tray_icon.is_some()
|
||||||
|| sysproxy_tray_icon.is_some()
|
|| sysproxy_tray_icon.is_some()
|
||||||
|| tun_tray_icon.is_some()
|
|| tun_tray_icon.is_some()
|
||||||
|
|| tray_icon.is_some()
|
||||||
{
|
{
|
||||||
handle::Handle::update_systray_part()?;
|
handle::Handle::update_systray_part()?;
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
if tray_icon.is_some() {
|
|
||||||
handle::Handle::update_systray_part()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
<Result<()>>::Ok(())
|
<Result<()>>::Ok(())
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,6 @@ pub fn app_home_dir() -> Result<PathBuf> {
|
|||||||
.ok_or(anyhow::anyhow!("failed to get the portable app dir"))?;
|
.ok_or(anyhow::anyhow!("failed to get the portable app dir"))?;
|
||||||
return Ok(PathBuf::from(app_dir).join(".config").join(APP_ID));
|
return Ok(PathBuf::from(app_dir).join(".config").join(APP_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
let handle = handle::Handle::global();
|
let handle = handle::Handle::global();
|
||||||
let app_handle = handle.app_handle.lock().clone();
|
let app_handle = handle.app_handle.lock().clone();
|
||||||
|
|
||||||
@ -65,7 +64,7 @@ pub fn app_home_dir() -> Result<PathBuf> {
|
|||||||
/// get the resources dir
|
/// get the resources dir
|
||||||
pub fn app_resources_dir() -> Result<PathBuf> {
|
pub fn app_resources_dir() -> Result<PathBuf> {
|
||||||
let handle = handle::Handle::global();
|
let handle = handle::Handle::global();
|
||||||
let app_handle = handle.app_handle.lock();
|
let app_handle = handle.app_handle.lock().clone();
|
||||||
if let Some(app_handle) = app_handle.as_ref() {
|
if let Some(app_handle) = app_handle.as_ref() {
|
||||||
match app_handle.path().resource_dir() {
|
match app_handle.path().resource_dir() {
|
||||||
Ok(dir) => {
|
Ok(dir) => {
|
||||||
|
@ -196,8 +196,8 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
if (selected?.path.length) {
|
if (selected) {
|
||||||
await copyIconFile(`${selected.path}`, "common");
|
await copyIconFile(`${selected}`, "common");
|
||||||
await initIconPath();
|
await initIconPath();
|
||||||
onChangeData({ common_tray_icon: true });
|
onChangeData({ common_tray_icon: true });
|
||||||
patchVerge({ common_tray_icon: true });
|
patchVerge({ common_tray_icon: true });
|
||||||
@ -242,8 +242,8 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
if (selected?.path.length) {
|
if (selected) {
|
||||||
await copyIconFile(`${selected.path}`, "sysproxy");
|
await copyIconFile(`${selected}`, "sysproxy");
|
||||||
await initIconPath();
|
await initIconPath();
|
||||||
onChangeData({ sysproxy_tray_icon: true });
|
onChangeData({ sysproxy_tray_icon: true });
|
||||||
patchVerge({ sysproxy_tray_icon: true });
|
patchVerge({ sysproxy_tray_icon: true });
|
||||||
@ -281,13 +281,13 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
multiple: false,
|
multiple: false,
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
name: "Tray Icon Image",
|
name: "Tun Icon Image",
|
||||||
extensions: ["png", "ico"],
|
extensions: ["png", "ico"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
if (selected?.path.length) {
|
if (selected) {
|
||||||
await copyIconFile(`${selected.path}`, "tun");
|
await copyIconFile(`${selected}`, "tun");
|
||||||
await initIconPath();
|
await initIconPath();
|
||||||
onChangeData({ tun_tray_icon: true });
|
onChangeData({ tun_tray_icon: true });
|
||||||
patchVerge({ tun_tray_icon: true });
|
patchVerge({ tun_tray_icon: true });
|
||||||
|
@ -194,9 +194,9 @@ const SettingVerge = ({ onError }: Props) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
if (selected?.path.length) {
|
if (selected) {
|
||||||
onChangeData({ startup_script: `${selected.path}` });
|
onChangeData({ startup_script: `${selected}` });
|
||||||
patchVerge({ startup_script: `${selected.path}` });
|
patchVerge({ startup_script: `${selected}` });
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user