Skip to content

Commit

Permalink
托盘和窗口优化
Browse files Browse the repository at this point in the history
  • Loading branch information
xianyunleo committed Feb 4, 2024
1 parent 8a2423f commit e7fb626
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/renderer/components/SideBar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="sidebar">
<div class="draggable"></div>
<div class="draggable" @dblclick="dblclick"></div>
<div class="logo-container">
<img src="@/renderer/assets/img/icons/icon-trans.png" alt="icon" />
</div>
Expand Down Expand Up @@ -44,6 +44,12 @@ import {defineAsyncComponent, ref} from 'vue'
import {useRouter} from "vue-router";
const router = useRouter();
const selectedKeys = ref(['/']);
import { getCurrentWindow, switchMaximize } from '@/shared/utils/window'
import { isWindows } from '@/main/utils/utils'
const dblclick = () => {
if (!isWindows) switchMaximize(getCurrentWindow())
}
const AMenu = defineAsyncComponent(() => {
return new Promise((resolve) => {
Expand Down
14 changes: 7 additions & 7 deletions src/renderer/components/TitleBar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class='title-bar draggable'>
<div class='title-bar draggable' @dblclick="dblclick">
<div class='notify color-text'>
{{ APP_NAME }} {{ t('notice') }}:<a class='non-draggable color-text' @click='clickUrl'>🎉{{ t('none') }}</a>
</div>
Expand Down Expand Up @@ -31,7 +31,7 @@ import Native from '@/main/utils/Native'
import { t } from '@/shared/utils/i18n'
import { isWindows } from '@/main/utils/utils'
import { APP_NAME } from '@/shared/utils/constant'
import { getCurrentWindow } from '@electron/remote'
import { getCurrentWindow, switchMaximize } from '@/shared/utils/window'
const mainWindow = getCurrentWindow()
const isWindowMax = ref(false)
Expand All @@ -46,12 +46,12 @@ const minimizeClick = () => {
minimizeIsHover.value = false
}
const dblclick = () => {
if (!isWindows) maximizeClick()
}
const maximizeClick = () => {
if (mainWindow.isMaximized()) {
mainWindow.unmaximize()
} else {
mainWindow.maximize()
}
switchMaximize(mainWindow)
}
const closeClick = () => {
Expand Down
13 changes: 13 additions & 0 deletions src/shared/utils/window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getCurrentWindow as getCurrentWindowByRemote } from '@electron/remote'

export function getCurrentWindow() {
return getCurrentWindowByRemote()
}

export function switchMaximize(mainWindow) {
if (mainWindow.isMaximized()) {
mainWindow.unmaximize()
} else {
mainWindow.maximize()
}
}

0 comments on commit e7fb626

Please sign in to comment.