Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuingsmile committed Aug 22, 2024
2 parents 5d5bcda + 931209c commit 6d2884f
Show file tree
Hide file tree
Showing 31 changed files with 457 additions and 233 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## :tada: 2.9.3 (2024-08-22)


### :sparkles: Features

* **custom:** add advanced picbed manual link ([26149ad](https://github.com/Kuingsmile/piclist/commit/26149ad))
* **custom:** remove some dev output ([a046b40](https://github.com/Kuingsmile/piclist/commit/a046b40))
* **custom:** support avif picture preview ([630eb03](https://github.com/Kuingsmile/piclist/commit/630eb03))
* **custom:** support secondary picbed upload ([8962a46](https://github.com/Kuingsmile/piclist/commit/8962a46)), closes [#226](https://github.com/Kuingsmile/piclist/issues/226)


### :bug: Bug Fixes

* **custom:** fix piclist picbed bugs ([893da24](https://github.com/Kuingsmile/piclist/commit/893da24)), closes [#236](https://github.com/Kuingsmile/piclist/issues/236)
* **custom:** fix type error ([6bf6d6b](https://github.com/Kuingsmile/piclist/commit/6bf6d6b))


### :pencil: Documentation

* **custom:** prepare for new version ([0007d9a](https://github.com/Kuingsmile/piclist/commit/0007d9a))



## :tada: 2.9.2 (2024-07-30)


Expand Down
10 changes: 7 additions & 3 deletions currentVersion.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### ✨ Features

- 新增高级自定义图床
- 相册页面现在加载图片时会显示loading图
- 优化了相册页面的加载速度
- 新增第二图床上传支持
- 现在管理页面支持预览avif图片
- 调整了图床配置页面的日期显示格式

### 🐛 Bug Fixes

- 修复了PicList图床对core版的兼容性问题
10 changes: 7 additions & 3 deletions currentVersion_en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### ✨ Features

- Add advanced custom image bed
- The album page now displays a loading image when loading pictures
- Optimized the loading speed of the album page
- Added support for the second image bed upload
- Now the management page supports previewing avif images
- Adjusted the date display format on the image bed configuration page

### 🐛 Bug Fixes

- Fixed the compatibility issue of PicList image bed with the core version
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "piclist",
"version": "2.9.2",
"version": "2.9.3",
"author": {
"name": "Kuingsmile",
"email": "[email protected]"
Expand Down Expand Up @@ -67,7 +67,7 @@
"multer": "^1.4.5-lts.1",
"node-ssh-no-cpu-features": "^2.0.0",
"nodejs-file-downloader": "^4.12.1",
"piclist": "^1.9.1",
"piclist": "^1.9.3",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"proxy-agent": "^5.0.0",
Expand Down Expand Up @@ -97,7 +97,7 @@
"@types/lowdb": "^1.0.15",
"@types/mime-types": "^2.1.4",
"@types/multer": "^1.4.11",
"@types/node": "^16.10.2",
"@types/node": "^22.0.0",
"@types/semver": "^7.5.6",
"@types/tunnel": "^0.0.7",
"@types/upyun": "^3.4.3",
Expand Down
3 changes: 3 additions & 0 deletions public/i18n/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ NO_MORE_NOTICE: No More Notice
SHOW_DEVTOOLS: Show Devtools
FEEDBACK: Feedback
CURRENT_PICBED: Current Picbed
CURRENT_SECOND_PICBED: Current Second Picbed
START_WATCH_CLIPBOARD: Start Watch Clipboard
STOP_WATCH_CLIPBOARD: Stop Watch Clipboard
OPEN_TOOLBOX: Open Toolbox
Expand Down Expand Up @@ -183,6 +184,8 @@ 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_ENABLE_SECOND_PICBED: Enable Second Picbed
SETTINGS_SET_SECOND_PICBED: Set Second Picbed
SETTINGS_OPEN_UPLOAD_TIPS: Open Upload Tips
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: Open Upload Result Tips
SETTINGS_MINI_WINDOW_ON_TOP: Mini Window On Top
Expand Down
3 changes: 3 additions & 0 deletions public/i18n/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ NO_MORE_NOTICE: 以后不再提醒
SHOW_DEVTOOLS: 打开开发者工具
FEEDBACK: 反馈问题
CURRENT_PICBED: 当前图床
CURRENT_SECOND_PICBED: 当前第二图床
START_WATCH_CLIPBOARD: 开始监听剪贴板
STOP_WATCH_CLIPBOARD: 停止监听剪贴板
OPEN_TOOLBOX: 打开修复工具箱
Expand Down Expand Up @@ -185,6 +186,8 @@ SETTINGS_TIMESTAMP_RENAME: 时间戳重命名
SETTINGS_ADVANCED_RENAME: 高级重命名
SETTINGS_ADVANCED_RENAME_ENABLE: 开启高级重命名
SETTINGS_ADVANCED_RENAME_FORMAT: 重命名格式
SETTINGS_ENABLE_SECOND_PICBED: 启用第二图床同步上传
SETTINGS_SET_SECOND_PICBED: 设置第二图床
SETTINGS_OPEN_UPLOAD_TIPS: 开启上传进度提示
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: 开启上传结果提示
SETTINGS_MINI_WINDOW_ON_TOP: Mini窗口置顶
Expand Down
3 changes: 3 additions & 0 deletions public/i18n/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ NO_MORE_NOTICE: 以後不再提醒
SHOW_DEVTOOLS: 開啟開發者工具
FEEDBACK: 問題反饋
CURRENT_PICBED: 當前圖床
CURRENT_SECOND_PICBED: 當前第二圖床
START_WATCH_CLIPBOARD: 開始監聽剪貼簿
STOP_WATCH_CLIPBOARD: 停止監聽剪貼簿
OPEN_TOOLBOX: 開啟修復工具箱
Expand Down Expand Up @@ -183,6 +184,8 @@ SETTINGS_TIMESTAMP_RENAME: 以時間戳命名
SETTINGS_ADVANCED_RENAME: 高級命名
SETTINGS_ADVANCED_RENAME_ENABLE: 啟用高級命名
SETTINGS_ADVANCED_RENAME_FORMAT: 高級命名格式
SETTINGS_ENABLE_SECOND_PICBED: 啟用第二圖床同步上傳
SETTINGS_SET_SECOND_PICBED: 設定第二圖床
SETTINGS_OPEN_UPLOAD_TIPS: 開啟上傳提示
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: 開啟上傳結果提示
SETTINGS_MINI_WINDOW_ON_TOP: Mini視窗置頂
Expand Down
3 changes: 2 additions & 1 deletion src/main/apis/app/system/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import db, { GalleryDB } from '@core/datastore'
import picgo from '@core/picgo'

import uploader from 'apis/app/uploader'
import { uploadClipboardFiles } from 'apis/app/uploader/apis'
import { handleSecondaryUpload, uploadClipboardFiles } from 'apis/app/uploader/apis'
import windowManager from 'apis/app/window/windowManager'

import { buildPicBedListMenu } from '~/events/remotes/menu'
Expand Down Expand Up @@ -309,6 +309,7 @@ export function createTray(tooltip: string) {
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
const rawInput = cloneDeep(files)
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
await handleSecondaryUpload(trayWindow.webContents, files, 'tray')
const imgs = await uploader.setWebContents(trayWindow.webContents).upload(files)
const deleteLocalFile = db.get(configPaths.settings.deleteLocalFile) || false
if (imgs !== false) {
Expand Down
65 changes: 65 additions & 0 deletions src/main/apis/app/uploader/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import pasteTemplate from '~/utils/pasteTemplate'

import { IPasteStyle, IWindowList } from '#/types/enum'
import { configPaths } from '#/utils/configPaths'
import { changeCurrentUploader } from '~/utils/handleUploaderConfig'

const handleClipboardUploading = async (): Promise<false | ImgInfo[]> => {
const useBuiltinClipboard =
Expand All @@ -28,6 +29,7 @@ const handleClipboardUploading = async (): Promise<false | ImgInfo[]> => {
}

export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
await handleSecondaryUpload(undefined, undefined, 'clipboard')
const img = await handleClipboardUploading()
if (img !== false) {
if (img.length > 0) {
Expand Down Expand Up @@ -84,6 +86,7 @@ export const uploadChoosedFiles = async (
): Promise<IStringKeyMap[]> => {
const input = files.map(item => item.path)
const rawInput = cloneDeep(input)
await handleSecondaryUpload(webContents, input)
const imgs = await uploader.setWebContents(webContents).upload(input)
const result = []
if (imgs !== false) {
Expand Down Expand Up @@ -132,3 +135,65 @@ export const uploadChoosedFiles = async (
return []
}
}

export const handleSecondaryUpload = async (
webContents?: WebContents,
input?: string[],
uploadType: 'clipboard' | 'file' | 'tray' = 'file'
): Promise<void> => {
const enableSecondUploader = db.get(configPaths.settings.enableSecondUploader) || false
let currentPicBedType = ''
let currentPicBedConfig = {} as IStringKeyMap
let currentPicBedConfigId = ''
let needRestore = false
if (enableSecondUploader) {
const secondUploader = db.get(configPaths.picBed.secondUploader)
const secondUploaderConfig = db.get(configPaths.picBed.secondUploaderConfig)
const secondUploaderId = db.get(configPaths.picBed.secondUploaderId)
const currentPicBed = db.get('picBed') || ({} as IStringKeyMap)
currentPicBedType = currentPicBed.uploader || currentPicBed.current || 'smms'
currentPicBedConfig = currentPicBed[currentPicBedType] || ({} as IStringKeyMap)
currentPicBedConfigId = currentPicBedConfig._id
if (
secondUploader === currentPicBedType &&
secondUploaderConfig._configName === currentPicBedConfig._configName &&
secondUploaderId === currentPicBedConfigId
) {
picgo.log.info('second uploader is the same as current uploader')
} else {
needRestore = true
let secondImgs: ImgInfo[] | false = false
changeCurrentUploader(secondUploader, secondUploaderConfig, secondUploaderId)
if (uploadType === 'clipboard') {
secondImgs = await handleClipboardUploading()
} else {
secondImgs = await uploader.setWebContents(webContents!).upload(input)
}
if (secondImgs !== false) {
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)
if (uploadType === 'clipboard') {
if (secondImgs.length > 0) {
await GalleryDB.getInstance().insert(secondImgs[0])
trayWindow?.webContents?.send('clipboardFiles', [])
trayWindow?.webContents?.send('uploadFiles', secondImgs)
}
} else {
for (let i = 0; i < secondImgs.length; i++) {
await GalleryDB.getInstance().insert(secondImgs[i])
}
if (uploadType === 'tray') {
trayWindow?.webContents?.send('dragFiles', secondImgs)
} else {
trayWindow?.webContents?.send('uploadFiles', secondImgs)
}
}
if (windowManager.has(IWindowList.SETTING_WINDOW) && uploadType !== 'tray') {
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery')
}
}
}
}
if (needRestore) {
changeCurrentUploader(currentPicBedType, currentPicBedConfig, currentPicBedConfigId)
}
}
29 changes: 6 additions & 23 deletions src/main/apis/app/window/windowList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,9 @@ windowList.set(IWindowList.RENAME_WINDOW, {
window.loadURL(handleWindowParams(RENAME_WINDOW_URL))
const currentWindow = windowManager.getAvailableWindow(true)
if (currentWindow && currentWindow.isVisible()) {
// bounds: { x: 821, y: 75, width: 800, height: 450 }
const bounds = currentWindow.getBounds()
let positionX = bounds.x + bounds.width / 2 - 150
let positionY
// if is the settingWindow
if (bounds.height > 400) {
positionY = bounds.y + bounds.height / 2 - 88
} else {
// if is the miniWindow
positionY = bounds.y + bounds.height / 2
}
positionX = Math.floor(positionX)
positionY = Math.floor(positionY)
const { x, y, width, height } = currentWindow.getBounds()
const positionX = Math.floor(x + width / 2 - 150)
const positionY = Math.floor(y + height / 2 - (height > 400 ? 88 : 0))
window.setPosition(positionX, positionY, false)
}
}
Expand All @@ -259,16 +249,9 @@ windowList.set(IWindowList.TOOLBOX_WINDOW, {
window.loadURL(TOOLBOX_WINDOW_URL)
const currentWindow = windowManager.getAvailableWindow(true)
if (currentWindow && currentWindow.isVisible()) {
const bounds = currentWindow.getBounds()
let positionX = bounds.x + bounds.width / 2 - 400
let positionY
if (bounds.height > 400) {
positionY = bounds.y + bounds.height / 2 - 225
} else {
positionY = bounds.y + bounds.height / 2
}
positionX = Math.floor(positionX)
positionY = Math.floor(positionY)
const { x, y, width, height } = currentWindow.getBounds()
const positionX = Math.floor(x + width / 2 - 400)
const positionY = Math.floor(y + height / 2 - (height > 400 ? 225 : 0))
window.setPosition(positionX, positionY, false)
}
}
Expand Down
53 changes: 26 additions & 27 deletions src/main/apis/app/window/windowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,31 @@ class WindowManager implements IWindowManager {

create(name: IWindowList) {
const windowConfig: IWindowListItem = windowList.get(name)!
if (windowConfig.isValid) {
if (!windowConfig.multiple) {
if (this.has(name)) return this.#windowMap.get(name)!
}
const window = new BrowserWindow(windowConfig.options())
const id = window.id
if (windowConfig.multiple) {
this.#windowMap.set(`${name}_${window.id}`, window)
this.#windowIdMap.set(window.id, `${name}_${window.id}`)
} else {
this.#windowMap.set(name, window)
this.#windowIdMap.set(window.id, name)
}
windowConfig.callback(window, this)
window.on('close', () => {
this.deleteById(id)
})
return window
} else {
return null
if (!windowConfig.isValid) return null

if (!windowConfig.multiple) {
if (this.has(name)) return this.#windowMap.get(name)!
}

const window = new BrowserWindow(windowConfig.options())
const id = window.id
const windowName = windowConfig.multiple ? `${name}_${id}` : name

this.#windowMap.set(windowName, window)
this.#windowIdMap.set(id, windowName)

windowConfig.callback(window, this)
window.on('close', () => {
this.deleteById(id)
})
return window
}

get(name: IWindowList) {
if (this.has(name)) {
return this.#windowMap.get(name)!
} else {
const window = this.create(name)
return window
}
return this.create(name)
}

has(name: IWindowList) {
Expand All @@ -57,11 +52,15 @@ class WindowManager implements IWindowManager {
const miniWindow = this.#windowMap.get(IWindowList.MINI_WINDOW)
if (miniWindow && miniWindow.isVisible() && !isSkipMiniWindow) {
return miniWindow
} else {
const settingWindow = this.#windowMap.get(IWindowList.SETTING_WINDOW)
const trayWindow = this.#windowMap.get(IWindowList.TRAY_WINDOW)
return settingWindow || trayWindow || this.create(IWindowList.SETTING_WINDOW)!
}

const settingWindow = this.#windowMap.get(IWindowList.SETTING_WINDOW)
if (settingWindow) return settingWindow

const trayWindow = this.#windowMap.get(IWindowList.TRAY_WINDOW)
if (trayWindow) return trayWindow

return this.create(IWindowList.SETTING_WINDOW)!
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/apis/gui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import pasteTemplate from '~/utils/pasteTemplate'
import { SHOW_INPUT_BOX } from '#/events/constants'
import { IPasteStyle } from '#/types/enum'
import { configPaths } from '#/utils/configPaths'
import { handleSecondaryUpload } from '../app/uploader/apis'

// Cross-process support may be required in the future
class GuiApi implements IGuiApi {
Expand Down Expand Up @@ -78,6 +79,7 @@ class GuiApi implements IGuiApi {
this.windowId = await getWindowId()
const webContents = this.getWebcontentsByWindowId(this.windowId)
const rawInput = cloneDeep(input)
await handleSecondaryUpload(webContents!, input)
const imgs = await uploader.setWebContents(webContents!).upload(input)
if (imgs !== false) {
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
Expand Down
Loading

0 comments on commit 6d2884f

Please sign in to comment.