🐛 Fix: fix macos traypage bug

This commit is contained in:
萌萌哒赫萝
2023-04-12 16:22:02 +08:00
parent 9305293a95
commit b20c6d7a85
5 changed files with 220 additions and 12 deletions

View File

@@ -5,9 +5,9 @@ import {
Tray,
dialog,
clipboard,
systemPreferences,
Notification,
screen
screen,
nativeTheme
} from 'electron'
import uploader from 'apis/app/uploader'
import db, { GalleryDB } from '~/main/apis/core/datastore'
@@ -101,14 +101,21 @@ export function createMenu () {
},
{
label: 'Edit',
// @ts-ignore
submenu: [
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z' },
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z' },
// @ts-ignore
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
// @ts-ignore
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
{ type: 'separator' },
{ label: 'Cut', accelerator: 'CmdOrCtrl+X' },
{ label: 'Copy', accelerator: 'CmdOrCtrl+C' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V' },
{ label: 'Select All', accelerator: 'CmdOrCtrl+A' }
// @ts-ignore
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
// @ts-ignore
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
// @ts-ignore
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
// @ts-ignore
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' }
]
},
{
@@ -372,7 +379,7 @@ export function createTray () {
})
tray.on('drag-enter', () => {
if (systemPreferences.isDarkMode()) {
if (nativeTheme.shouldUseDarkColors) {
tray!.setImage(`${__static}/upload-dark.png`)
} else {
tray!.setImage(`${__static}/upload.png`)

View File

@@ -2,7 +2,7 @@ import { IPasteStyle } from '#/types/enum'
import { handleUrlEncode } from '#/utils/common'
import db from '~/main/apis/core/datastore'
const formatCustomLink = (customLink: string, item: ImgInfo) => {
export const formatCustomLink = (customLink: string, item: ImgInfo) => {
const fileName = item.fileName!.replace(new RegExp(`\\${item.extname}$`), '')
const url = item.url || item.imgUrl
const extName = item.extname