mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-05 23:47:43 +08:00
🐛 Fix: fix macos traypage bug
This commit is contained in:
@@ -0,0 +1,92 @@
|
|||||||
|
# main.yml
|
||||||
|
|
||||||
|
# Workflow's name
|
||||||
|
name: Linux Build
|
||||||
|
|
||||||
|
# Workflow's trigger
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
ELECTRON_OUTPUT_PATH: ./dist_electron
|
||||||
|
CSC_LINK: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
|
||||||
|
CSC_KEY_PASSWORD: ${{ secrets.P12_PASSWORD }}
|
||||||
|
|
||||||
|
# Workflow's jobs
|
||||||
|
jobs:
|
||||||
|
# job's id
|
||||||
|
release:
|
||||||
|
# job's name
|
||||||
|
name: build and release electron app
|
||||||
|
|
||||||
|
# the type of machine to run the job on
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
# create a build matrix for jobs
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
|
||||||
|
# create steps
|
||||||
|
steps:
|
||||||
|
# step1: check out repository
|
||||||
|
- name: Check out git repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# step2: sign
|
||||||
|
- name: Install the Apple certificates
|
||||||
|
if: matrix.os == 'macos-11'
|
||||||
|
run: |
|
||||||
|
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
|
||||||
|
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
|
||||||
|
|
||||||
|
# step3: install node env
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16.x'
|
||||||
|
|
||||||
|
- name: Install system deps
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
run: |
|
||||||
|
sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils
|
||||||
|
|
||||||
|
# step3: yarn
|
||||||
|
- name: Yarn install macos
|
||||||
|
if: matrix.os == 'macos-11'
|
||||||
|
run: |
|
||||||
|
yarn
|
||||||
|
yarn global add xvfb-maybe
|
||||||
|
npm rebuild --platform=darwin --arch=arm64 sharp
|
||||||
|
|
||||||
|
- name: Yarn install windows
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: |
|
||||||
|
yarn
|
||||||
|
yarn global add xvfb-maybe
|
||||||
|
|
||||||
|
- name: Yarn install linux
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
run: |
|
||||||
|
yarn
|
||||||
|
yarn global add xvfb-maybe
|
||||||
|
|
||||||
|
- name: Build & release app
|
||||||
|
run: |
|
||||||
|
yarn release
|
||||||
|
yarn upload-dist
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
R2_SECRET_ID: ${{ secrets.R2_SECRET_ID }}
|
||||||
|
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
|
||||||
|
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
|
||||||
|
ELECTRON_SKIP_NOTARIZATION: ${{ secrets.ELECTRON_SKIP_NOTARIZATION }}
|
||||||
|
XCODE_APP_LOADER_EMAIL: ${{ secrets.XCODE_APP_LOADER_EMAIL }}
|
||||||
|
XCODE_APP_LOADER_PASSWORD: ${{ secrets.XCODE_APP_LOADER_PASSWORD }}
|
||||||
|
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
|
||||||
|
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
|
||||||
|
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
|
||||||
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
# main.yml
|
||||||
|
|
||||||
|
# Workflow's name
|
||||||
|
name: Win Build
|
||||||
|
|
||||||
|
# Workflow's trigger
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
ELECTRON_OUTPUT_PATH: ./dist_electron
|
||||||
|
CSC_LINK: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
|
||||||
|
CSC_KEY_PASSWORD: ${{ secrets.P12_PASSWORD }}
|
||||||
|
|
||||||
|
# Workflow's jobs
|
||||||
|
jobs:
|
||||||
|
# job's id
|
||||||
|
release:
|
||||||
|
# job's name
|
||||||
|
name: build and release electron app
|
||||||
|
|
||||||
|
# the type of machine to run the job on
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
# create a build matrix for jobs
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [windows-latest]
|
||||||
|
|
||||||
|
# create steps
|
||||||
|
steps:
|
||||||
|
# step1: check out repository
|
||||||
|
- name: Check out git repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# step2: sign
|
||||||
|
- name: Install the Apple certificates
|
||||||
|
if: matrix.os == 'macos-11'
|
||||||
|
run: |
|
||||||
|
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
|
||||||
|
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
|
||||||
|
|
||||||
|
# step3: install node env
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16.x'
|
||||||
|
|
||||||
|
- name: Install system deps
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
run: |
|
||||||
|
sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils
|
||||||
|
|
||||||
|
# step3: yarn
|
||||||
|
- name: Yarn install macos
|
||||||
|
if: matrix.os == 'macos-11'
|
||||||
|
run: |
|
||||||
|
yarn
|
||||||
|
yarn global add xvfb-maybe
|
||||||
|
npm rebuild --platform=darwin --arch=arm64 sharp
|
||||||
|
|
||||||
|
- name: Yarn install windows
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: |
|
||||||
|
yarn
|
||||||
|
yarn global add xvfb-maybe
|
||||||
|
|
||||||
|
- name: Yarn install linux
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
run: |
|
||||||
|
yarn
|
||||||
|
yarn global add xvfb-maybe
|
||||||
|
|
||||||
|
- name: Build & release app
|
||||||
|
run: |
|
||||||
|
yarn release
|
||||||
|
yarn upload-dist
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
R2_SECRET_ID: ${{ secrets.R2_SECRET_ID }}
|
||||||
|
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
|
||||||
|
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
|
||||||
|
ELECTRON_SKIP_NOTARIZATION: ${{ secrets.ELECTRON_SKIP_NOTARIZATION }}
|
||||||
|
XCODE_APP_LOADER_EMAIL: ${{ secrets.XCODE_APP_LOADER_EMAIL }}
|
||||||
|
XCODE_APP_LOADER_PASSWORD: ${{ secrets.XCODE_APP_LOADER_PASSWORD }}
|
||||||
|
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
|
||||||
|
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
|
||||||
|
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
|
||||||
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
||||||
@@ -5,9 +5,9 @@ import {
|
|||||||
Tray,
|
Tray,
|
||||||
dialog,
|
dialog,
|
||||||
clipboard,
|
clipboard,
|
||||||
systemPreferences,
|
|
||||||
Notification,
|
Notification,
|
||||||
screen
|
screen,
|
||||||
|
nativeTheme
|
||||||
} from 'electron'
|
} from 'electron'
|
||||||
import uploader from 'apis/app/uploader'
|
import uploader from 'apis/app/uploader'
|
||||||
import db, { GalleryDB } from '~/main/apis/core/datastore'
|
import db, { GalleryDB } from '~/main/apis/core/datastore'
|
||||||
@@ -101,14 +101,21 @@ export function createMenu () {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
|
// @ts-ignore
|
||||||
submenu: [
|
submenu: [
|
||||||
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z' },
|
// @ts-ignore
|
||||||
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z' },
|
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
|
||||||
|
// @ts-ignore
|
||||||
|
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: 'Cut', accelerator: 'CmdOrCtrl+X' },
|
// @ts-ignore
|
||||||
{ label: 'Copy', accelerator: 'CmdOrCtrl+C' },
|
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
|
||||||
{ label: 'Paste', accelerator: 'CmdOrCtrl+V' },
|
// @ts-ignore
|
||||||
{ label: 'Select All', accelerator: 'CmdOrCtrl+A' }
|
{ 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', () => {
|
tray.on('drag-enter', () => {
|
||||||
if (systemPreferences.isDarkMode()) {
|
if (nativeTheme.shouldUseDarkColors) {
|
||||||
tray!.setImage(`${__static}/upload-dark.png`)
|
tray!.setImage(`${__static}/upload-dark.png`)
|
||||||
} else {
|
} else {
|
||||||
tray!.setImage(`${__static}/upload.png`)
|
tray!.setImage(`${__static}/upload.png`)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { IPasteStyle } from '#/types/enum'
|
|||||||
import { handleUrlEncode } from '#/utils/common'
|
import { handleUrlEncode } from '#/utils/common'
|
||||||
import db from '~/main/apis/core/datastore'
|
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 fileName = item.fileName!.replace(new RegExp(`\\${item.extname}$`), '')
|
||||||
const url = item.url || item.imgUrl
|
const url = item.url || item.imgUrl
|
||||||
const extName = item.extname
|
const extName = item.extname
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ import { IResult } from '@picgo/store/dist/types'
|
|||||||
import { OPEN_WINDOW } from '#/events/constants'
|
import { OPEN_WINDOW } from '#/events/constants'
|
||||||
import { IPasteStyle, IWindowList } from '#/types/enum'
|
import { IPasteStyle, IWindowList } from '#/types/enum'
|
||||||
import { getConfig, sendToMain } from '@/utils/dataSender'
|
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 files = ref<IResult<ImgInfo>[]>([])
|
||||||
const notification = reactive({
|
const notification = reactive({
|
||||||
@@ -95,7 +96,7 @@ async function copyTheLink (item: ImgInfo) {
|
|||||||
notification.body = item.imgUrl!
|
notification.body = item.imgUrl!
|
||||||
const pasteStyle = await getConfig<IPasteStyle>('settings.pasteStyle') || IPasteStyle.MARKDOWN
|
const pasteStyle = await getConfig<IPasteStyle>('settings.pasteStyle') || IPasteStyle.MARKDOWN
|
||||||
const customLink = await getConfig<string>('settings.customLink')
|
const customLink = await getConfig<string>('settings.customLink')
|
||||||
const txt = pasteTemplate(pasteStyle, item, customLink)
|
const txt = await pasteTemplate(pasteStyle, item, customLink)
|
||||||
clipboard.writeText(txt)
|
clipboard.writeText(txt)
|
||||||
const myNotification = new Notification(notification.title, notification)
|
const myNotification = new Notification(notification.title, notification)
|
||||||
myNotification.onclick = () => {
|
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 {
|
// function calcHeight (width: number, height: number): number {
|
||||||
// return height * 160 / width
|
// return height * 160 / width
|
||||||
// }
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user