mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-28 02:52:16 +08:00
✨ Feature: optimize url encode and filename encode
This commit is contained in:
@@ -68,7 +68,7 @@
|
||||
"mime-types": "^2.1.35",
|
||||
"mitt": "^3.0.0",
|
||||
"nodejs-file-downloader": "^4.10.6",
|
||||
"piclist": "^0.5.4",
|
||||
"piclist": "^0.6.0",
|
||||
"pinia": "^2.0.32",
|
||||
"pinia-plugin-persistedstate": "^3.1.0",
|
||||
"qiniu": "^7.8.0",
|
||||
|
||||
@@ -7,8 +7,7 @@ import { IWindowList } from '#/types/enum'
|
||||
import uploader from '.'
|
||||
import pasteTemplate from '~/main/utils/pasteTemplate'
|
||||
import db, { GalleryDB } from '~/main/apis/core/datastore'
|
||||
import { handleCopyUrl } from '~/main/utils/common'
|
||||
import { handleUrlEncode } from '#/utils/common'
|
||||
import { handleCopyUrl, handleUrlEncodeWithSetting } from '~/main/utils/common'
|
||||
import { T } from '~/main/i18n/index'
|
||||
import ALLApi from '@/apis/allApi'
|
||||
import picgo from '@core/picgo'
|
||||
@@ -49,7 +48,7 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery')
|
||||
}
|
||||
return {
|
||||
url: handleUrlEncode(img[0].imgUrl as string),
|
||||
url: handleUrlEncodeWithSetting(img[0].imgUrl as string),
|
||||
fullResult: img[0]
|
||||
}
|
||||
} else {
|
||||
@@ -99,7 +98,7 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW
|
||||
}, i * 100)
|
||||
await GalleryDB.getInstance().insert(imgs[i])
|
||||
result.push({
|
||||
url: handleUrlEncode(imgs[i].imgUrl!),
|
||||
url: handleUrlEncodeWithSetting(imgs[i].imgUrl!),
|
||||
fullResult: imgs[i]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1282,7 +1282,7 @@ const form = reactive<ISettingForm>({
|
||||
customMiniIcon: '',
|
||||
isHideDock: false,
|
||||
autoImport: false,
|
||||
encodeOutputURL: true,
|
||||
encodeOutputURL: false,
|
||||
isAutoListenClipboard: false,
|
||||
useShortUrl: false,
|
||||
deleteLocalFile: false
|
||||
@@ -1421,7 +1421,7 @@ async function initData () {
|
||||
form.useBuiltinClipboard = settings.useBuiltinClipboard === undefined ? true : settings.useBuiltinClipboard
|
||||
form.isAutoListenClipboard = settings.isAutoListenClipboard || false
|
||||
form.language = settings.language ?? 'zh-CN'
|
||||
form.encodeOutputURL = settings.encodeOutputURL === undefined ? true : settings.encodeOutputURL
|
||||
form.encodeOutputURL = settings.encodeOutputURL === undefined ? false : settings.encodeOutputURL
|
||||
form.deleteCloudFile = settings.deleteCloudFile || false
|
||||
form.autoImport = settings.autoImport || false
|
||||
form.isCustomMiniIcon = settings.isCustomMiniIcon || false
|
||||
|
||||
@@ -123,7 +123,7 @@ 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) {
|
||||
if ((await getConfig('settings.encodeOutputURL')) === true) {
|
||||
url = handleUrlEncode(url)
|
||||
}
|
||||
const useShortUrl = await getConfig('settings.useShortUrl') || false
|
||||
|
||||
10
yarn.lock
10
yarn.lock
@@ -11095,10 +11095,10 @@ performance-now@^2.1.0:
|
||||
resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||
integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==
|
||||
|
||||
piclist@^0.5.4:
|
||||
version "0.5.4"
|
||||
resolved "https://registry.npmjs.org/piclist/-/piclist-0.5.4.tgz#ca28e0c561ab62bbeb12a144377bbe3bab0dba12"
|
||||
integrity sha512-5cVpGs9uPV72FInR7/kvrIQXYRM6bRaAVpd8iul8eZFJUosIDplfBCm+PPrWCeXvaJPkQw7CnO2OEjkL+rXWxA==
|
||||
piclist@^0.6.0:
|
||||
version "0.6.0"
|
||||
resolved "https://registry.npmjs.org/piclist/-/piclist-0.6.0.tgz#ad03c205736381df34469c079307283d0eae16e4"
|
||||
integrity sha512-PgaH3rtmOzxfBMfxPzgdtjulkvZ1voRlZK2BJoPDaOIcm5rHF77/n8GRWTlXxS32XqtXJKbdq0hLvOYVDmxW0Q==
|
||||
dependencies:
|
||||
"@picgo/i18n" "^1.0.0"
|
||||
"@picgo/store" "^2.0.4"
|
||||
@@ -11683,7 +11683,7 @@ qiniu@^7.8.0:
|
||||
tunnel-agent "^0.6.0"
|
||||
urllib "^2.34.1"
|
||||
|
||||
qrcode.vue@^3.4.0:
|
||||
qrcode.vue@^3.3.3:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.npmjs.org/qrcode.vue/-/qrcode.vue-3.4.0.tgz#4513ff1a4734cb7184086c2fd439f0d462c6d281"
|
||||
integrity sha512-4XeImbv10Fin16Fl2DArCMhGyAdvIg2jb7vDT+hZiIAMg/6H6mz9nUZr/dR8jBcun5VzNzkiwKhiqOGbloinwA==
|
||||
|
||||
Reference in New Issue
Block a user