mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-23 01:00:35 +08:00
✨ Feature: optimize url encode and filename encode
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import fs from 'fs-extra'
|
||||
import db from '~/main/apis/core/datastore'
|
||||
import { clipboard, Notification, dialog } from 'electron'
|
||||
import { handleUrlEncode } from '~/universal/utils/common'
|
||||
|
||||
export const handleCopyUrl = (str: string): void => {
|
||||
if (db.get('settings.autoCopy') !== false) {
|
||||
@@ -110,3 +111,5 @@ export const getClipboardFilePath = (): string => {
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export const handleUrlEncodeWithSetting = (url: string) => db.get('settings.encodeOutputURL') ? handleUrlEncode(url) : url
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { IPasteStyle } from '#/types/enum'
|
||||
import { handleUrlEncode, generateShortUrl } from '#/utils/common'
|
||||
import { generateShortUrl } from '#/utils/common'
|
||||
import db from '~/main/apis/core/datastore'
|
||||
import { handleUrlEncodeWithSetting } from './common'
|
||||
|
||||
export const formatCustomLink = (customLink: string, item: ImgInfo) => {
|
||||
const fileName = item.fileName!.replace(new RegExp(`\\${item.extname}$`), '')
|
||||
@@ -23,9 +24,7 @@ export const formatCustomLink = (customLink: string, item: ImgInfo) => {
|
||||
|
||||
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)
|
||||
}
|
||||
url = handleUrlEncodeWithSetting(item.url || item.imgUrl)
|
||||
const useShortUrl = db.get('settings.useShortUrl') || false
|
||||
if (useShortUrl) {
|
||||
url = await generateShortUrl(url)
|
||||
|
||||
Reference in New Issue
Block a user