diff --git a/public/locales/af/common.json b/public/locales/af/common.json index 2c4e1a028..ae3e8efd2 100644 --- a/public/locales/af/common.json +++ b/public/locales/af/common.json @@ -9,6 +9,7 @@ "disconnect": "Ontkoppel", "hashrate": "Hashtempo", "max-temperature": "Maksimum temperatuur", + "minimize": "Minimize", "mode": "Modus", "please-try-again-later": "Probeer asseblief later weer. As die probleem voortduur, kontak ons asseblief.", "resources": "Hulpbronne", @@ -20,6 +21,7 @@ "temperature": "Temperatuur", "testnet": "Toetsnetwerk", "unknown": "Onbekend", + "unminimize": "Unminimize", "usage": "Gebruik", "utilization": "Benutting", "version": "Weergawe", diff --git a/public/locales/af/mining-view.json b/public/locales/af/mining-view.json index b4419eb7a..68b7eea57 100644 --- a/public/locales/af/mining-view.json +++ b/public/locales/af/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "CPU Krag", - "gpu-power": "GPU Krag", - "estimated-day": "Est tXTM/dag", "connection-to-node-lost": "Kontak met mynwerker verloor. Wag asseblief vir mynwerker om kontak te maak of begin weer.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "CPU Krag", + "cpu-usage": "CPU Usage", "current-block-time": "Huidige bloktyd", "day": "day", + "estimated-day": "Est tXTM/dag", "estimated-earnings": "Geskatte verdienste", "floor": "Vloer", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "GPU Krag", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "Kanselleer myn", "changing-mode": "Verander modus", diff --git a/public/locales/cn/common.json b/public/locales/cn/common.json index a55ac9b5f..4c139ca1f 100644 --- a/public/locales/cn/common.json +++ b/public/locales/cn/common.json @@ -9,6 +9,7 @@ "disconnect": "断开连接", "hashrate": "哈希率", "max-temperature": "最高温度", + "minimize": "Minimize", "mode": "模式", "please-try-again-later": "请稍后再试。如果问题仍然存在,请联系我们。", "resources": "资源", @@ -20,6 +21,7 @@ "temperature": "温度", "testnet": "测试网", "unknown": "未知", + "unminimize": "Unminimize", "usage": "使用", "utilization": "利用率", "version": "版本", diff --git a/public/locales/cn/mining-view.json b/public/locales/cn/mining-view.json index dc2543495..80005602e 100644 --- a/public/locales/cn/mining-view.json +++ b/public/locales/cn/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "CPU 功率", - "gpu-power": "GPU 功率", - "estimated-day": "预估 tXTM/天", "connection-to-node-lost": "与矿工的连接丢失。请等待矿机重新连接或重启矿机.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "CPU 功率", + "cpu-usage": "CPU Usage", "current-block-time": "当前区块时间", "day": "day", + "estimated-day": "预估 tXTM/天", "estimated-earnings": "预计收益", "floor": "地板", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "GPU 功率", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "取消挖矿", "changing-mode": "更改模式", diff --git a/public/locales/de/common.json b/public/locales/de/common.json index 0c44be04d..a9ecf7fcd 100644 --- a/public/locales/de/common.json +++ b/public/locales/de/common.json @@ -9,6 +9,7 @@ "disconnect": "Trennen", "hashrate": "Hashrate", "max-temperature": "Maximaltemperatur", + "minimize": "Minimize", "mode": "Modus", "please-try-again-later": "Bitte versuche es später erneut. Wenn das Problem weiterhin besteht, kontaktiere uns bitte.", "resources": "Ressourcen", @@ -20,6 +21,7 @@ "temperature": "Temperatur", "testnet": "Testnet", "unknown": "Unbekannt", + "unminimize": "Unminimize", "usage": "Nutzung", "utilization": "Auslastung", "version": "Version", diff --git a/public/locales/de/mining-view.json b/public/locales/de/mining-view.json index 5a25872ab..5d7e2219e 100644 --- a/public/locales/de/mining-view.json +++ b/public/locales/de/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "CPU-Leistung", - "gpu-power": "GPU-Leistung", - "estimated-day": "Geschätzte tXTM/Tag", "connection-to-node-lost": "Verbindung zum Miner verloren. Bitte warte, bis der Miner sich wieder verbindet, oder starte den Miner neu.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "CPU-Leistung", + "cpu-usage": "CPU Usage", "current-block-time": "Aktuelle Blockzeit", "day": "day", + "estimated-day": "Geschätzte tXTM/Tag", "estimated-earnings": "Geschätzte Einnahmen", "floor": "Stockwerk", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "GPU-Leistung", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "Mining abbrechen", "changing-mode": "Modus wird geändert", diff --git a/public/locales/en/common.json b/public/locales/en/common.json index ec35efe41..273b526a6 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -9,6 +9,7 @@ "disconnect": "Disconnect", "hashrate": "Hashrate", "max-temperature": "Max temperature", + "minimize": "Minimize", "mode": "Mode", "please-try-again-later": "Please try again later. If the problem persists, please contact us.", "resources": "Resources", @@ -20,6 +21,7 @@ "temperature": "Temperature", "testnet": "Testnet", "unknown": "Unknown", + "unminimize": "Unminimize", "usage": "Usage", "utilization": "Utilization", "version": "Version", diff --git a/public/locales/en/mining-view.json b/public/locales/en/mining-view.json index 4bef06e6f..ad92b1c8b 100644 --- a/public/locales/en/mining-view.json +++ b/public/locales/en/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "CPU Power", - "gpu-power": "GPU Power", - "estimated-day":"Est tXTM/day", "connection-to-node-lost": "Connection to miner lost. Please wait for the miner to reconnect or restart the miner.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "CPU Power", + "cpu-usage": "CPU Usage", "current-block-time": "Current block time", "day": "day", + "estimated-day": "Est tXTM/day", "estimated-earnings": "Estimated earnings", "floor": "Floor", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "GPU Power", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "Cancel Mining", "changing-mode": "Changing mode", @@ -19,4 +23,4 @@ "you-earn-rewards-separately": "You earn rewards for mining CPU and GPU separately", "you-won-while-away": "You won {{ blocks }} while you were away", "your-reward-is": "Your reward is" -} +} \ No newline at end of file diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json index 201bda25d..0f0678436 100644 --- a/public/locales/fr/common.json +++ b/public/locales/fr/common.json @@ -9,6 +9,7 @@ "disconnect": "Déconnecter", "hashrate": "Taux de hachage", "max-temperature": "Température maximale", + "minimize": "Minimize", "mode": "Mode", "please-try-again-later": "Réessaye plus tard s'il te plaît. Si le problème persiste, contacte-nous s'il te plaît.", "resources": "Ressources", @@ -20,6 +21,7 @@ "temperature": "Température", "testnet": "Testnet", "unknown": "Inconnu", + "unminimize": "Unminimize", "usage": "Utilisation", "utilization": "Utilisation", "version": "Version", diff --git a/public/locales/fr/mining-view.json b/public/locales/fr/mining-view.json index cfb3346a4..c52ea976c 100644 --- a/public/locales/fr/mining-view.json +++ b/public/locales/fr/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "Puissance CPU", - "gpu-power": "Puissance GPU", - "estimated-day": "Est tXTM/jour", "connection-to-node-lost": "Connexion au mineur perdue. Attends que le mineur se reconnecte ou redémarre le mineur.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "Puissance CPU", + "cpu-usage": "CPU Usage", "current-block-time": "Temps actuelle du bloc", "day": "day", + "estimated-day": "Est tXTM/jour", "estimated-earnings": "Gains estimés", "floor": "Étage", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "Puissance GPU", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "Annuler le minage", "changing-mode": "Changement de mode", diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 86414541b..063807f85 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -9,6 +9,7 @@ "disconnect": "डिस्कनेक्ट करें", "hashrate": "हैश दर", "max-temperature": "अधिकतम तापमान", + "minimize": "Minimize", "mode": "मोड", "please-try-again-later": "कृपया बाद में पुनः प्रयास करें। यदि समस्या बनी रहती है, तो कृपया हमसे संपर्क करें।", "resources": "संसाधन", @@ -20,6 +21,7 @@ "temperature": "तापमान", "testnet": "टेस्टनेट", "unknown": "अज्ञात", + "unminimize": "Unminimize", "usage": "उपयोग", "utilization": "उपयोग", "version": "संस्करण", diff --git a/public/locales/hi/mining-view.json b/public/locales/hi/mining-view.json index 56e964921..8188763ff 100644 --- a/public/locales/hi/mining-view.json +++ b/public/locales/hi/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "CPU पावर", - "gpu-power": "GPU पावर", - "estimated-day": "Est tXTM/दिन", "connection-to-node-lost": "माइनर से कनेक्शन खो गया। कृपया माइनर के पुनः कनेक्ट होने या पुनः आरंभ करने की प्रतीक्षा करें।", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "CPU पावर", + "cpu-usage": "CPU Usage", "current-block-time": "वर्तमान ब्लॉक समय", "day": "day", + "estimated-day": "Est tXTM/दिन", "estimated-earnings": "अनुमानित कमाई", "floor": "न्यूनतम स्तर", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "GPU पावर", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "माइनिंग रद्द करें", "changing-mode": "मोड बदल रहा है", diff --git a/public/locales/id/common.json b/public/locales/id/common.json index 9d93947dc..9bd34a9dd 100644 --- a/public/locales/id/common.json +++ b/public/locales/id/common.json @@ -9,6 +9,7 @@ "disconnect": "Putuskan Koneksi", "hashrate": "Hashrate", "max-temperature": "Suhu maksimum", + "minimize": "Minimize", "mode": "Mode", "please-try-again-later": "Silakan coba lagi nanti. Jika masalah berlanjut, silakan hubungi kami.", "resources": "Sumber daya", @@ -20,6 +21,7 @@ "temperature": "Suhu", "testnet": "Testnet", "unknown": "Tidak diketahui", + "unminimize": "Unminimize", "usage": "Penggunaan", "utilization": "Pemanfaatan", "version": "Versi", diff --git a/public/locales/id/mining-view.json b/public/locales/id/mining-view.json index 6994546ee..33b718bcc 100644 --- a/public/locales/id/mining-view.json +++ b/public/locales/id/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "Daya CPU", - "gpu-power": "Daya GPU", - "estimated-day": "Perkiraan tXTM/hari", "connection-to-node-lost": "Koneksi ke penambang terputus. Harap tunggu penambang untuk menyambung kembali atau mulai ulang penambang.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "Daya CPU", + "cpu-usage": "CPU Usage", "current-block-time": "Waktu blok saat ini", "day": "day", + "estimated-day": "Perkiraan tXTM/hari", "estimated-earnings": "Perkiraan penghasilan", "floor": "Batas Bawah", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "Daya GPU", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "Batalkan Penambangan", "changing-mode": "Mengubah mode", diff --git a/public/locales/ja/common.json b/public/locales/ja/common.json index 2cbe6ceda..141eb7b82 100644 --- a/public/locales/ja/common.json +++ b/public/locales/ja/common.json @@ -9,6 +9,7 @@ "disconnect": "切断", "hashrate": "ハッシュレート", "max-temperature": "最大温度", + "minimize": "Minimize", "mode": "モード", "please-try-again-later": "後でもう一度お試しください。問題が続く場合は、お問い合わせください。", "resources": "リソース", @@ -20,6 +21,7 @@ "temperature": "温度", "testnet": "テストネット", "unknown": "不明", + "unminimize": "Unminimize", "usage": "使用量", "utilization": "利用率", "version": "バージョン", diff --git a/public/locales/ja/mining-view.json b/public/locales/ja/mining-view.json index c49487090..cebc2a0ae 100644 --- a/public/locales/ja/mining-view.json +++ b/public/locales/ja/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "CPUパワー", - "gpu-power": "GPUパワー", - "estimated-day": "推定 tXTM/日", "connection-to-node-lost": "マイナーへの接続が失われました。マイナーが再接続するか、再起動するのをお待ちください。", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "CPUパワー", + "cpu-usage": "CPU Usage", "current-block-time": "現在のブロック時間", "day": "day", + "estimated-day": "推定 tXTM/日", "estimated-earnings": "推定収益", "floor": "フロア", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "GPUパワー", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "マイニングをキャンセル", "changing-mode": "モードを変更中", diff --git a/public/locales/ko/common.json b/public/locales/ko/common.json index 449f2aa80..5d0730a95 100644 --- a/public/locales/ko/common.json +++ b/public/locales/ko/common.json @@ -9,6 +9,7 @@ "disconnect": "연결 해제", "hashrate": "해시레이트", "max-temperature": "최대 온도", + "minimize": "Minimize", "mode": "모드", "please-try-again-later": "나중에 다시 시도해 주세요. 문제가 계속되면 저희에게 연락해 주세요.", "resources": "자원", @@ -20,6 +21,7 @@ "temperature": "온도", "testnet": "테스트넷", "unknown": "알 수 없음", + "unminimize": "Unminimize", "usage": "사용량", "utilization": "활용도", "version": "버전", diff --git a/public/locales/ko/mining-view.json b/public/locales/ko/mining-view.json index 98fe5ee55..4cc264398 100644 --- a/public/locales/ko/mining-view.json +++ b/public/locales/ko/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "CPU 전력", - "gpu-power": "GPU 전력", - "estimated-day": "Est tXTM/일", "connection-to-node-lost": "마이너와의 연결이 끊어졌습니다. 마이너가 다시 연결되거나 재시작될 때까지 기다려주세요.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "CPU 전력", + "cpu-usage": "CPU Usage", "current-block-time": "현재 블록 시간", "day": "day", + "estimated-day": "Est tXTM/일", "estimated-earnings": "예상 수익", "floor": "최저값", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "GPU 전력", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "채굴 취소", "changing-mode": "모드 변경 중", diff --git a/public/locales/pl/common.json b/public/locales/pl/common.json index 62da6b1b1..9917fbaef 100644 --- a/public/locales/pl/common.json +++ b/public/locales/pl/common.json @@ -9,6 +9,7 @@ "disconnect": "Odłącz", "hashrate": "Prędkość ( hashrate )", "max-temperature": "Maksymalna temperatura", + "minimize": "Minimize", "mode": "Tryb", "please-try-again-later": "Spróbuj ponownie później. Jeśli problem będzie się powtarzał, skontaktuj się z nami.", "resources": "Zasoby", @@ -20,6 +21,7 @@ "temperature": "Temperatura", "testnet": "Testnet", "unknown": "Nieznany", + "unminimize": "Unminimize", "usage": "Użycie", "utilization": "Wykorzystanie", "version": "Wersja", diff --git a/public/locales/pl/mining-view.json b/public/locales/pl/mining-view.json index 994b8740f..eee187d04 100644 --- a/public/locales/pl/mining-view.json +++ b/public/locales/pl/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "Moc CPU", - "gpu-power": "Moc GPU", - "estimated-day": "Est tXTM/dzień", "connection-to-node-lost": "Połączenie z węzłem kopania zostało utracone. Poczekaj, aż wznowi połącznie lub uruchom go ponownie.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "Moc CPU", + "cpu-usage": "CPU Usage", "current-block-time": "Aktualny czas bloku", "day": "day", + "estimated-day": "Est tXTM/dzień", "estimated-earnings": "Szacowane zarobki", "floor": "Poziom", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "Moc GPU", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "Anuluj kopanie", "changing-mode": "Zmiana trybu", diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 816b2752d..2cfe937e3 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -9,6 +9,7 @@ "disconnect": "Отключить", "hashrate": "Хэшрейт", "max-temperature": "Максимальная температура", + "minimize": "Minimize", "mode": "Режим", "please-try-again-later": "Пожалуйста, попробуйте позже. Если проблема сохраняется, свяжитесь с нами.", "resources": "Ресурсы", @@ -20,6 +21,7 @@ "temperature": "Температура", "testnet": "Тестовая сеть", "unknown": "Неизвестно", + "unminimize": "Unminimize", "usage": "Использование", "utilization": "Использование", "version": "Версия", diff --git a/public/locales/ru/mining-view.json b/public/locales/ru/mining-view.json index 9bdf0572f..bff1a79de 100644 --- a/public/locales/ru/mining-view.json +++ b/public/locales/ru/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "ЦП Мощность", - "gpu-power": "ГПУ Мощность", - "estimated-day": "Est tXTM/день", "connection-to-node-lost": "Соединение с майнером потеряно. Пожалуйста, подождите, пока майнер переподключится, или перезапустите его.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "ЦП Мощность", + "cpu-usage": "CPU Usage", "current-block-time": "Текущее время блока", "day": "day", + "estimated-day": "Est tXTM/день", "estimated-earnings": "Ожидаемый доход", "floor": "Минимум", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "ГПУ Мощность", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "Отмена майнинга", "changing-mode": "Изменение режима", diff --git a/public/locales/tr/common.json b/public/locales/tr/common.json index 664de2b6b..2dc67cbcb 100644 --- a/public/locales/tr/common.json +++ b/public/locales/tr/common.json @@ -9,6 +9,7 @@ "disconnect": "Bağlantıyı Kes", "hashrate": "Hashrate", "max-temperature": "Maks. Sıcaklık", + "minimize": "Minimize", "mode": "Mod", "please-try-again-later": "Lütfen daha sonra tekrar deneyin. Sorun devam ederse, lütfen bizimle iletişime geçin.", "resources": "Kaynaklar", @@ -20,6 +21,7 @@ "temperature": "Sıcaklık", "testnet": "Testnet", "unknown": "Bilinmeyen", + "unminimize": "Unminimize", "usage": "Kullanım", "utilization": "Fayda", "version": "Versiyon", diff --git a/public/locales/tr/mining-view.json b/public/locales/tr/mining-view.json index 8437fcfce..562dfebf6 100644 --- a/public/locales/tr/mining-view.json +++ b/public/locales/tr/mining-view.json @@ -1,12 +1,16 @@ { - "cpu-power": "CPU Gücü", - "gpu-power": "GPU Gücü", - "estimated-day": "Est tXTM/gün", "connection-to-node-lost": "Madenciyle bağlantı kesildi. Lütfen madencinin yeniden bağlanmasını bekleyin veya madenciyi yeniden başlatın.", + "cpu-hashrate": "CPU Hashrate", + "cpu-power": "CPU Gücü", + "cpu-usage": "CPU Usage", "current-block-time": "Geçerli blok zamanı", "day": "day", + "estimated-day": "Est tXTM/gün", "estimated-earnings": "Tahmini kazançlar", "floor": "Zemin", + "gpu-hashrate": "GPU Hashrate", + "gpu-power": "GPU Gücü", + "gpu-usage": "GPU Usage", "mining-button-text": { "cancel-mining": "Madenciyi İptal Et", "changing-mode": "Mod değiştirme", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index f0baa2673..f6447fb13 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -828,9 +828,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.36" +version = "1.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" +checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" dependencies = [ "jobserver", "libc", diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 1b2107998..5d63dd035 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -10,6 +10,8 @@ "core:menu:default", "core:tray:default", "core:window:allow-close", - "core:window:allow-destroy" + "core:window:allow-destroy", + "core:window:allow-minimize", + "core:window:allow-unminimize" ] } \ No newline at end of file diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 441a26a98..be1502186 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -55,7 +55,6 @@ }, "trayIcon": { "id": "universe-systray", - "title": "hi", "iconPath": "icons/systray_icon.ico" }, "macOSPrivateApi": true, diff --git a/src/App/App.tsx b/src/App/App.tsx index ff89a9786..fafc54229 100644 --- a/src/App/App.tsx +++ b/src/App/App.tsx @@ -1,5 +1,5 @@ import { useShuttingDown } from '@app/hooks/useShuttingDown'; -import { useSystemTray } from '@app/hooks/useSystemTray'; +import { useInitSystemTray } from '@app/hooks/useSystemTray'; import { useAppStateStore } from '@app/store/appStateStore'; import { LazyMotion, domMax, MotionConfig } from 'framer-motion'; @@ -15,7 +15,7 @@ import ThemeProvider from '../theme/ThemeProvider.tsx'; import AppContent from './AppContent'; export default function App() { - useSystemTray(); + useInitSystemTray(); const isShuttingDown = useShuttingDown(); const isSettingUp = useAppStateStore((s) => s.isSettingUp); return ( diff --git a/src/hooks/useSystemTray.ts b/src/hooks/useSystemTray.ts index 0e189ce1a..36ce312d2 100644 --- a/src/hooks/useSystemTray.ts +++ b/src/hooks/useSystemTray.ts @@ -1,11 +1,38 @@ -import { useCallback, useEffect } from 'react'; +import { Menu } from '@tauri-apps/api/menu'; +import { PredefinedMenuItemOptions } from '@tauri-apps/api/menu/predefinedMenuItem'; import { TrayIcon } from '@tauri-apps/api/tray'; -import { Menu, PredefinedMenuItem } from '@tauri-apps/api/menu'; +import { useCallback, useEffect, useRef } from 'react'; -export function useSystemTray() { +import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow'; + +const appWindow = getCurrentWebviewWindow(); +const tray = await TrayIcon.getById('universe-systray'); + +// { +// id: 'unminimize', +// text: 'Unminimize', +// enabled: await appWindow?.isMinimized(), +// action: () => { +// appWindow.unminimize(); +// }, +// }, +// { +// id: 'minimize', +// text: 'Minimize', +// enabled: await appWindow?.isMinimizable(), +// action: () => { +// appWindow.minimize(); +// }, +// }, + +export function useInitSystemTray() { + const initiated = useRef(false); const setMenu = useCallback(async () => { - const separator = await PredefinedMenuItem.new({ item: 'Separator' }); - const menu = await Menu.new({ + const separator = { + item: 'Separator', + } as PredefinedMenuItemOptions; + + return await Menu.new({ items: [ { id: 'cpu_hashrate', @@ -34,26 +61,21 @@ export function useSystemTray() { text: 'Est earning: {} tXTM/day', enabled: false, }, - { - id: 'unminimize', - text: 'Unminimize', - }, ], }); - - return menu; }, []); - const setTray = useCallback(async () => { - const tray = await TrayIcon.getById('universe-systray'); + const setInitialTray = useCallback(async () => { const menu = await setMenu(); if (tray) { - tray.setTitle('fancy systray '); - tray.setIcon('icons/icon.png'); - tray.setMenu(menu); + await tray.setIcon('icons/icon.png'); + await tray.setMenu(menu); } - }, []); + }, [setMenu]); useEffect(() => { - setTray(); - }, []); + if (initiated.current) return; + setInitialTray().then(() => { + initiated.current = true; + }); + }, [setInitialTray]); }