mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-08 01:01:13 +08:00
🐛 Fix: fix several bugs of manage page and minipage
This commit is contained in:
@@ -581,7 +581,9 @@ https://www.baidu.com/img/bd_logo1.png"
|
||||
size="20"
|
||||
style="cursor: pointer;"
|
||||
color="#409EFF"
|
||||
@click="copyToClipboard(formatLink(item.url, item.fileName, manageStore.config.settings.pasteFormat ?? '$markdown', manageStore.config.settings.customPasteFormat ?? '$url'))"
|
||||
@click="async () => {
|
||||
copyToClipboard(await formatLink(item.url, item.fileName, manageStore.config.settings.pasteFormat ?? '$markdown', manageStore.config.settings.customPasteFormat ?? '$url'))
|
||||
}"
|
||||
>
|
||||
<CopyDocument />
|
||||
</el-icon>
|
||||
@@ -589,32 +591,44 @@ https://www.baidu.com/img/bd_logo1.png"
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
@click="copyToClipboard(formatLink(item.url, item.fileName, 'url'))"
|
||||
@click="async () => {
|
||||
copyToClipboard(await formatLink(item.url, item.fileName, 'url'))
|
||||
}"
|
||||
>
|
||||
Url
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click="copyToClipboard(formatLink(item.url, item.fileName, 'markdown'))"
|
||||
@click="async () => {
|
||||
copyToClipboard(await formatLink(item.url, item.fileName, 'markdown'))
|
||||
}"
|
||||
>
|
||||
Markdown
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click="copyToClipboard(formatLink(item.url, item.fileName, 'markdown-with-link'))"
|
||||
@click="async () => {
|
||||
copyToClipboard(await formatLink(item.url, item.fileName, 'markdown-with-link'))
|
||||
}"
|
||||
>
|
||||
Markdown-link
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click="copyToClipboard(formatLink(item.url, item.fileName, 'html'))"
|
||||
@click="async () => {
|
||||
copyToClipboard(await formatLink(item.url, item.fileName, 'html'))
|
||||
}"
|
||||
>
|
||||
Html
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click="copyToClipboard(formatLink(item.url, item.fileName, 'bbcode'))"
|
||||
@click="async () => {
|
||||
copyToClipboard(await formatLink(item.url, item.fileName, 'bbcode'))
|
||||
}"
|
||||
>
|
||||
BBCode
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click="copyToClipboard(formatLink(item.url, item.fileName, 'custom', manageStore.config.settings.customPasteFormat))"
|
||||
@click="async () => {
|
||||
copyToClipboard(await formatLink(item.url, item.fileName, 'custom', manageStore.config.settings.customPasteFormat))
|
||||
}"
|
||||
>
|
||||
{{ $T('MANAGE_BUCKET_URL_FORMAT_CUSTOM') }}
|
||||
</el-dropdown-item>
|
||||
@@ -1540,6 +1554,7 @@ function handleUploadKeepDirChange (val: any) {
|
||||
}
|
||||
|
||||
function handleViewChange (val: 'list' | 'grid') {
|
||||
saveConfig('settings.isShowList', val === 'list')
|
||||
showFileStyle.value = val
|
||||
}
|
||||
|
||||
@@ -1738,7 +1753,8 @@ function renameFileBeforeUpload (filePath: string): string {
|
||||
const typeMap = {
|
||||
timestampRename: manageStore.config.settings.timestampRename,
|
||||
randomStringRename: manageStore.config.settings.randomStringRename,
|
||||
customRenameFormat: manageStore.config.settings.customRenameFormat
|
||||
customRenameFormat: manageStore.config.settings.customRenameFormat,
|
||||
customRename: manageStore.config.settings.customRename
|
||||
}
|
||||
return renameFile(typeMap, fileName)
|
||||
}
|
||||
@@ -2047,7 +2063,7 @@ async function resetParam (force: boolean = false) {
|
||||
previewedImage.value = ''
|
||||
isShowFileInfo.value = false
|
||||
lastChoosed.value = -1
|
||||
showFileStyle.value = manageStore.config.picBed[configMap.alias].isShowList ? 'list' : 'grid'
|
||||
showFileStyle.value = manageStore.config.settings.isShowList ? 'list' : 'grid'
|
||||
if (!isAutoRefresh.value && !force && !paging.value) {
|
||||
const cachedData = await searchExistFileList()
|
||||
if (cachedData.length > 0) {
|
||||
@@ -2719,19 +2735,19 @@ function handleBatchCopyInfo () {
|
||||
ElMessage.success(`${$T('MANAGE_BUCKET_BATCH_COPY_INFO_MSG_A')} ${selectedItems.length} ${$T('MANAGE_BUCKET_BATCH_COPY_INFO_MSG_B')}`)
|
||||
}
|
||||
|
||||
function handleBatchCopyLink (type: string) {
|
||||
async function handleBatchCopyLink (type: string) {
|
||||
if (selectedItems.length === 0) {
|
||||
ElMessage.warning($T('MANAGE_BUCKET_BATCH_COPY_URL_ERROR_MSG'))
|
||||
return
|
||||
}
|
||||
const result = [] as string[]
|
||||
selectedItems.forEach((item: any) => {
|
||||
selectedItems.forEach(async (item: any) => {
|
||||
if (!item.isDir) {
|
||||
if (type !== 'preSignedUrl') {
|
||||
result.push(formatLink(item.url, item.fileName, type, manageStore.config.settings.customPasteFormat))
|
||||
result.push(await formatLink(item.url, item.fileName, type, manageStore.config.settings.customPasteFormat))
|
||||
} else {
|
||||
getPreSignedUrl(item).then((url: string) => {
|
||||
result.push(formatLink(url, item.fileName, type, manageStore.config.settings.customPasteFormat))
|
||||
getPreSignedUrl(item).then(async (url: string) => {
|
||||
result.push(await formatLink(url, item.fileName, type, manageStore.config.settings.customPasteFormat))
|
||||
}).then(() => {
|
||||
if (result.length === selectedItems.length) {
|
||||
clipboard.writeText(result.join('\n'))
|
||||
@@ -3513,7 +3529,7 @@ const columns: Column<any>[] = [
|
||||
size="20"
|
||||
style="cursor: pointer;"
|
||||
color="#409EFF"
|
||||
onClick={() => copyToClipboard(formatLink(item.url, item.fileName, manageStore.config.settings.pasteFormat ?? '$markdown', manageStore.config.settings.customPasteFormat ?? '$url'))}
|
||||
onClick={async () => copyToClipboard(await formatLink(item.url, item.fileName, manageStore.config.settings.pasteFormat ?? '$markdown', manageStore.config.settings.customPasteFormat ?? '$url'))}
|
||||
>
|
||||
<CopyDocument />
|
||||
</ElIcon>
|
||||
@@ -3521,32 +3537,32 @@ const columns: Column<any>[] = [
|
||||
dropdown: () => (
|
||||
<ElDropdownMenu>
|
||||
<ElDropdownItem
|
||||
onClick={() => copyToClipboard(formatLink(item.url, item.fileName, 'url'))}
|
||||
onClick={async () => copyToClipboard(await formatLink(item.url, item.fileName, 'url'))}
|
||||
>
|
||||
Url
|
||||
</ElDropdownItem>
|
||||
<ElDropdownItem
|
||||
onClick={() => copyToClipboard(formatLink(item.url, item.fileName, 'markdown'))}
|
||||
onClick={async () => copyToClipboard(await formatLink(item.url, item.fileName, 'markdown'))}
|
||||
>
|
||||
Markdown
|
||||
</ElDropdownItem>
|
||||
<ElDropdownItem
|
||||
onClick={() => copyToClipboard(formatLink(item.url, item.fileName, 'markdown-with-link'))}
|
||||
onClick={async () => copyToClipboard(await formatLink(item.url, item.fileName, 'markdown-with-link'))}
|
||||
>
|
||||
Markdown-link
|
||||
</ElDropdownItem>
|
||||
<ElDropdownItem
|
||||
onClick={() => copyToClipboard(formatLink(item.url, item.fileName, 'html'))}
|
||||
onClick={async () => copyToClipboard(await formatLink(item.url, item.fileName, 'html'))}
|
||||
>
|
||||
Html
|
||||
</ElDropdownItem>
|
||||
<ElDropdownItem
|
||||
onClick={() => copyToClipboard(formatLink(item.url, item.fileName, 'bbcode'))}
|
||||
onClick={async () => copyToClipboard(await formatLink(item.url, item.fileName, 'bbcode'))}
|
||||
>
|
||||
BBCode
|
||||
</ElDropdownItem>
|
||||
<ElDropdownItem
|
||||
onClick={() => copyToClipboard(formatLink(item.url, item.fileName, 'custom', manageStore.config.settings.customPasteFormat))}
|
||||
onClick={async () => copyToClipboard(await formatLink(item.url, item.fileName, 'custom', manageStore.config.settings.customPasteFormat))}
|
||||
>
|
||||
Custom
|
||||
</ElDropdownItem>
|
||||
|
||||
@@ -150,6 +150,31 @@
|
||||
@change="handleIsForceCustomUrlHttpsChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<span
|
||||
style="position:absolute;left: 0;"
|
||||
>
|
||||
{{ $T('MANAGE_SETTING_ENCODE_URL_WHEN_COPY') }}
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
:content="$T('MANAGE_SETTING_ENCODE_URL_WHEN_COPY_TIPS')"
|
||||
placement="right"
|
||||
>
|
||||
<el-icon>
|
||||
<InfoFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</template>
|
||||
<el-switch
|
||||
v-model="form.isEncodeUrl"
|
||||
style="position:absolute;right: 0;"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#ff4949"
|
||||
@change="handleIsEncodeUrlChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<span
|
||||
@@ -507,6 +532,7 @@ const form = reactive<IStringKeyMap>({
|
||||
isAutoRefresh: false,
|
||||
isIgnoreCase: false,
|
||||
isForceCustomUrlHttps: false,
|
||||
isEncodeUrl: false,
|
||||
isShowList: false,
|
||||
isUploadKeepDirStructure: true,
|
||||
isDownloadFileKeepDirStructure: false,
|
||||
@@ -577,8 +603,10 @@ async function initData () {
|
||||
downloadDir.value = config.settings.downloadDir ?? ''
|
||||
form.isAutoRefresh = config.settings.isAutoRefresh ?? false
|
||||
form.isShowThumbnail = config.settings.isShowThumbnail ?? false
|
||||
form.isShowList = config.settings.isShowList ?? false
|
||||
form.isIgnoreCase = config.settings.isIgnoreCase ?? false
|
||||
form.isForceCustomUrlHttps = config.settings.isForceCustomUrlHttps ?? true
|
||||
form.isEncodeUrl = config.settings.isEncodeUrl ?? false
|
||||
PreSignedExpire.value = config.settings.PreSignedExpire ?? 14400
|
||||
maxDownloadFileCount.value = config.settings.maxDownloadFileCount ?? 5
|
||||
form.isUploadKeepDirStructure = config.settings.isUploadKeepDirStructure ?? true
|
||||
@@ -641,6 +669,12 @@ function handleIsForceCustomUrlHttpsChange (val:ICheckBoxValueType) {
|
||||
})
|
||||
}
|
||||
|
||||
function handleIsEncodeUrlChange (val:ICheckBoxValueType) {
|
||||
saveConfig({
|
||||
'settings.isEncodeUrl': val
|
||||
})
|
||||
}
|
||||
|
||||
function handleTimestampRenameChange (val:ICheckBoxValueType) {
|
||||
saveConfig({
|
||||
'settings.timestampRename': val
|
||||
|
||||
@@ -2,6 +2,8 @@ import { v4 as uuidv4 } from 'uuid'
|
||||
import path from 'path'
|
||||
import crypto from 'crypto'
|
||||
import { availableIconList } from './icon'
|
||||
import { getConfig } from './dataSender'
|
||||
import { handleUrlEncode } from '~/universal/utils/common'
|
||||
|
||||
export function randomStringGenerator (length: number): string {
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
||||
@@ -44,13 +46,14 @@ export function renameFile (typeMap : IStringKeyMap, oldName: string): string {
|
||||
return renameFileNameWithTimestamp(oldName)
|
||||
} else if (typeMap.randomStringRename) {
|
||||
return renameFileNameWithRandomString(oldName, 20)
|
||||
} else {
|
||||
} else if (typeMap.customRename) {
|
||||
return renameFileNameWithCustomString(oldName, typeMap.customRenameFormat)
|
||||
}
|
||||
return oldName
|
||||
}
|
||||
|
||||
export function formatLink (url: string, fileName: string, type: string, format?: string) : string {
|
||||
const encodedUrl = encodeURI(url)
|
||||
export async function formatLink (url: string, fileName: string, type: string, format?: string) : Promise<string> {
|
||||
const encodedUrl = await getConfig('settings.isEncodeUrl') ? handleUrlEncode(url) : url
|
||||
switch (type) {
|
||||
case 'markdown':
|
||||
return ``
|
||||
@@ -73,7 +76,7 @@ export function formatLink (url: string, fileName: string, type: string, format?
|
||||
}
|
||||
|
||||
export function getFileIconPath (fileName: string) {
|
||||
const ext = path.extname(fileName).slice(1)
|
||||
const ext = path.extname(fileName).slice(1).toLowerCase()
|
||||
return availableIconList.includes(ext) ? `${ext}.webp` : 'unknown.webp'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
<template>
|
||||
<div
|
||||
id="mini-page"
|
||||
:class="{ linux: os === 'linux' }"
|
||||
>
|
||||
<img
|
||||
:src="logoPath.value ? logoPath.value : require('../assets/squareLogo.png')"
|
||||
style="width: 100%; height: 100%;border-radius: 50%;"
|
||||
>
|
||||
<div
|
||||
id="upload-area"
|
||||
:class="{ 'is-dragover': dragover, uploading: showProgress, linux: os === 'linux' }"
|
||||
@@ -15,6 +10,11 @@
|
||||
@dragover.prevent="dragover = true"
|
||||
@dragleave.prevent="dragover = false"
|
||||
>
|
||||
<img
|
||||
v-if="!dragover && !showProgress"
|
||||
:src="logoPath.value ? logoPath.value : require('../assets/squareLogo.png')"
|
||||
style="width: 100%; height: 100%;border-radius: 50%;"
|
||||
>
|
||||
<div
|
||||
id="upload-dragger"
|
||||
@dblclick="openUploadWindow"
|
||||
|
||||
Reference in New Issue
Block a user