mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-06 20:42:57 +08:00
✨ Feature(custom): optimize scripts for gallery item delete
This commit is contained in:
@@ -39,11 +39,16 @@ const galleryRoutes = [
|
|||||||
action: IRPCActionType.GALLERY_REMOVE_FILES,
|
action: IRPCActionType.GALLERY_REMOVE_FILES,
|
||||||
handler: async (_: IIPCEvent, args: [files: ImgInfo[]]) => {
|
handler: async (_: IIPCEvent, args: [files: ImgInfo[]]) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
runScriptInStage('onGalleryRemove', picgo, { galleryItem: args[0] })
|
|
||||||
picgo.emit(ICOREBuildInEvent.REMOVE, args[0], GuiApi.getInstance())
|
picgo.emit(ICOREBuildInEvent.REMOVE, args[0], GuiApi.getInstance())
|
||||||
}, 500)
|
}, 500)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.GALLERY_REMOVE_RUN_SCRIPTS,
|
||||||
|
handler: async (_: IIPCEvent, args: [file: ImgInfo]) => {
|
||||||
|
await runScriptInStage('onGalleryRemove', picgo, { galleryItem: args[0] })
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.GALLERY_GET_DB,
|
action: IRPCActionType.GALLERY_GET_DB,
|
||||||
handler: async (_: IIPCEvent, args: [filter: IFilter]) => {
|
handler: async (_: IIPCEvent, args: [filter: IFilter]) => {
|
||||||
|
|||||||
@@ -191,6 +191,8 @@ export const IRPCActionType = {
|
|||||||
GALLERY_REMOVE_BY_ID_DB: 'GALLERY_REMOVE_BY_ID_DB',
|
GALLERY_REMOVE_BY_ID_DB: 'GALLERY_REMOVE_BY_ID_DB',
|
||||||
GALLERY_INSERT_DB: 'GALLERY_INSERT_DB',
|
GALLERY_INSERT_DB: 'GALLERY_INSERT_DB',
|
||||||
GALLERY_INSERT_DB_BATCH: 'GALLERY_INSERT_DB_BATCH',
|
GALLERY_INSERT_DB_BATCH: 'GALLERY_INSERT_DB_BATCH',
|
||||||
|
GALLERY_REMOVE_RUN_SCRIPTS: 'GALLERY_REMOVE_RUN_SCRIPTS',
|
||||||
|
|
||||||
// plugin rpc
|
// plugin rpc
|
||||||
PLUGIN_GET_LIST: 'PLUGIN_GET_LIST',
|
PLUGIN_GET_LIST: 'PLUGIN_GET_LIST',
|
||||||
PLUGIN_INSTALL: 'PLUGIN_INSTALL',
|
PLUGIN_INSTALL: 'PLUGIN_INSTALL',
|
||||||
|
|||||||
@@ -220,7 +220,6 @@ function handleMapChange(picbedType: string, value: any, id?: string) {
|
|||||||
for (const sibling of element?.parentElement?.parentElement?.children || []) {
|
for (const sibling of element?.parentElement?.parentElement?.children || []) {
|
||||||
const input = sibling.querySelector('input') as HTMLInputElement | null
|
const input = sibling.querySelector('input') as HTMLInputElement | null
|
||||||
if (input && input !== element) {
|
if (input && input !== element) {
|
||||||
console.log('uncheck', input)
|
|
||||||
input.checked = false
|
input.checked = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1935,7 +1935,6 @@ async function initCustomDomainList() {
|
|||||||
label: defaultUrl,
|
label: defaultUrl,
|
||||||
value: defaultUrl,
|
value: defaultUrl,
|
||||||
})
|
})
|
||||||
console.log('customDomainList', customDomainList.value)
|
|
||||||
currentCustomDomain.value = customDomainList.value[0].value
|
currentCustomDomain.value = customDomainList.value[0].value
|
||||||
} else {
|
} else {
|
||||||
customDomainList.value.length = 0
|
customDomainList.value.length = 0
|
||||||
@@ -2426,7 +2425,6 @@ const matchedFilesNumber = computed(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log('matchedFiles', matchedFiles)
|
|
||||||
return matchedFiles
|
return matchedFiles
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -2589,7 +2587,6 @@ async function copyLink(item: any, type: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handlecopyDropdownOpen() {
|
function handlecopyDropdownOpen() {
|
||||||
console.log('copyDropdownOpen', copyDropdownOpen.value)
|
|
||||||
copyDropdownOpen.value = !copyDropdownOpen.value
|
copyDropdownOpen.value = !copyDropdownOpen.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -849,6 +849,7 @@ function remove(item: ImgInfo, _: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await $$db.removeById(item.id!)
|
await $$db.removeById(item.id!)
|
||||||
|
window.electron.sendRPC(IRPCActionType.GALLERY_REMOVE_RUN_SCRIPTS, getRawData(item))
|
||||||
const args = getRawData(file)
|
const args = getRawData(file)
|
||||||
window.electron.sendRPC(IRPCActionType.GALLERY_REMOVE_FILES, [args])
|
window.electron.sendRPC(IRPCActionType.GALLERY_REMOVE_FILES, [args])
|
||||||
await updateGallery()
|
await updateGallery()
|
||||||
@@ -949,6 +950,7 @@ function multiRemove() {
|
|||||||
files.push(file)
|
files.push(file)
|
||||||
await $$db.removeById(key)
|
await $$db.removeById(key)
|
||||||
}
|
}
|
||||||
|
window.electron.sendRPC(IRPCActionType.GALLERY_REMOVE_RUN_SCRIPTS, getRawData(file))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -960,6 +962,7 @@ function multiRemove() {
|
|||||||
if (file) {
|
if (file) {
|
||||||
files.push(file)
|
files.push(file)
|
||||||
await $$db.removeById(key)
|
await $$db.removeById(key)
|
||||||
|
window.electron.sendRPC(IRPCActionType.GALLERY_REMOVE_RUN_SCRIPTS, getRawData(file))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,6 @@ const handleConfirm = async () => {
|
|||||||
async function getPicBeds() {
|
async function getPicBeds() {
|
||||||
try {
|
try {
|
||||||
const result = await window.electron.triggerRPC<any>(IRPCActionType.PICBED_GET_PICBED_CONFIG, $route.params.type)
|
const result = await window.electron.triggerRPC<any>(IRPCActionType.PICBED_GET_PICBED_CONFIG, $route.params.type)
|
||||||
console.log('PicBed config result:', result)
|
|
||||||
config.value = result.config
|
config.value = result.config
|
||||||
picBedName.value = result.name
|
picBedName.value = result.name
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1605,7 +1605,6 @@ const addWatch = () => {
|
|||||||
watch(
|
watch(
|
||||||
() => formOfSetting.value.mainWindowWidth,
|
() => formOfSetting.value.mainWindowWidth,
|
||||||
newVal => {
|
newVal => {
|
||||||
console.log('Main window width changed:', newVal)
|
|
||||||
const width = enforceNumber(newVal)
|
const width = enforceNumber(newVal)
|
||||||
saveConfig({ [configPaths.settings.mainWindowWidth]: rawPicGoSize.value ? 800 : Math.max(width, 100) })
|
saveConfig({ [configPaths.settings.mainWindowWidth]: rawPicGoSize.value ? 800 : Math.max(width, 100) })
|
||||||
},
|
},
|
||||||
@@ -1614,7 +1613,6 @@ const addWatch = () => {
|
|||||||
watch(
|
watch(
|
||||||
() => formOfSetting.value.mainWindowHeight,
|
() => formOfSetting.value.mainWindowHeight,
|
||||||
newVal => {
|
newVal => {
|
||||||
console.log('Main window height changed:', newVal)
|
|
||||||
const height = enforceNumber(newVal)
|
const height = enforceNumber(newVal)
|
||||||
saveConfig({ [configPaths.settings.mainWindowHeight]: rawPicGoSize.value ? 450 : Math.max(height, 100) })
|
saveConfig({ [configPaths.settings.mainWindowHeight]: rawPicGoSize.value ? 450 : Math.max(height, 100) })
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -278,7 +278,6 @@ async function refreshList() {
|
|||||||
const fileStats =
|
const fileStats =
|
||||||
(await window.electron.triggerRPC<IObj[]>(IRPCActionType.GET_FILES_STAT, getRawData(result), 'scripts')) || []
|
(await window.electron.triggerRPC<IObj[]>(IRPCActionType.GET_FILES_STAT, getRawData(result), 'scripts')) || []
|
||||||
const disabledList = ((await getConfig(configPaths.scripts.disabledList)) as string[] | undefined) || []
|
const disabledList = ((await getConfig(configPaths.scripts.disabledList)) as string[] | undefined) || []
|
||||||
console.log('disabledList', disabledList)
|
|
||||||
fileStats.forEach(file => {
|
fileStats.forEach(file => {
|
||||||
const fullPath = file.filePath.join('/')
|
const fullPath = file.filePath.join('/')
|
||||||
file.enabled = !disabledList.includes(fullPath)
|
file.enabled = !disabledList.includes(fullPath)
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ export const IRPCActionType = {
|
|||||||
GALLERY_REMOVE_BY_ID_DB: 'GALLERY_REMOVE_BY_ID_DB',
|
GALLERY_REMOVE_BY_ID_DB: 'GALLERY_REMOVE_BY_ID_DB',
|
||||||
GALLERY_INSERT_DB: 'GALLERY_INSERT_DB',
|
GALLERY_INSERT_DB: 'GALLERY_INSERT_DB',
|
||||||
GALLERY_INSERT_DB_BATCH: 'GALLERY_INSERT_DB_BATCH',
|
GALLERY_INSERT_DB_BATCH: 'GALLERY_INSERT_DB_BATCH',
|
||||||
|
GALLERY_REMOVE_RUN_SCRIPTS: 'GALLERY_REMOVE_RUN_SCRIPTS',
|
||||||
|
|
||||||
// plugin rpc
|
// plugin rpc
|
||||||
PLUGIN_GET_LIST: 'PLUGIN_GET_LIST',
|
PLUGIN_GET_LIST: 'PLUGIN_GET_LIST',
|
||||||
PLUGIN_INSTALL: 'PLUGIN_INSTALL',
|
PLUGIN_INSTALL: 'PLUGIN_INSTALL',
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ export const picBedManualUrlList: IStringKeyMap = {
|
|||||||
export const defaultScriptTemplate = `
|
export const defaultScriptTemplate = `
|
||||||
// ctx 为 核心PicList实例, extra为额外参数, 其中extra.galleryItem为当前删除的相册对象
|
// ctx 为 核心PicList实例, extra为额外参数, 其中extra.galleryItem为当前删除的相册对象
|
||||||
// 可用额外API: axios, crypto, fs, path, os, setTimeout, setInterval, clearTimeout, clearInterval, base64Decode, base64Encode
|
// 可用额外API: axios, crypto, fs, path, os, setTimeout, setInterval, clearTimeout, clearInterval, base64Decode, base64Encode
|
||||||
// 图床上传脚本必须返回 ctx 对象, 其它脚本可根据需求返回任意数据
|
|
||||||
|
|
||||||
async function main(ctx, extra) {
|
async function main(ctx, extra) {
|
||||||
// 在这里编写你的脚本代码
|
// 在这里编写你的脚本代码
|
||||||
@@ -82,7 +81,6 @@ async function main(ctx, extra) {
|
|||||||
export const defaultScriptTemplateEn = `
|
export const defaultScriptTemplateEn = `
|
||||||
// ctx is the core PicList instance, extra is additional parameters, among which extra.galleryItem is the currently deleted album object
|
// ctx is the core PicList instance, extra is additional parameters, among which extra.galleryItem is the currently deleted album object
|
||||||
// Available additional APIs: axios, crypto, fs, path, os, setTimeout, setInterval, clearTimeout, clearInterval, base64Decode, base64Encode
|
// Available additional APIs: axios, crypto, fs, path, os, setTimeout, setInterval, clearTimeout, clearInterval, base64Decode, base64Encode
|
||||||
// The image bed upload script must return the ctx object, other scripts can return any data as needed
|
|
||||||
|
|
||||||
async function main(ctx, extra) {
|
async function main(ctx, extra) {
|
||||||
// Write your script code here
|
// Write your script code here
|
||||||
|
|||||||
Reference in New Issue
Block a user