mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-25 18:20:24 +08:00
🐛 Fix: fix macos traypage bug
This commit is contained in:
@@ -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`)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -70,7 +70,8 @@ import { IResult } from '@picgo/store/dist/types'
|
||||
import { OPEN_WINDOW } from '#/events/constants'
|
||||
import { IPasteStyle, IWindowList } from '#/types/enum'
|
||||
import { getConfig, sendToMain } from '@/utils/dataSender'
|
||||
import pasteTemplate from '~/main/utils/pasteTemplate'
|
||||
import { formatCustomLink } from '~/main/utils/pasteTemplate'
|
||||
import { handleUrlEncode } from '#/utils/common'
|
||||
|
||||
const files = ref<IResult<ImgInfo>[]>([])
|
||||
const notification = reactive({
|
||||
@@ -95,7 +96,7 @@ async function copyTheLink (item: ImgInfo) {
|
||||
notification.body = item.imgUrl!
|
||||
const pasteStyle = await getConfig<IPasteStyle>('settings.pasteStyle') || IPasteStyle.MARKDOWN
|
||||
const customLink = await getConfig<string>('settings.customLink')
|
||||
const txt = pasteTemplate(pasteStyle, item, customLink)
|
||||
const txt = await pasteTemplate(pasteStyle, item, customLink)
|
||||
clipboard.writeText(txt)
|
||||
const myNotification = new Notification(notification.title, notification)
|
||||
myNotification.onclick = () => {
|
||||
@@ -103,6 +104,22 @@ async function copyTheLink (item: ImgInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
async function pasteTemplate (style: IPasteStyle, item: ImgInfo, customLink: string | undefined) {
|
||||
let url = item.url || item.imgUrl
|
||||
if ((await getConfig('settings.encodeOutputURL')) !== false) {
|
||||
url = handleUrlEncode(url)
|
||||
}
|
||||
const _customLink = customLink || ''
|
||||
const tpl = {
|
||||
markdown: ``,
|
||||
HTML: `<img src="${url}"/>`,
|
||||
URL: url,
|
||||
UBB: `[IMG]${url}[/IMG]`,
|
||||
Custom: formatCustomLink(_customLink, item)
|
||||
}
|
||||
return tpl[style]
|
||||
}
|
||||
|
||||
// function calcHeight (width: number, height: number): number {
|
||||
// return height * 160 / width
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user