mirror of
https://github.com/Molunerfinn/PicGo.git
synced 2024-04-21 10:31:33 +00:00
@@ -1,4 +1,6 @@
|
||||
import { IPasteStyle } from '#/types/enum'
|
||||
import db from 'apis/core/datastore'
|
||||
import { handleUrlEncode } from '~/universal/utils/common'
|
||||
|
||||
const formatCustomLink = (customLink: string, item: ImgInfo) => {
|
||||
const fileName = item.fileName!.replace(new RegExp(`\\${item.extname}$`), '')
|
||||
@@ -20,7 +22,10 @@ const formatCustomLink = (customLink: string, item: ImgInfo) => {
|
||||
}
|
||||
|
||||
export default (style: IPasteStyle, item: ImgInfo, customLink: string | undefined) => {
|
||||
const url = item.url || item.imgUrl
|
||||
let url = item.url || item.imgUrl
|
||||
if (db.get('settings.encodeOutputURL') !== false) {
|
||||
url = handleUrlEncode(url)
|
||||
}
|
||||
const _customLink = customLink || '$url'
|
||||
const tpl = {
|
||||
markdown: ``,
|
||||
|
||||
@@ -232,6 +232,16 @@
|
||||
@change="useBuiltinClipboardChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_ENCODE_OUTPUT_URL')"
|
||||
>
|
||||
<el-switch
|
||||
v-model="form.encodeOutputURL"
|
||||
:active-text="$T('SETTINGS_OPEN')"
|
||||
:inactive-text="$T('SETTINGS_CLOSE')"
|
||||
@change="handleEncodeOutputURL"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:style="{ marginRight: '-64px' }"
|
||||
:label="$T('CHOOSE_SHOWED_PICBED')"
|
||||
@@ -558,7 +568,8 @@ const form = reactive<ISettingForm>({
|
||||
checkBetaUpdate: true,
|
||||
useBuiltinClipboard: false,
|
||||
language: 'zh-CN',
|
||||
logFileSizeLimit: 10
|
||||
logFileSizeLimit: 10,
|
||||
encodeOutputURL: true
|
||||
})
|
||||
|
||||
const languageList = i18nManager.languageList.map(item => ({
|
||||
@@ -643,6 +654,7 @@ async function initData () {
|
||||
form.checkBetaUpdate = settings.checkBetaUpdate === undefined ? true : settings.checkBetaUpdate
|
||||
form.useBuiltinClipboard = settings.useBuiltinClipboard === undefined ? false : settings.useBuiltinClipboard
|
||||
form.language = settings.language ?? 'zh-CN'
|
||||
form.encodeOutputURL = settings.encodeOutputURL === undefined ? true : settings.encodeOutputURL
|
||||
currentLanguage.value = settings.language ?? 'zh-CN'
|
||||
customLink.value = settings.customLink || '$url'
|
||||
shortKey.upload = settings.shortKey.upload
|
||||
@@ -814,6 +826,16 @@ function handleAutoCopyUrl (val: ICheckBoxValueType) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleEncodeOutputURL (val: ICheckBoxValueType) {
|
||||
saveConfig('settings.encodeOutputURL', val)
|
||||
const successNotification = new Notification($T('SETTINGS_ENCODE_OUTPUT_URL'), {
|
||||
body: $T('TIPS_SET_SUCCEED')
|
||||
})
|
||||
successNotification.onclick = () => {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
function confirmLogLevelSetting () {
|
||||
if (form.logLevel.length === 0) {
|
||||
return $message.error($T('TIPS_PLEASE_CHOOSE_LOG_LEVEL'))
|
||||
|
||||
Vendored
+1
@@ -109,6 +109,7 @@ interface ILocales {
|
||||
UPLOADER_CONFIG_NAME: string
|
||||
UPLOADER_CONFIG_PLACEHOLDER: string
|
||||
SELECTED_SETTING_HINT: string
|
||||
SETTINGS_ENCODE_OUTPUT_URL: string
|
||||
SHORTCUT_NAME: string
|
||||
SHORTCUT_BIND: string
|
||||
SHORTCUT_STATUS: string
|
||||
|
||||
Vendored
+1
@@ -12,6 +12,7 @@ interface ISettingForm {
|
||||
useBuiltinClipboard: boolean
|
||||
language: string
|
||||
logFileSizeLimit: number
|
||||
encodeOutputURL: boolean
|
||||
}
|
||||
|
||||
interface IShortKeyMap {
|
||||
|
||||
@@ -5,7 +5,7 @@ export const isUrlEncode = (url: string): boolean => {
|
||||
return url !== decodeURI(url)
|
||||
} catch (e) {
|
||||
// if some error caught, try to let it go
|
||||
return true
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user