🔨 Refactor(custom): refactor drop down item in bucket page

This commit is contained in:
Kuingsmile 2024-06-04 14:58:51 +08:00
parent 0c241bc82c
commit afffea7623
6 changed files with 55 additions and 75 deletions

View File

@ -758,13 +758,18 @@ MANAGE_BUCKET_DELETE_BTN: Delete
MANAGE_BUCKET_SORT_TITLE: Sort
MANAGE_BUCKET_SORT_NAME: Name
MANAGE_BUCKET_SORT_SIZE: Size
MANAGE_BUCKET_SORT_TYPE: Type
MANAGE_BUCKET_SORT_EXT: Type
MANAGE_BUCKET_SORT_TIME: Time
MANAGE_BUCKET_SORT_SELECTED: Selected status
MANAGE_BUCKET_INIT: Init
MANAGE_BUCKET_SORT_CHECK: Selected status
MANAGE_BUCKET_SORT_INIT: Init
MANAGE_BUCKET_URL_UPLOAD_DIALOG_TITLE: Please enter URL(s), support multiple URLs separated by line breaks
MANAGE_BUCKET_URL_UPLOAD_DIALOG_CONFIRM: Confirm
MANAGE_BUCKET_URL_UPLOAD_DIALOG_CANCEL: Cancel
MANAGE_BUCKET_URL_FORMAT_MARKDOWN: Markdown
MANAGE_BUCKET_URL_FORMAT_MARKDOWN_WITH_LINK: Markdown-link
MANAGE_BUCKET_URL_FORMAT_URL: Url
MANAGE_BUCKET_URL_FORMAT_HTML: Html
MANAGE_BUCKET_URL_FORMAT_BBCODE: BBCode
MANAGE_BUCKET_URL_FORMAT_CUSTOM: Custom
MANAGE_BUCKET_URL_FORMAT_PRESIGN: Presigned link
MANAGE_BUCKET_FILE_INFO_TITLE: File information

View File

@ -763,13 +763,18 @@ MANAGE_BUCKET_DELETE_BTN: 删除
MANAGE_BUCKET_SORT_TITLE: 排序
MANAGE_BUCKET_SORT_NAME: 文件名
MANAGE_BUCKET_SORT_SIZE: 大小
MANAGE_BUCKET_SORT_TYPE: 类型
MANAGE_BUCKET_SORT_EXT: 类型
MANAGE_BUCKET_SORT_TIME: 时间
MANAGE_BUCKET_SORT_SELECTED: 选中状态
MANAGE_BUCKET_INIT: 初始化
MANAGE_BUCKET_SORT_CHECK: 选中状态
MANAGE_BUCKET_SORT_INIT: 初始化
MANAGE_BUCKET_URL_UPLOAD_DIALOG_TITLE: 请输入URL支持多个URL以换行分隔
MANAGE_BUCKET_URL_UPLOAD_DIALOG_CONFIRM: 确定
MANAGE_BUCKET_URL_UPLOAD_DIALOG_CANCEL: 取消
MANAGE_BUCKET_URL_FORMAT_MARKDOWN: Markdown
MANAGE_BUCKET_URL_FORMAT_MARKDOWN_WITH_LINK: Markdown-link
MANAGE_BUCKET_URL_FORMAT_URL: Url
MANAGE_BUCKET_URL_FORMAT_HTML: Html
MANAGE_BUCKET_URL_FORMAT_BBCODE: BBCode
MANAGE_BUCKET_URL_FORMAT_CUSTOM: 自定义
MANAGE_BUCKET_URL_FORMAT_PRESIGN: 预签名链接
MANAGE_BUCKET_FILE_INFO_TITLE: 文件信息

View File

@ -758,13 +758,18 @@ MANAGE_BUCKET_DELETE_BTN: 刪除
MANAGE_BUCKET_SORT_TITLE: 排序
MANAGE_BUCKET_SORT_NAME: 檔案名稱
MANAGE_BUCKET_SORT_SIZE: 大小
MANAGE_BUCKET_SORT_TYPE: 類型
MANAGE_BUCKET_SORT_EXT: 類型
MANAGE_BUCKET_SORT_TIME: 時間
MANAGE_BUCKET_SORT_SELECTED: 選取狀態
MANAGE_BUCKET_INIT: 初始化
MANAGE_BUCKET_SORT_CHECK: 選取狀態
MANAGE_BUCKET_SORT_INIT: 初始化
MANAGE_BUCKET_URL_UPLOAD_DIALOG_TITLE: 請輸入 URL支援多個 URL以換行分隔
MANAGE_BUCKET_URL_UPLOAD_DIALOG_CONFIRM: 確定
MANAGE_BUCKET_URL_UPLOAD_DIALOG_CANCEL: 取消
MANAGE_BUCKET_URL_FORMAT_MARKDOWN: Markdown
MANAGE_BUCKET_URL_FORMAT_MARKDOWN_WITH_LINK: Markdown-link
MANAGE_BUCKET_URL_FORMAT_URL: Url
MANAGE_BUCKET_URL_FORMAT_HTML: Html
MANAGE_BUCKET_URL_FORMAT_BBCODE: BBCode
MANAGE_BUCKET_URL_FORMAT_CUSTOM: 自訂
MANAGE_BUCKET_URL_FORMAT_PRESIGN: 預簽名連結
MANAGE_BUCKET_FILE_INFO_TITLE: 檔案資訊

View File

@ -400,23 +400,12 @@
{{ $T('MANAGE_BUCKET_SORT_TITLE') }}
</el-button>
<template #dropdown>
<el-dropdown-item @click="sortFile('name')">
{{ $T('MANAGE_BUCKET_SORT_NAME') }}
</el-dropdown-item>
<el-dropdown-item @click="sortFile('size')">
{{ $T('MANAGE_BUCKET_SORT_SIZE') }}
</el-dropdown-item>
<el-dropdown-item @click="sortFile('ext')">
{{ $T('MANAGE_BUCKET_SORT_TYPE') }}
</el-dropdown-item>
<el-dropdown-item @click="sortFile('time')">
{{ $T('MANAGE_BUCKET_SORT_TIME') }}
</el-dropdown-item>
<el-dropdown-item @click="sortFile('check')">
{{ $T('MANAGE_BUCKET_SORT_SELECTED') }}
</el-dropdown-item>
<el-dropdown-item @click="sortFile('init')">
{{ $T('MANAGE_BUCKET_INIT') }}
<el-dropdown-item
v-for="item in sortTypeList"
:key="item"
@click="sortFile(item as any)"
>
{{ $T(`MANAGE_BUCKET_SORT_${item.toUpperCase()}` as any) }}
</el-dropdown-item>
</template>
</el-dropdown>
@ -634,46 +623,11 @@ https://www.baidu.com/img/bd_logo1.png"
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
@click="async () => {
copyToClipboard(await formatLink(item.url, item.fileName, 'url'))
}"
v-for="format in linkFormatList"
:key="format"
@click="copyLink(item, format)"
>
Url
</el-dropdown-item>
<el-dropdown-item
@click="async () => {
copyToClipboard(await formatLink(item.url, item.fileName, 'markdown'))
}"
>
Markdown
</el-dropdown-item>
<el-dropdown-item
@click="async () => {
copyToClipboard(await formatLink(item.url, item.fileName, 'markdown-with-link'))
}"
>
Markdown-link
</el-dropdown-item>
<el-dropdown-item
@click="async () => {
copyToClipboard(await formatLink(item.url, item.fileName, 'html'))
}"
>
Html
</el-dropdown-item>
<el-dropdown-item
@click="async () => {
copyToClipboard(await formatLink(item.url, item.fileName, 'bbcode'))
}"
>
BBCode
</el-dropdown-item>
<el-dropdown-item
@click="async () => {
copyToClipboard(await formatLink(item.url, item.fileName, 'custom', manageStore.config.settings.customPasteFormat))
}"
>
{{ $T('MANAGE_BUCKET_URL_FORMAT_CUSTOM') }}
{{ $T(`MANAGE_BUCKET_URL_FORMAT_${format.toUpperCase().replace(/-/g, '_')}` as any) }}
</el-dropdown-item>
<el-dropdown-item
v-if="isShowPresignedUrl"
@ -1571,8 +1525,10 @@ const linkFormatArray = [
{ key: 'BBCode', value: 'bbcode' },
{ key: 'Custom', value: 'custom' }
]
const linkFormatList = ['url', 'markdown', 'markdown-with-link', 'html', 'bbcode', 'custom']
type sortTypeList = 'name' | 'size' | 'time' | 'ext' | 'check' | 'init'
type ISortTypeList = 'name' | 'size' | 'time' | 'ext' | 'check' | 'init'
const sortTypeList = ['name', 'size', 'time', 'ext', 'check', 'init']
//
const route = useRoute()
@ -2230,7 +2186,7 @@ async function resetParam (force: boolean = false) {
const cachedData = await searchExistFileList()
if (cachedData.length > 0) {
currentPageFilesInfo.push(...cachedData[0].value.fullList)
const sortType = localStorage.getItem('sortType') as sortTypeList || 'init'
const sortType = localStorage.getItem('sortType') as ISortTypeList || 'init'
sortFile(sortType)
isShowLoadingPage.value = false
return
@ -2240,7 +2196,7 @@ async function resetParam (force: boolean = false) {
const res = await getBucketFileList() as IStringKeyMap
if (res.success) {
currentPageFilesInfo.push(...res.fullList)
const sortType = localStorage.getItem('sortType') as sortTypeList || 'init'
const sortType = localStorage.getItem('sortType') as ISortTypeList || 'init'
sortFile(sortType)
if (res.isTruncated && paging.value) {
pagingMarkerStack.push(pagingMarker.value)
@ -2311,7 +2267,7 @@ const changePage = async (cur: number | undefined, prev: number | undefined) =>
}
const isForwardNavigation = cur > prev
const newPageNumber = isForwardNavigation ? prev + 1 : prev - 1
const sortType = localStorage.getItem('sortType') as sortTypeList || 'init'
const sortType = localStorage.getItem('sortType') as ISortTypeList || 'init'
isShowLoadingPage.value = true
currentPageNumber.value = newPageNumber
@ -2771,6 +2727,10 @@ function handleBatchCopyInfo () {
ElMessage.success(`${$T('MANAGE_BUCKET_BATCH_COPY_INFO_MSG_A')} ${selectedItems.value.length} ${$T('MANAGE_BUCKET_BATCH_COPY_INFO_MSG_B')}`)
}
async function copyLink (item: any, type: string) {
copyToClipboard(await formatLink(item.url, item.fileName, type, manageStore.config.settings.customPasteFormat))
}
async function handleBatchCopyLink (type: string) {
if (!selectedItems.value.length) {
ElMessage.warning($T('MANAGE_BUCKET_BATCH_COPY_URL_ERROR_MSG'))
@ -2844,7 +2804,7 @@ async function getBucketFileListBackStage () {
fileTransferInterval = setInterval(() => {
const currentFileList = fileTransferStore.getFileTransferList()
currentPageFilesInfo.splice(0, currentPageFilesInfo.length, ...currentFileList)
const sortType = localStorage.getItem('sortType') as sortTypeList || 'init'
const sortType = localStorage.getItem('sortType') as ISortTypeList || 'init'
sortFile(sortType)
const table = fileCacheDbInstance.table(currentPicBedName.value)
table.put({

View File

@ -145,13 +145,13 @@
{{ $T('MANAGE_BUCKET_SORT_NAME') }}
</el-dropdown-item>
<el-dropdown-item @click="sortFile('ext')">
{{ $T('MANAGE_BUCKET_SORT_TYPE') }}
{{ $T('MANAGE_BUCKET_SORT_EXT') }}
</el-dropdown-item>
<el-dropdown-item @click="sortFile('time')">
{{ $T('MANAGE_BUCKET_SORT_TIME') }}
</el-dropdown-item>
<el-dropdown-item @click="sortFile('check')">
{{ $T('MANAGE_BUCKET_SORT_SELECTED') }}
{{ $T('MANAGE_BUCKET_SORT_CHECK') }}
</el-dropdown-item>
</template>
</el-dropdown>

View File

@ -716,13 +716,18 @@ interface ILocales {
MANAGE_BUCKET_SORT_TITLE: string
MANAGE_BUCKET_SORT_NAME: string
MANAGE_BUCKET_SORT_SIZE: string
MANAGE_BUCKET_SORT_TYPE: string
MANAGE_BUCKET_SORT_EXT: string
MANAGE_BUCKET_SORT_TIME: string
MANAGE_BUCKET_SORT_SELECTED: string
MANAGE_BUCKET_INIT: string
MANAGE_BUCKET_SORT_CHECK: string
MANAGE_BUCKET_SORT_INIT: string
MANAGE_BUCKET_URL_UPLOAD_DIALOG_TITLE: string
MANAGE_BUCKET_URL_UPLOAD_DIALOG_CONFIRM: string
MANAGE_BUCKET_URL_UPLOAD_DIALOG_CANCEL: string
MANAGE_BUCKET_URL_FORMAT_MARKDOWN: string
MANAGE_BUCKET_URL_FORMAT_MARKDOWN_WITH_LINK: string
MANAGE_BUCKET_URL_FORMAT_URL: string
MANAGE_BUCKET_URL_FORMAT_HTML: string
MANAGE_BUCKET_URL_FORMAT_BBCODE: string
MANAGE_BUCKET_URL_FORMAT_CUSTOM: string
MANAGE_BUCKET_URL_FORMAT_PRESIGN: string
MANAGE_BUCKET_FILE_INFO_TITLE: string