diff --git a/.github/workflows/manually.yml b/.github/workflows/manually.yml deleted file mode 100644 index 30ef4803..00000000 --- a/.github/workflows/manually.yml +++ /dev/null @@ -1,58 +0,0 @@ -# main.yml - -# Workflow's name -name: Manually Build - -# Workflow's trigger -on: workflow_dispatch - -# 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, macos-11] - - # create steps - steps: - # step1: check out repository - - name: Check out git repository - uses: actions/checkout@v2 - - # step2: 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 - 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 }} diff --git a/public/i18n/en.yml b/public/i18n/en.yml index cca3863e..4ad14bd3 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -109,7 +109,8 @@ UPLOAD_PAGE_IMAGE_PROCESS_POSITION_TOP_RIGHT: top right UPLOAD_PAGE_IMAGE_PROCESS_POSITION_BOTTOM_LEFT: bottom left UPLOAD_PAGE_IMAGE_PROCESS_POSITION_BOTTOM_RIGHT: bottom right UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER: center - +UPLOAD_SHORT_URL: 短链接 +UPLOAD_NORMAL_URL: 长链接 # settings SETTINGS: Settings @@ -195,6 +196,7 @@ SETTINGS_ISHIDEDOCK: Hide Dock Icon SETTINGS_ISHIDEDOCK_TIPS: Not support hide dock and tray at the same time SETTINGS_ENCODE_OUTPUT_URL: Encode Output(or Copyed) URL SETTINGS_WATCH_CLIPBOARD: Watch clipboard when software start +SETTINGS_SHORT_URL: Use short url # shortcut-page BUILTIN_CLIPBOARD_TIPS: Use builtin clipboard function to upload instead of using scripts diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index 0650d945..98d2e501 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -108,6 +108,9 @@ UPLOAD_PAGE_IMAGE_PROCESS_POSITION_TOP_RIGHT: 右上 UPLOAD_PAGE_IMAGE_PROCESS_POSITION_BOTTOM_LEFT: 左下 UPLOAD_PAGE_IMAGE_PROCESS_POSITION_BOTTOM_RIGHT: 右下 UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER: 中 +UPLOAD_SHORT_URL: 短链接 +UPLOAD_NORMAL_URL: 长链接 + # settings @@ -195,6 +198,7 @@ SETTINGS_ISHIDEDOCK: 是否隐藏dock图标 SETTINGS_ISHIDEDOCK_TIPS: 不支持同时隐藏dock和托盘 SETTINGS_ENCODE_OUTPUT_URL: 输出(复制) URL 时进行转义 SETTINGS_WATCH_CLIPBOARD: 软件启动时自动监听剪贴板上传 +SETTINGS_SHORT_URL: 使用短链接 # shortcut-page SHORTCUT_NAME: 快捷键名称 diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index 42e5bc2f..1ca0cc88 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -108,7 +108,8 @@ UPLOAD_PAGE_IMAGE_PROCESS_POSITION_TOP_RIGHT: 右上 UPLOAD_PAGE_IMAGE_PROCESS_POSITION_BOTTOM_LEFT: 左下 UPLOAD_PAGE_IMAGE_PROCESS_POSITION_BOTTOM_RIGHT: 右下 UPLOAD_PAGE_IMAGE_PROCESS_POSITION_CENTER: 中 - +UPLOAD_SHORT_URL: 短链接 +UPLOAD_NORMAL_URL: 长链接 # settings SETTINGS: 設定 @@ -195,6 +196,7 @@ SETTINGS_ISHIDEDOCK: 是否隱藏dock圖示 SETTINGS_ISHIDEDOCK_TIPS: 不支持同時隱藏dock和托盘 SETTINGS_ENCODE_OUTPUT_URL: 輸出(複製) URL 時進行轉義 SETTINGS_WATCH_CLIPBOARD: 軟體啟動時自動監聽剪貼簿上傳 +SETTINGS_SHORT_URL: 使用短網址 # shortcut-page SHORTCUT_NAME: 快捷鍵名稱 diff --git a/src/main/apis/app/system/index.ts b/src/main/apis/app/system/index.ts index 60d5d971..c0fea692 100644 --- a/src/main/apis/app/system/index.ts +++ b/src/main/apis/app/system/index.ts @@ -401,7 +401,7 @@ export function createTray () { if (imgs !== false) { const pasteText: string[] = [] for (let i = 0; i < imgs.length; i++) { - pasteText.push(pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink'))) + pasteText.push(await (pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))) const notification = new Notification({ title: T('UPLOAD_SUCCEED'), body: imgs[i].imgUrl! diff --git a/src/main/apis/app/uploader/apis.ts b/src/main/apis/app/uploader/apis.ts index 78122873..8b765824 100644 --- a/src/main/apis/app/uploader/apis.ts +++ b/src/main/apis/app/uploader/apis.ts @@ -30,7 +30,7 @@ export const uploadClipboardFiles = async (): Promise => { if (img.length > 0) { const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW) const pasteStyle = db.get('settings.pasteStyle') || 'markdown' - handleCopyUrl(pasteTemplate(pasteStyle, img[0], db.get('settings.customLink'))) + handleCopyUrl(await (pasteTemplate(pasteStyle, img[0], db.get('settings.customLink')))) const notification = new Notification({ title: T('UPLOAD_SUCCEED'), body: img[0].imgUrl! @@ -77,7 +77,7 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW const pasteStyle = db.get('settings.pasteStyle') || 'markdown' const pasteText: string[] = [] for (let i = 0; i < imgs.length; i++) { - pasteText.push(pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink'))) + pasteText.push(await (pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))) const notification = new Notification({ title: T('UPLOAD_SUCCEED'), body: imgs[i].imgUrl! diff --git a/src/main/apis/gui/index.ts b/src/main/apis/gui/index.ts index 977cafca..f65e5f25 100644 --- a/src/main/apis/gui/index.ts +++ b/src/main/apis/gui/index.ts @@ -81,7 +81,7 @@ class GuiApi implements IGuiApi { const pasteStyle = db.get('settings.pasteStyle') || 'markdown' const pasteText: string[] = [] for (let i = 0; i < imgs.length; i++) { - pasteText.push(pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink'))) + pasteText.push(await (pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))) const notification = new Notification({ title: T('UPLOAD_SUCCEED'), body: imgs[i].imgUrl as string diff --git a/src/main/events/ipcList.ts b/src/main/events/ipcList.ts index 49b4894b..36fc3e80 100644 --- a/src/main/events/ipcList.ts +++ b/src/main/events/ipcList.ts @@ -55,7 +55,7 @@ export default { const img = await uploader.setWebContents(trayWindow.webContents).uploadWithBuildInClipboard() if (img !== false) { const pasteStyle = db.get('settings.pasteStyle') || 'markdown' - handleCopyUrl(pasteTemplate(pasteStyle, img[0], db.get('settings.customLink'))) + handleCopyUrl(await (pasteTemplate(pasteStyle, img[0], db.get('settings.customLink')))) const notification = new Notification({ title: T('UPLOAD_SUCCEED'), body: img[0].imgUrl! diff --git a/src/main/events/picgoCoreIPC.ts b/src/main/events/picgoCoreIPC.ts index 16ebf539..c6d12aeb 100644 --- a/src/main/events/picgoCoreIPC.ts +++ b/src/main/events/picgoCoreIPC.ts @@ -346,7 +346,7 @@ const handlePicGoGalleryDB = () => { ipcMain.handle(PASTE_TEXT, async (_, item: ImgInfo, copy = true) => { const pasteStyle = picgo.getConfig('settings.pasteStyle') || IPasteStyle.MARKDOWN const customLink = picgo.getConfig('settings.customLink') - const txt = pasteTemplate(pasteStyle, item, customLink) + const txt = await pasteTemplate(pasteStyle, item, customLink) if (copy) { clipboard.writeText(txt) } diff --git a/src/main/utils/pasteTemplate.ts b/src/main/utils/pasteTemplate.ts index fb6beb1b..89677dd1 100644 --- a/src/main/utils/pasteTemplate.ts +++ b/src/main/utils/pasteTemplate.ts @@ -1,5 +1,5 @@ import { IPasteStyle } from '#/types/enum' -import { handleUrlEncode } from '#/utils/common' +import { handleUrlEncode, generateShortUrl } from '#/utils/common' import db from '~/main/apis/core/datastore' export const formatCustomLink = (customLink: string, item: ImgInfo) => { @@ -21,11 +21,15 @@ export const formatCustomLink = (customLink: string, item: ImgInfo) => { return customLink } -export default (style: IPasteStyle, item: ImgInfo, customLink: string | undefined) => { +export default async (style: IPasteStyle, item: ImgInfo, customLink: string | undefined) => { let url = item.url || item.imgUrl if (db.get('settings.encodeOutputURL') !== false) { url = handleUrlEncode(url) } + const useShortUrl = db.get('settings.useShortUrl') || false + if (useShortUrl) { + url = await generateShortUrl(url) + } const _customLink = customLink || '![$fileName]($url)' const tpl = { markdown: `![](${url})`, diff --git a/src/main/utils/privacyManager.ts b/src/main/utils/privacyManager.ts index f041411d..e5cf201a 100644 --- a/src/main/utils/privacyManager.ts +++ b/src/main/utils/privacyManager.ts @@ -11,7 +11,6 @@ class PrivacyManager { return false } else { db.set('settings.privacyEnsure', true) - return true } } return true diff --git a/src/renderer/pages/Gallery.vue b/src/renderer/pages/Gallery.vue index c8404624..425d2ad8 100644 --- a/src/renderer/pages/Gallery.vue +++ b/src/renderer/pages/Gallery.vue @@ -31,7 +31,7 @@ class="handle-bar" :gutter="16" > - + - + + + + + + - + + + +
('') +const shortURLMap = { + [$T('UPLOAD_SHORT_URL')]: $T('UPLOAD_SHORT_URL'), + [$T('UPLOAD_NORMAL_URL')]: $T('UPLOAD_NORMAL_URL') +} const fileSortNameReverse = ref(false) const fileSortTimeReverse = ref(false) const fileSortExtReverse = ref(false) @@ -835,6 +863,11 @@ async function handlePasteStyleChange (val: string) { pasteStyle.value = val } +function handleUseShortUrlChange (value: string) { + saveConfig('settings.useShortUrl', value === $T('UPLOAD_SHORT_URL')) + useShortUrl.value = value +} + function sortFile (type: 'name' | 'time' | 'ext' | 'check') { switch (type) { case 'name': @@ -954,6 +987,7 @@ onBeforeUnmount(() => { onActivated(async () => { pasteStyle.value = (await getConfig('settings.pasteStyle')) || 'markdown' + useShortUrl.value = (await getConfig('settings.useShortUrl') ? $T('UPLOAD_SHORT_URL') : $T('UPLOAD_NORMAL_URL')) initDeleteCloud() }) diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index 443f22cb..766c5cb5 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -312,6 +312,16 @@ @change="handleAutoCopyUrl" /> + + +