fix: 🐛 Fixed the problem of minimizing the visibility of tray icons

This commit is contained in:
viarotel 2024-09-09 18:58:17 +08:00
parent 7435122eb9
commit b0f42aa474
6 changed files with 33 additions and 32 deletions

View File

@ -2,12 +2,14 @@ import { resolve } from 'node:path'
import { contextBridge } from 'electron'
import { cloneDeep } from 'lodash-es'
export const isPackaged = process.env.IS_PACKAGED === 'true'
export const isPackaged = ['true'].includes(process.env.IS_PACKAGED)
export const extraResolve = (value) => {
return isPackaged
? resolve(process.resourcesPath, `extra/${value}`)
: resolve(`electron/resources/extra/${value}`)
export const extraResolve = (filePath) => {
const basePath = isPackaged ? process.resourcesPath : 'electron/resources'
const value = resolve(basePath, 'extra', filePath)
return value
}
export const buildResolve = value =>

View File

@ -8,8 +8,10 @@ if (process.platform === 'darwin') {
fixPath()
}
process.env.IS_PACKAGED = JSON.stringify(app.isPackaged)
process.env.IS_PACKAGED = String(app.isPackaged)
process.env.DESKTOP_PATH = app.getPath('desktop')
process.env.CWD = process.cwd()
export const isPackaged = ['true'].includes(process.env.IS_PACKAGED)

View File

@ -6,17 +6,15 @@ import remote from '@electron/remote/main'
import { electronApp, optimizer } from '@electron-toolkit/utils'
import { app, BrowserWindow, shell } from 'electron'
import contextMenu from 'electron-context-menu'
import { icnsLogoPath, icoLogoPath, logoPath } from './configs/index.js'
import events from './events/index.js'
/** process.js 必须位于非依赖项的顶部 */
import { isPackaged } from './helpers/process.js'
import log from './helpers/log.js'
import './helpers/console.js'
import appStore from './helpers/store.js'
// process.js 必须位于非依赖项的顶部
import './helpers/process.js'
import { icnsLogoPath, icoLogoPath, logoPath } from './configs/index.js'
import './helpers/console.js'
import events from './events/index.js'
const require = createRequire(import.meta.url)
const __dirname = path.dirname(fileURLToPath(import.meta.url))
@ -28,7 +26,7 @@ const debug = !!appStore.get('common.debug')
if (!debug) {
log.warn(
'Debug Tips:',
'If you need to generate and view the running log, please start the debugging function on the preference setting page',
'If you need to generate and view the running log, please start the debugging function on the preference setting page'
)
}
@ -37,7 +35,7 @@ contextMenu({
showSelectAll: false,
showSearchWithGoogle: false,
showSaveImageAs: true,
showInspectElement: !app.isPackaged,
showInspectElement: !isPackaged,
})
// The built directory structure
@ -61,14 +59,13 @@ function createWindow() {
if (process.platform === 'win32') {
icon = icoLogoPath
}
else if (process.platform === 'darwin') {
} else if (process.platform === 'darwin') {
icon = icnsLogoPath
}
mainWindow = new BrowserWindow({
// 这里设置的图标仅在开发模式生效,打包后将使用应用程序图标
...(!app.isPackaged
...(!isPackaged
? {
icon,
}
@ -101,8 +98,7 @@ function createWindow() {
if (VITE_DEV_SERVER_URL) {
mainWindow.loadURL(VITE_DEV_SERVER_URL)
}
else {
} else {
mainWindow.loadFile(path.join(process.env.DIST, 'index.html'))
}

View File

@ -16,6 +16,7 @@ export default antfu(
'dist',
'dist-electron',
'dist-release',
'electron/main.js',
],
},
{
@ -47,6 +48,7 @@ export default antfu(
'no-new': 'off',
'prefer-promise-reject-errors': 'off',
'no-unused-expressions': 'off',
'sort-imports': 'off',
'vue/html-self-closing': 'off',
'vue/block-order': 'off',

View File

@ -25,7 +25,7 @@
"electron-in-page-search": "1.3.2",
"nanoid": "5.0.7",
"pinia-plugin-persistedstate": "3.2.1",
"vue": "3.4.26"
"vue": "3.4.21"
},
"devDependencies": {
"@antfu/eslint-config": "3.3.2",
@ -34,17 +34,17 @@
"@electron-toolkit/utils": "3.0.0",
"@electron/remote": "2.1.2",
"@intlify/unplugin-vue-i18n": "4.0.0",
"@unocss/reset": "0.59.4",
"@unocss/transformer-directives": "0.59.4",
"@unocss/reset": "0.62.3",
"@unocss/transformer-directives": "0.62.3",
"@viarotel-org/unocss-preset-shades": "0.8.2",
"@vitejs/plugin-vue": "5.0.4",
"@vueuse/core": "10.9.0",
"dayjs": "1.11.11",
"electron": "30.0.3",
"electron": "29.1.1",
"electron-builder": "24.13.3",
"electron-context-menu": "4.0.0",
"electron-context-menu": "4.0.4",
"electron-find-in-page": "1.0.8",
"electron-log": "5.1.2",
"electron-log": "5.2.0",
"electron-store": "9.0.0",
"electron-updater": "6.1.8",
"element-plus": "2.8.2",
@ -57,10 +57,10 @@
"postcss": "8.4.38",
"postcss-nested": "6.0.1",
"postcss-scss": "4.0.9",
"unocss": "0.59.4",
"unplugin-auto-import": "0.17.5",
"unplugin-vue-components": "0.27.0",
"vite": "5.2.11",
"unocss": "0.62.3",
"unplugin-auto-import": "0.18.2",
"unplugin-vue-components": "0.27.4",
"vite": "5.1.5",
"vite-plugin-electron": "0.28.7",
"vite-plugin-electron-renderer": "0.14.5",
"vite-svg-loader": "5.1.0",

View File

@ -41,12 +41,11 @@ import { i18n } from '$/locales/index.js'
import localeModel from '$/plugins/element-plus/locale.js'
import { usePreferenceStore } from '$/store/preference/index.js'
import { useThemeStore } from '$/store/theme/index.js'
import { ElMessageBox } from 'element-plus'
import About from './components/About/index.vue'
import Device from './components/Device/index.vue'
import Preference from './components/Preference/index.vue'
import Quick from './components/Quick/index.vue'