Skip to content

Commit

Permalink
Fix: 初次登录托盘状态错误
Browse files Browse the repository at this point in the history
  • Loading branch information
KiWi233333 committed Nov 9, 2024
1 parent 1974cbc commit 7d7c897
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions composables/tauri/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export async function useFlashTray() {
const onlineUrl = await resolveResource("./res/online.png");
const offlineUrl = await resolveResource("./res/offline.png");
const msgUrl = await resolveResource("./res/msg.png");
console.log("tray icon urls", onlineUrl, offlineUrl, msgUrl);

async function setTrayIcon(icon: string | null) {
const tray = await TrayIcon.getById(TrayIconId).catch((err) => {
console.error("获取托盘图标失败", err);
Expand Down Expand Up @@ -73,6 +71,12 @@ export async function useFlashTray() {
}
};

watch(activeIcon, (newVal, oldVal) => {
if (newVal === oldVal)
return;
setTrayIcon(newVal);
}, { immediate: true });

return {
iconUrl,
onlineUrl,
Expand Down
2 changes: 1 addition & 1 deletion init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export async function useMsgBoxWebViewInit() {
immediate: true,
debounce: 300,
});
watch(() => user.isLogin, async (newVal, oldVal) => {
watch(() => user.isLogin, (newVal, oldVal) => {
activeIcon.value = newVal ? onlineUrl : offlineUrl;
}, {
immediate: true,
Expand Down

0 comments on commit 7d7c897

Please sign in to comment.