mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-26 10:40:26 +08:00
✨ Feature: add url encode setting
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { IPasteStyle } from '#/types/enum'
|
||||
import { handleUrlEncode } from '#/utils/common'
|
||||
import db from 'apis/core/datastore'
|
||||
|
||||
const formatCustomLink = (customLink: string, item: ImgInfo) => {
|
||||
const fileName = item.fileName!.replace(new RegExp(`\\${item.extname}$`), '')
|
||||
@@ -21,8 +22,11 @@ const formatCustomLink = (customLink: string, item: ImgInfo) => {
|
||||
}
|
||||
|
||||
export default (style: IPasteStyle, item: ImgInfo, customLink: string | undefined) => {
|
||||
const url = handleUrlEncode(item.url || item.imgUrl)
|
||||
const _customLink = customLink || '$url'
|
||||
let url = item.url || item.imgUrl
|
||||
if (db.get('settings.encodeOutputURL') !== false) {
|
||||
url = handleUrlEncode(url)
|
||||
}
|
||||
const _customLink = customLink || ''
|
||||
const tpl = {
|
||||
markdown: ``,
|
||||
HTML: `<img src="${url}"/>`,
|
||||
|
||||
@@ -335,6 +335,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')"
|
||||
@@ -1040,7 +1050,8 @@ const form = reactive<ISettingForm>({
|
||||
deleteCloudFile: false,
|
||||
isCustomMiniIcon: false,
|
||||
customMiniIcon: '',
|
||||
isHideDock: false
|
||||
isHideDock: false,
|
||||
encodeOutputURL: true
|
||||
})
|
||||
|
||||
const languageList = i18nManager.languageList.map(item => ({
|
||||
@@ -1061,7 +1072,7 @@ const proxyVisible = ref(false)
|
||||
const mainWindowSizeVisible = ref(false)
|
||||
|
||||
const customLink = reactive({
|
||||
value: '$url'
|
||||
value: ''
|
||||
})
|
||||
|
||||
const shortKey = reactive<IShortKeyMap>({
|
||||
@@ -1132,13 +1143,14 @@ 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
|
||||
form.deleteCloudFile = settings.deleteCloudFile || false
|
||||
form.isCustomMiniIcon = settings.isCustomMiniIcon || false
|
||||
form.customMiniIcon = settings.customMiniIcon || ''
|
||||
form.isHideDock = settings.isHideDock || false
|
||||
currentLanguage.value = settings.language ?? 'zh-CN'
|
||||
currentStartMode.value = settings.startMode || 'quiet'
|
||||
customLink.value = settings.customLink || '$url'
|
||||
customLink.value = settings.customLink || ''
|
||||
shortKey.upload = settings.shortKey.upload
|
||||
proxy.value = picBed.proxy || ''
|
||||
npmRegistry.value = settings.registry || ''
|
||||
@@ -1200,6 +1212,16 @@ function confirmCustomLink () {
|
||||
})
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
async function cancelProxy () {
|
||||
proxyVisible.value = false
|
||||
proxy.value = await getConfig<string>('picBed.proxy') || ''
|
||||
|
||||
@@ -602,7 +602,7 @@ function ipcSendFiles (files: FileList) {
|
||||
|
||||
async function getPasteStyle () {
|
||||
pasteStyle.value = await getConfig('settings.pasteStyle') || 'markdown'
|
||||
customLink.value = await getConfig('settings.customLink') || '$url'
|
||||
customLink.value = await getConfig('settings.customLink') || ''
|
||||
}
|
||||
|
||||
function handlePasteStyleChange (val: string | number | boolean) {
|
||||
|
||||
1
src/universal/types/i18n.d.ts
vendored
1
src/universal/types/i18n.d.ts
vendored
@@ -186,6 +186,7 @@ interface ILocales {
|
||||
SETTINGS_SYNC_DELETE_CLOUD: string
|
||||
SETTINGS_ISHIDEDOCK: string
|
||||
SETTINGS_ISHIDEDOCK_TIPS: string
|
||||
SETTINGS_ENCODE_OUTPUT_URL: string
|
||||
SHORTCUT_NAME: string
|
||||
SHORTCUT_BIND: string
|
||||
SHORTCUT_STATUS: string
|
||||
|
||||
3
src/universal/types/view.d.ts
vendored
3
src/universal/types/view.d.ts
vendored
@@ -15,7 +15,8 @@ interface ISettingForm {
|
||||
deleteCloudFile: boolean,
|
||||
isCustomMiniIcon: boolean,
|
||||
customMiniIcon: string,
|
||||
isHideDock: boolean
|
||||
isHideDock: boolean,
|
||||
encodeOutputURL: boolean
|
||||
}
|
||||
|
||||
interface IShortKeyMap {
|
||||
|
||||
Reference in New Issue
Block a user