mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-28 11:42:04 +08:00
✨ Feature: add addvanced rename feature
This commit is contained in:
@@ -217,3 +217,52 @@ export const customRenameFormatTable = [
|
||||
description: '原文件名'
|
||||
}
|
||||
]
|
||||
|
||||
export const buildInRenameFormatTable = [
|
||||
{
|
||||
placeholder: '{Y}',
|
||||
description: '年份,4位数',
|
||||
placeholderB: '{y}',
|
||||
descriptionB: '年份,2位数'
|
||||
},
|
||||
{
|
||||
placeholder: '{m}',
|
||||
description: '月份(01-12)',
|
||||
placeholderB: '{d}',
|
||||
descriptionB: '日期(01-31)'
|
||||
},
|
||||
{
|
||||
placeholder: '{h}',
|
||||
description: '小时(00-23)',
|
||||
placeholderB: '{i}',
|
||||
descriptionB: '分钟(00-59)'
|
||||
},
|
||||
{
|
||||
placeholder: '{s}',
|
||||
description: '秒(00-59)',
|
||||
placeholderB: '{localFolder:<number>}',
|
||||
descriptionB: '本地文件夹层级'
|
||||
},
|
||||
{
|
||||
placeholder: '{timestamp}',
|
||||
description: '时间戳(秒)',
|
||||
placeholderB: '{uuid}',
|
||||
descriptionB: 'uuid字符串'
|
||||
},
|
||||
{
|
||||
placeholder: '{md5}',
|
||||
description: 'md5',
|
||||
placeholderB: '{md5-16}',
|
||||
descriptionB: 'md5前16位'
|
||||
},
|
||||
{
|
||||
placeholder: '{str-10}',
|
||||
description: '10位随机字符串',
|
||||
placeholderB: '{str-20}',
|
||||
descriptionB: '20位随机字符串'
|
||||
},
|
||||
{
|
||||
placeholder: '{filename}',
|
||||
description: '原文件名'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -661,39 +661,48 @@ function remove (item: ImgInfo) {
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
const file = await $$db.getById(item.id!)
|
||||
await $$db.removeById(item.id!)
|
||||
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist']
|
||||
if (await getConfig('settings.deleteCloudFile')) {
|
||||
if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) {
|
||||
setTimeout(() => {
|
||||
ALLApi.delete(item).then((value: boolean) => {
|
||||
if (value) {
|
||||
ElNotification({
|
||||
title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'),
|
||||
message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_SUCCEED')}`,
|
||||
type: 'success'
|
||||
})
|
||||
} else {
|
||||
ElNotification({
|
||||
title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'),
|
||||
message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_FAILED')}`,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
const result = await ALLApi.delete(item)
|
||||
if (result) {
|
||||
ElNotification({
|
||||
title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'),
|
||||
message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_SUCCEED')}`,
|
||||
type: 'success'
|
||||
})
|
||||
}, 0)
|
||||
await $$db.removeById(item.id!)
|
||||
sendToMain('removeFiles', [file])
|
||||
const obj = {
|
||||
title: $T('OPERATION_SUCCEED'),
|
||||
body: ''
|
||||
}
|
||||
const myNotification = new Notification(obj.title, obj)
|
||||
myNotification.onclick = () => {
|
||||
return true
|
||||
}
|
||||
updateGallery()
|
||||
} else {
|
||||
ElNotification({
|
||||
title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'),
|
||||
message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_FAILED')}`,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await $$db.removeById(item.id!)
|
||||
sendToMain('removeFiles', [file])
|
||||
const obj = {
|
||||
title: $T('OPERATION_SUCCEED'),
|
||||
body: ''
|
||||
}
|
||||
const myNotification = new Notification(obj.title, obj)
|
||||
myNotification.onclick = () => {
|
||||
return true
|
||||
}
|
||||
updateGallery()
|
||||
}
|
||||
sendToMain('removeFiles', [file])
|
||||
const obj = {
|
||||
title: $T('OPERATION_SUCCEED'),
|
||||
body: ''
|
||||
}
|
||||
const myNotification = new Notification(obj.title, obj)
|
||||
myNotification.onclick = () => {
|
||||
return true
|
||||
}
|
||||
updateGallery()
|
||||
}).catch((e) => {
|
||||
console.log(e)
|
||||
return true
|
||||
|
||||
@@ -319,6 +319,18 @@
|
||||
@change="handleAutoRename"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_ADVANCED_RENAME')"
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
round
|
||||
size="small"
|
||||
@click="advancedRenameVisible = true"
|
||||
>
|
||||
{{ $T('SETTINGS_CLICK_TO_SET') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_DELETE_LOCAL_FILE_AFTER_UPLOAD')"
|
||||
>
|
||||
@@ -721,6 +733,99 @@
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
v-model="advancedRenameVisible"
|
||||
:title="$T('SETTINGS_ADVANCED_RENAME')"
|
||||
center
|
||||
align-center
|
||||
draggable
|
||||
destroy-on-close
|
||||
>
|
||||
<el-link
|
||||
:underline="false"
|
||||
style="margin-bottom: 10px;"
|
||||
>
|
||||
{{ $T('SETTINGS_ADVANCED_RENAME_ENABLE') }}
|
||||
</el-link>
|
||||
<br>
|
||||
<el-switch
|
||||
v-model="advancedRename.enable"
|
||||
:active-text="$T('SETTINGS_OPEN')"
|
||||
:inactive-text="$T('SETTINGS_CLOSE')"
|
||||
/>
|
||||
<br>
|
||||
<el-link
|
||||
:underline="false"
|
||||
style="margin-bottom: 10px;margin-top: 10px;"
|
||||
>
|
||||
<span>
|
||||
{{ $T('SETTINGS_ADVANCED_RENAME_FORMAT') }}
|
||||
<el-popover
|
||||
effect="light"
|
||||
placement="right"
|
||||
width="350"
|
||||
>
|
||||
<template #reference>
|
||||
<el-icon
|
||||
color="#409EFF"
|
||||
>
|
||||
<InfoFilled />
|
||||
</el-icon>
|
||||
</template>
|
||||
<el-descriptions
|
||||
:column="1"
|
||||
style="width: 320px;"
|
||||
border
|
||||
>
|
||||
<el-descriptions-item
|
||||
v-for="(item, index) in buildInRenameFormatTable"
|
||||
:key="index"
|
||||
:label="item.placeholder"
|
||||
align="center"
|
||||
label-style="width: 100px;"
|
||||
>
|
||||
{{ item.description }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item
|
||||
v-for="(item, index) in buildInRenameFormatTable.slice(0, buildInRenameFormatTable.length-1)"
|
||||
:key="index"
|
||||
:label="item.placeholderB"
|
||||
align="center"
|
||||
label-style="width: 100px;"
|
||||
>
|
||||
{{ item.descriptionB }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-popover>
|
||||
</span>
|
||||
</el-link>
|
||||
<el-input
|
||||
v-model="advancedRename.format"
|
||||
placeholder="Ex. {Y}-{m}-{uuid}"
|
||||
clearable
|
||||
/>
|
||||
<div
|
||||
style="margin-top: 10px;align-items: center;display: flex;justify-content: flex-end;"
|
||||
>
|
||||
<el-button
|
||||
type="danger"
|
||||
style="margin-right: 30px;"
|
||||
plain
|
||||
:icon="Close"
|
||||
@click="handleCancelAdvancedRename"
|
||||
>
|
||||
{{ $T('CANCEL') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
:icon="Edit"
|
||||
@click="handleSaveAdvancedRename"
|
||||
>
|
||||
{{ $T('CONFIRM') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
v-model="logFileVisible"
|
||||
:title="$T('SETTINGS_SET_LOG_FILE')"
|
||||
@@ -1249,7 +1354,7 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ElForm, ElMessage as $message, ElMessage, ElMessageBox, FormRules } from 'element-plus'
|
||||
import { Reading, QuestionFilled } from '@element-plus/icons-vue'
|
||||
import { Reading, Close, Edit, InfoFilled } from '@element-plus/icons-vue'
|
||||
import pkg from 'root/package.json'
|
||||
import { PICGO_OPEN_FILE, OPEN_URL, GET_PICBEDS, HIDE_DOCK } from '#/events/constants'
|
||||
import {
|
||||
@@ -1266,6 +1371,7 @@ import { useRouter } from 'vue-router'
|
||||
import { SHORTKEY_PAGE } from '@/router/config'
|
||||
import { IConfig, IBuildInCompressOptions, IBuildInWaterMarkOptions } from 'piclist'
|
||||
import { invokeToMain } from '@/manage/utils/dataSender'
|
||||
import { buildInRenameFormatTable } from '../manage/utils/common'
|
||||
|
||||
const imageProcessDialogVisible = ref(false)
|
||||
const activeName = ref<'system' | 'syncAndConfigure' | 'upload' | 'advanced' | 'upadte'>('system')
|
||||
@@ -1404,6 +1510,7 @@ const syncVisible = ref(false)
|
||||
const upDownConfigVisible = ref(false)
|
||||
const proxyVisible = ref(false)
|
||||
const mainWindowSizeVisible = ref(false)
|
||||
const advancedRenameVisible = ref(false)
|
||||
|
||||
const customLink = reactive({
|
||||
value: ''
|
||||
@@ -1441,6 +1548,11 @@ const server = ref({
|
||||
enable: true
|
||||
})
|
||||
|
||||
const advancedRename = ref({
|
||||
enable: false,
|
||||
format: '{filename}'
|
||||
})
|
||||
|
||||
const sync = ref({
|
||||
type: 'github',
|
||||
username: '',
|
||||
@@ -1541,6 +1653,10 @@ async function initData () {
|
||||
host: '127.0.0.1',
|
||||
enable: true
|
||||
}
|
||||
advancedRename.value = config.buildIn?.rename || {
|
||||
enable: false,
|
||||
format: '{filename}'
|
||||
}
|
||||
sync.value = settings.sync || {
|
||||
type: 'github',
|
||||
username: '',
|
||||
@@ -1610,6 +1726,25 @@ function handleEncodeOutputURL (val: ICheckBoxValueType) {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCancelAdvancedRename () {
|
||||
advancedRenameVisible.value = false
|
||||
advancedRename.value = toRaw((await getConfig<any>('buildIn.rename')) || {
|
||||
enable: false,
|
||||
format: '{filename}'
|
||||
})
|
||||
}
|
||||
|
||||
function handleSaveAdvancedRename () {
|
||||
saveConfig('buildIn.rename', toRaw(advancedRename.value))
|
||||
advancedRenameVisible.value = false
|
||||
const successNotification = new Notification($T('SETTINGS_ADVANCED_RENAME'), {
|
||||
body: $T('TIPS_SET_SUCCEED')
|
||||
})
|
||||
successNotification.onclick = () => {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
async function cancelProxy () {
|
||||
proxyVisible.value = false
|
||||
proxy.value = await getConfig<string>('picBed.proxy') || ''
|
||||
|
||||
3
src/universal/types/i18n.d.ts
vendored
3
src/universal/types/i18n.d.ts
vendored
@@ -163,6 +163,9 @@ interface ILocales {
|
||||
SETTINGS_LAUNCH_ON_BOOT: string
|
||||
SETTINGS_RENAME_BEFORE_UPLOAD: string
|
||||
SETTINGS_TIMESTAMP_RENAME: string
|
||||
SETTINGS_ADVANCED_RENAME: string
|
||||
SETTINGS_ADVANCED_RENAME_ENABLE: string
|
||||
SETTINGS_ADVANCED_RENAME_FORMAT: string
|
||||
SETTINGS_OPEN_UPLOAD_TIPS: string
|
||||
SETTINGS_MINI_WINDOW_ON_TOP: string
|
||||
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: string
|
||||
|
||||
Reference in New Issue
Block a user