mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-03-13 00:18:13 -04:00
✨ Feature: add addvanced rename feature
This commit is contained in:
parent
86505c19e2
commit
c4b0235d61
@ -68,7 +68,7 @@
|
||||
"mime-types": "^2.1.35",
|
||||
"mitt": "^3.0.0",
|
||||
"nodejs-file-downloader": "^4.10.6",
|
||||
"piclist": "^0.6.6",
|
||||
"piclist": "^0.6.7",
|
||||
"pinia": "^2.0.32",
|
||||
"pinia-plugin-persistedstate": "^3.1.0",
|
||||
"qiniu": "^7.8.0",
|
||||
|
@ -168,6 +168,9 @@ SETTINGS_ACCEPT_BETA_UPDATE: Accept Beta Update
|
||||
SETTINGS_LAUNCH_ON_BOOT: Launch On Boot
|
||||
SETTINGS_RENAME_BEFORE_UPLOAD: Rename Before Upload
|
||||
SETTINGS_TIMESTAMP_RENAME: Timestamp Rename
|
||||
SETTINGS_ADVANCED_RENAME: Advanced Rename
|
||||
SETTINGS_ADVANCED_RENAME_ENABLE: Enable Advanced Rename
|
||||
SETTINGS_ADVANCED_RENAME_FORMAT: Advanced Rename Format
|
||||
SETTINGS_OPEN_UPLOAD_TIPS: Open Upload Tips
|
||||
SETTINGS_MINI_WINDOW_ON_TOP: Mini Window On Top
|
||||
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: Auto Copy URL After Upload
|
||||
|
@ -170,6 +170,9 @@ SETTINGS_ACCEPT_BETA_UPDATE: 接受Beta版本更新
|
||||
SETTINGS_LAUNCH_ON_BOOT: 开机自启
|
||||
SETTINGS_RENAME_BEFORE_UPLOAD: 上传前重命名
|
||||
SETTINGS_TIMESTAMP_RENAME: 时间戳重命名
|
||||
SETTINGS_ADVANCED_RENAME: 高级重命名
|
||||
SETTINGS_ADVANCED_RENAME_ENABLE: 开启高级重命名
|
||||
SETTINGS_ADVANCED_RENAME_FORMAT: 重命名格式
|
||||
SETTINGS_OPEN_UPLOAD_TIPS: 开启上传提示
|
||||
SETTINGS_MINI_WINDOW_ON_TOP: Mini窗口置顶
|
||||
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上传后自动复制URL
|
||||
|
@ -168,6 +168,9 @@ SETTINGS_ACCEPT_BETA_UPDATE: 接受Beta版本更新
|
||||
SETTINGS_LAUNCH_ON_BOOT: 開機時啟動
|
||||
SETTINGS_RENAME_BEFORE_UPLOAD: 上傳前重新命名
|
||||
SETTINGS_TIMESTAMP_RENAME: 以時間戳命名
|
||||
SETTINGS_ADVANCED_RENAME: 高級命名
|
||||
SETTINGS_ADVANCED_RENAME_ENABLE: 啟用高級命名
|
||||
SETTINGS_ADVANCED_RENAME_FORMAT: 高級命名格式
|
||||
SETTINGS_OPEN_UPLOAD_TIPS: 開啟上傳提示
|
||||
SETTINGS_MINI_WINDOW_ON_TOP: Mini視窗置頂
|
||||
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上傳後自動複製URL
|
||||
|
@ -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
|
||||
|
@ -11095,10 +11095,10 @@ performance-now@^2.1.0:
|
||||
resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||
integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==
|
||||
|
||||
piclist@^0.6.6:
|
||||
version "0.6.6"
|
||||
resolved "https://registry.npmjs.org/piclist/-/piclist-0.6.6.tgz#dda4f5b693f61dd6c5507312f5a94f8fd6679b4f"
|
||||
integrity sha512-d2hzxpoQ7BpIG+S1rtQcrfabhZtfky4g1+HgSfdasI4j7sH+bbsVM+cIxRMRQBHhqbvtVsiswv7SoeNFJNSQnw==
|
||||
piclist@^0.6.7:
|
||||
version "0.6.7"
|
||||
resolved "https://registry.npmjs.org/piclist/-/piclist-0.6.7.tgz#fae5bc4b1298783a6b55ae8b00eca8b6b1e126f5"
|
||||
integrity sha512-QPlyCnGMYCJQqzbtNg2jhsOvrit6cENZjQEaC137XbJ/xYC/JMSYhcNqt9PmRjlMBNqAH8SpnX51KJwWt74/nA==
|
||||
dependencies:
|
||||
"@picgo/i18n" "^1.0.0"
|
||||
"@picgo/store" "^2.0.4"
|
||||
@ -11129,6 +11129,7 @@ piclist@^0.6.6:
|
||||
sharp "^0.32.1"
|
||||
text-to-svg "^3.1.5"
|
||||
tunnel "^0.0.6"
|
||||
uuid "^9.0.0"
|
||||
|
||||
picocolors@^0.2.1:
|
||||
version "0.2.1"
|
||||
|
Loading…
Reference in New Issue
Block a user