-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"main-capability":{"identifier":"main-capability","description":"Capability for the main window","local":true,"windows":["main"],"permissions":["path:default","event:default","window:default","window:allow-start-dragging","window:allow-hide","window:allow-minimize","app:default","resources:default","menu:default","tray:default","autostart:allow-disable","autostart:allow-enable","autostart:allow-is-enabled","clipboard-manager:allow-write-text","dialog:allow-open","fs:allow-copy-file","fs:allow-mkdir","fs:allow-write-file","fs:allow-write-text-file","fs:allow-read-text-file","fs:allow-exists","fs:allow-remove","fs:scope-appdata-recursive","log:allow-log","process:allow-restart","process:allow-exit","shell:allow-open","sql:allow-load","sql:allow-select","sql:allow-execute","sql:allow-close","store:allow-length","store:allow-entries","store:allow-set","store:allow-save","updater:default","shion-history:allow-get-config","shion-history:allow-set-config","shion-history:allow-read-history","shion-watcher:allow-resume","shion-watcher:allow-suspend","shion-watcher:allow-get-program-list","shion-watcher:allow-get-program-by-path"]}} | ||
{"main-capability":{"identifier":"main-capability","description":"Capability for the main window","local":true,"windows":["main"],"permissions":["path:default","event:default","window:default","window:allow-start-dragging","window:allow-hide","window:allow-minimize","app:default","resources:default","menu:default","tray:default","tray:allow-get-by-id","autostart:allow-disable","autostart:allow-enable","autostart:allow-is-enabled","clipboard-manager:allow-write-text","dialog:allow-open","fs:allow-copy-file","fs:allow-mkdir","fs:allow-write-file","fs:allow-write-text-file","fs:allow-read-text-file","fs:allow-exists","fs:allow-remove","fs:scope-appdata-recursive","log:allow-log","process:allow-restart","process:allow-exit","shell:allow-open","sql:allow-load","sql:allow-select","sql:allow-execute","sql:allow-close","store:allow-length","store:allow-entries","store:allow-set","store:allow-save","updater:default","shion-history:allow-get-config","shion-history:allow-set-config","shion-history:allow-read-history","shion-watcher:allow-resume","shion-watcher:allow-suspend","shion-watcher:allow-get-program-list","shion-watcher:allow-get-program-by-path"]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { invoke } from '@tauri-apps/api/core' | ||
import { TrayIcon } from '@tauri-apps/api/tray' | ||
import { error } from '@tauri-apps/plugin-log' | ||
|
||
import { i18n } from '@/locales' | ||
|
||
export function checkTrayExists() { | ||
const timer = new Timer(async () => { | ||
const exists = await createTray() | ||
if (exists) | ||
timer.destroy() | ||
}, 3000) | ||
} | ||
|
||
async function createTray() { | ||
const icon = await TrayIcon.getById('tray') | ||
if (!icon) { | ||
try { | ||
await invoke('create_tray') | ||
await invoke('update_tray_menu', { | ||
data: { | ||
quit: i18n.global.t('tray.quit'), | ||
}, | ||
}) | ||
} | ||
catch (e) { | ||
error(`create tray error: ${e}`) | ||
return false | ||
} | ||
} | ||
return !!icon | ||
} |