mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-07-09 22:43:09 +08:00
🐛 Fix(custom): fix an issue eslint not worked as expected
This commit is contained in:
@@ -36,10 +36,10 @@ class RemoteNoticeHandler {
|
||||
try {
|
||||
const localCountStorage: IRemoteNoticeLocalCountStorage = fs.readJSONSync(
|
||||
REMOTE_NOTICE_LOCAL_STORAGE_PATH,
|
||||
'utf8'
|
||||
'utf8',
|
||||
)
|
||||
this.remoteNoticeLocalCountStorage = localCountStorage
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
this.remoteNoticeLocalCountStorage = localCountStorage
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class RemoteNoticeHandler {
|
||||
const noticeInfo = (await axios({
|
||||
method: 'get',
|
||||
url: REMOTE_NOTICE_URL,
|
||||
responseType: 'json'
|
||||
responseType: 'json',
|
||||
}).then(res => res.data)) as IRemoteNotice
|
||||
return noticeInfo
|
||||
} catch {
|
||||
@@ -121,7 +121,7 @@ class RemoteNoticeHandler {
|
||||
if (action.data?.url) {
|
||||
shell.openExternal(action.data.url)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
break
|
||||
case IRemoteNoticeActionType.OPEN_URL:
|
||||
@@ -144,7 +144,7 @@ class RemoteNoticeHandler {
|
||||
title: action.data?.title || '',
|
||||
message: action.data?.content || '',
|
||||
type: 'info',
|
||||
buttons: action.data?.buttons?.map(item => item.label) || ['Yes']
|
||||
buttons: action.data?.buttons?.map(item => item.label) || ['Yes'],
|
||||
})
|
||||
.then(res => {
|
||||
const button = action.data?.buttons?.[res.response]
|
||||
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
IPluginShortKeyConfig,
|
||||
IShortKeyConfig,
|
||||
IShortKeyConfigs,
|
||||
IShortKeyHandler
|
||||
IShortKeyHandler,
|
||||
} from '#/types/types'
|
||||
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '~/events/constant'
|
||||
import { configPaths } from '~/utils/configPaths'
|
||||
@@ -78,7 +78,7 @@ class ShortKeyHandler {
|
||||
config: IShortKeyConfig | IPluginShortKeyConfig,
|
||||
command: string,
|
||||
handler: IShortKeyHandler,
|
||||
writeFlag: boolean
|
||||
writeFlag: boolean,
|
||||
) {
|
||||
shortKeyService.registerCommand(command, handler)
|
||||
if (config.key) {
|
||||
@@ -96,8 +96,8 @@ class ShortKeyHandler {
|
||||
enable: true,
|
||||
name: config.name,
|
||||
label: config.label,
|
||||
key: config.key
|
||||
}
|
||||
key: config.key,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class ShortKeyHandler {
|
||||
if (item.enable === false) {
|
||||
globalShortcut.unregister(item.key)
|
||||
picgo.saveConfig({
|
||||
[`settings.shortKey.${command}.enable`]: false
|
||||
[`settings.shortKey.${command}.enable`]: false,
|
||||
})
|
||||
return true
|
||||
} else {
|
||||
@@ -116,7 +116,7 @@ class ShortKeyHandler {
|
||||
return false
|
||||
} else {
|
||||
picgo.saveConfig({
|
||||
[`settings.shortKey.${command}.enable`]: true
|
||||
[`settings.shortKey.${command}.enable`]: true,
|
||||
})
|
||||
globalShortcut.register(item.key, () => {
|
||||
this.handler(command)
|
||||
@@ -132,7 +132,7 @@ class ShortKeyHandler {
|
||||
if (globalShortcut.isRegistered(item.key)) return false
|
||||
globalShortcut.unregister(oldKey)
|
||||
picgo.saveConfig({
|
||||
[`settings.shortKey.${command}.key`]: item.key
|
||||
[`settings.shortKey.${command}.key`]: item.key,
|
||||
})
|
||||
globalShortcut.register(item.key, () => {
|
||||
this.handler(`${from}:${item.name}`)
|
||||
@@ -183,7 +183,7 @@ class ShortKeyHandler {
|
||||
.map(command => {
|
||||
return {
|
||||
command,
|
||||
key: commands[command].key
|
||||
key: commands[command].key,
|
||||
}
|
||||
}) as IKeyCommandType[]
|
||||
keyList.forEach(item => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import logger from '@core/picgo/logger'
|
||||
import type { IShortKeyHandler } from '#/types/types'
|
||||
|
||||
class ShortKeyService {
|
||||
private commandList: Map<string, IShortKeyHandler> = new Map()
|
||||
private commandList = new Map<string, IShortKeyHandler>()
|
||||
registerCommand(command: string, handler: IShortKeyHandler) {
|
||||
this.commandList.set(command, handler)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
MenuItemConstructorOptions,
|
||||
nativeTheme,
|
||||
Notification,
|
||||
Tray
|
||||
Tray,
|
||||
} from 'electron'
|
||||
import fs from 'fs-extra'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
@@ -41,7 +41,7 @@ export function setDockMenu() {
|
||||
const dockMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: $t('OPEN_MAIN_WINDOW'),
|
||||
click: openMainWindow
|
||||
click: openMainWindow,
|
||||
},
|
||||
{
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
@@ -54,7 +54,7 @@ export function setDockMenu() {
|
||||
})
|
||||
setDockMenu()
|
||||
},
|
||||
visible: !isListeningClipboard
|
||||
visible: !isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
@@ -64,8 +64,8 @@ export function setDockMenu() {
|
||||
clipboardPoll.removeAllListeners()
|
||||
setDockMenu()
|
||||
},
|
||||
visible: isListeningClipboard
|
||||
}
|
||||
visible: isListeningClipboard,
|
||||
},
|
||||
])
|
||||
app.dock?.setMenu(dockMenu)
|
||||
}
|
||||
@@ -82,9 +82,9 @@ export function createMenu() {
|
||||
click() {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{ label: $t('CHOOSE_DEFAULT_PICBED'), type: 'submenu', submenu },
|
||||
{
|
||||
@@ -96,13 +96,13 @@ export function createMenu() {
|
||||
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', role: 'cut' },
|
||||
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', role: 'copy' },
|
||||
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', role: 'paste' },
|
||||
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', role: 'selectAll' }
|
||||
]
|
||||
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', role: 'selectAll' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: $t('QUIT'),
|
||||
submenu: [{ label: $t('QUIT'), role: 'quit' }]
|
||||
}
|
||||
submenu: [{ label: $t('QUIT'), role: 'quit' }],
|
||||
},
|
||||
])
|
||||
Menu.setApplicationMenu(appMenu)
|
||||
}
|
||||
@@ -138,21 +138,21 @@ export function createContextMenu() {
|
||||
{
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
click: startWatchClipboard,
|
||||
visible: !isListeningClipboard
|
||||
visible: !isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
click: stopWatchClipboard,
|
||||
visible: isListeningClipboard
|
||||
visible: isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('RELOAD_APP'),
|
||||
click() {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
}
|
||||
},
|
||||
},
|
||||
{ label: $t('QUIT'), role: 'quit' }
|
||||
{ label: $t('QUIT'), role: 'quit' },
|
||||
]
|
||||
if (process.platform === 'win32') {
|
||||
template.splice(
|
||||
@@ -163,13 +163,13 @@ export function createContextMenu() {
|
||||
click() {
|
||||
openMiniWindow(false)
|
||||
},
|
||||
visible: !isMiniWindowVisible
|
||||
visible: !isMiniWindowVisible,
|
||||
},
|
||||
{
|
||||
label: $t('HIDE_MINI_WINDOW'),
|
||||
click: hideMiniWindow,
|
||||
visible: isMiniWindowVisible
|
||||
}
|
||||
visible: isMiniWindowVisible,
|
||||
},
|
||||
)
|
||||
}
|
||||
contextMenu = Menu.buildFromTemplate(template)
|
||||
@@ -188,22 +188,22 @@ export function createContextMenu() {
|
||||
click() {
|
||||
openMiniWindow(false)
|
||||
},
|
||||
visible: !isMiniWindowVisible
|
||||
visible: !isMiniWindowVisible,
|
||||
},
|
||||
{
|
||||
label: $t('HIDE_MINI_WINDOW'),
|
||||
click: hideMiniWindow,
|
||||
visible: isMiniWindowVisible
|
||||
visible: isMiniWindowVisible,
|
||||
},
|
||||
{
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
click: startWatchClipboard,
|
||||
visible: !isListeningClipboard
|
||||
visible: !isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
click: stopWatchClipboard,
|
||||
visible: isListeningClipboard
|
||||
visible: isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('ABOUT'),
|
||||
@@ -212,11 +212,11 @@ export function createContextMenu() {
|
||||
title: 'PicList',
|
||||
message: 'PicList',
|
||||
buttons: ['Ok'],
|
||||
detail: `Version: ${pkg.version}\nAuthor: Kuingsmile\nGithub: https://github.com/Kuingsmile/PicList`
|
||||
detail: `Version: ${pkg.version}\nAuthor: Kuingsmile\nGithub: https://github.com/Kuingsmile/PicList`,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{ label: $t('QUIT'), role: 'quit' }
|
||||
{ label: $t('QUIT'), role: 'quit' },
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -258,14 +258,14 @@ export function createTray(tooltip: string) {
|
||||
const decodePath = ensureFilePath(imgPath)
|
||||
if (decodePath === imgPath) {
|
||||
obj.push({
|
||||
imgUrl: imgPath
|
||||
imgUrl: imgPath,
|
||||
})
|
||||
} else {
|
||||
if (decodePath !== '') {
|
||||
// 带有中文的路径,无法直接被img.src所使用,会被转义
|
||||
const base64 = await fs.readFile(decodePath.replace('file://', ''), { encoding: 'base64' })
|
||||
obj.push({
|
||||
imgUrl: `data:image/png;base64,${base64}`
|
||||
imgUrl: `data:image/png;base64,${base64}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,7 @@ export function createTray(tooltip: string) {
|
||||
obj.push({
|
||||
width: img.getSize().width,
|
||||
height: img.getSize().height,
|
||||
imgUrl
|
||||
imgUrl,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -333,7 +333,7 @@ export function createTray(tooltip: string) {
|
||||
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
||||
pasteStyle,
|
||||
imgs[i],
|
||||
db.get(configPaths.settings.customLink)
|
||||
db.get(configPaths.settings.customLink),
|
||||
)
|
||||
imgs[i].shortUrl = shortUrl
|
||||
pasteText.push(pasteTextItem)
|
||||
@@ -344,7 +344,7 @@ export function createTray(tooltip: string) {
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || imgs[i].imgUrl!
|
||||
body: shortUrl || imgs[i].imgUrl!,
|
||||
// icon: files[i]
|
||||
})
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -62,7 +62,7 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || img[0].imgUrl!
|
||||
body: shortUrl || img[0].imgUrl!,
|
||||
// icon: img[0].imgUrl
|
||||
})
|
||||
setTimeout(() => {
|
||||
@@ -78,30 +78,30 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
||||
}
|
||||
return {
|
||||
url: handleUrlEncodeWithSetting(inserted.imgUrl as string),
|
||||
fullResult: inserted
|
||||
fullResult: inserted,
|
||||
}
|
||||
} else {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_FAILED'),
|
||||
body: $t('TIPS_UPLOAD_NOT_PICTURES')
|
||||
body: $t('TIPS_UPLOAD_NOT_PICTURES'),
|
||||
})
|
||||
notification.show()
|
||||
return {
|
||||
url: '',
|
||||
fullResult: {}
|
||||
fullResult: {},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
url: '',
|
||||
fullResult: {}
|
||||
fullResult: {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const uploadChoosedFiles = async (
|
||||
webContents: WebContents,
|
||||
files: IFileWithPath[]
|
||||
files: IFileWithPath[],
|
||||
): Promise<IStringKeyMap[]> => {
|
||||
const input = files.map(item => item.path)
|
||||
const rawInput = cloneDeep(input)
|
||||
@@ -132,7 +132,7 @@ export const uploadChoosedFiles = async (
|
||||
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
||||
pasteStyle,
|
||||
imgs[i],
|
||||
db.get(configPaths.settings.customLink)
|
||||
db.get(configPaths.settings.customLink),
|
||||
)
|
||||
imgs[i].shortUrl = shortUrl
|
||||
pasteText.push(pasteTextItem)
|
||||
@@ -144,7 +144,7 @@ export const uploadChoosedFiles = async (
|
||||
if (imgLength <= 3) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || imgs[i].imgUrl!
|
||||
body: shortUrl || imgs[i].imgUrl!,
|
||||
// icon: files[i].path
|
||||
})
|
||||
setTimeout(() => {
|
||||
@@ -153,7 +153,7 @@ export const uploadChoosedFiles = async (
|
||||
} else if (i === imgLength - 1) {
|
||||
const notification = new Notification({
|
||||
title: $t('MULTI_UPLOAD_SUCCEED', { n: imgLength }),
|
||||
body: ''
|
||||
body: '',
|
||||
})
|
||||
setTimeout(() => {
|
||||
notification.show()
|
||||
@@ -163,7 +163,7 @@ export const uploadChoosedFiles = async (
|
||||
const inserted = await GalleryDB.getInstance().insert(imgs[i])
|
||||
result.push({
|
||||
url: handleUrlEncodeWithSetting(inserted.imgUrl!),
|
||||
fullResult: inserted
|
||||
fullResult: inserted,
|
||||
})
|
||||
}
|
||||
handleCopyUrl(pasteText.join('\n'))
|
||||
@@ -181,7 +181,7 @@ export const uploadChoosedFiles = async (
|
||||
export const handleSecondaryUpload = async (
|
||||
webContents?: WebContents,
|
||||
input?: string[],
|
||||
uploadType: 'clipboard' | 'file' | 'tray' = 'file'
|
||||
uploadType: 'clipboard' | 'file' | 'tray' = 'file',
|
||||
): Promise<{ needRestore: boolean; ctx: IPicGo | false }> => {
|
||||
const enableSecondUploader = db.get(configPaths.settings.enableSecondUploader) || false
|
||||
let currentPicBedType = ''
|
||||
@@ -242,6 +242,6 @@ export const handleSecondaryUpload = async (
|
||||
}
|
||||
return {
|
||||
needRestore,
|
||||
ctx
|
||||
ctx,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class Uploader {
|
||||
if (db.get(configPaths.settings.uploadNotification)) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_PROGRESS'),
|
||||
body: $t('UPLOADING')
|
||||
body: $t('UPLOADING'),
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
@@ -85,10 +85,10 @@ class Uploader {
|
||||
name = await waitForRename(window, window.webContents.id)
|
||||
}
|
||||
item.fileName = name || fileName
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class Uploader {
|
||||
showNotification({
|
||||
title: $t('UPLOAD_FAILED'),
|
||||
body: util.format(e.stack),
|
||||
clickToCopy: true
|
||||
clickToCopy: true,
|
||||
})
|
||||
}, 500)
|
||||
return false
|
||||
@@ -186,7 +186,7 @@ class Uploader {
|
||||
showNotification({
|
||||
title: $t('UPLOAD_FAILED'),
|
||||
body: util.format(e.stack),
|
||||
clickToCopy: true
|
||||
clickToCopy: true,
|
||||
})
|
||||
}, 500)
|
||||
return false
|
||||
|
||||
@@ -20,11 +20,11 @@ const windowList = new Map<string, IWindowListItem>()
|
||||
const getDefaultWindowSizes = (): { width: number; height: number } => {
|
||||
const [mainWindowWidth, mainWindowHeight] = db.get([
|
||||
configPaths.settings.mainWindowWidth,
|
||||
configPaths.settings.mainWindowHeight
|
||||
configPaths.settings.mainWindowHeight,
|
||||
])
|
||||
return {
|
||||
width: mainWindowWidth || 1200,
|
||||
height: mainWindowHeight || 800
|
||||
height: mainWindowHeight || 800,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ const trayWindowOptions = {
|
||||
contextIsolation: true,
|
||||
nodeIntegrationInWorker: false,
|
||||
backgroundThrottling: true,
|
||||
webSecurity: false
|
||||
}
|
||||
webSecurity: false,
|
||||
},
|
||||
}
|
||||
|
||||
const settingWindowOptions = {
|
||||
@@ -88,8 +88,8 @@ const settingWindowOptions = {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
nodeIntegrationInWorker: false,
|
||||
webSecurity: false
|
||||
}
|
||||
webSecurity: false,
|
||||
},
|
||||
} as IBrowserWindowOptions
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
@@ -113,8 +113,8 @@ const miniWindowOptions = {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
backgroundThrottling: true,
|
||||
nodeIntegrationInWorker: false
|
||||
}
|
||||
nodeIntegrationInWorker: false,
|
||||
},
|
||||
} as IBrowserWindowOptions
|
||||
|
||||
if (db.get(configPaths.settings.miniWindowOntop)) {
|
||||
@@ -134,8 +134,8 @@ const renameWindowOptions = {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
nodeIntegrationInWorker: false,
|
||||
backgroundThrottling: false
|
||||
}
|
||||
backgroundThrottling: false,
|
||||
},
|
||||
} as IBrowserWindowOptions
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
@@ -163,8 +163,8 @@ const toolboxWindowOptions = {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
nodeIntegrationInWorker: false,
|
||||
webSecurity: false
|
||||
}
|
||||
webSecurity: false,
|
||||
},
|
||||
} as IBrowserWindowOptions
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
@@ -186,7 +186,7 @@ windowList.set(IWindowList.TRAY_WINDOW, {
|
||||
window.on('blur', () => {
|
||||
window.hide()
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
windowList.set(IWindowList.SETTING_WINDOW, {
|
||||
@@ -198,7 +198,7 @@ windowList.set(IWindowList.SETTING_WINDOW, {
|
||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#main-page/upload`)
|
||||
} else {
|
||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||
hash: 'main-page/upload'
|
||||
hash: 'main-page/upload',
|
||||
})
|
||||
}
|
||||
window.on('closed', () => {
|
||||
@@ -211,7 +211,7 @@ windowList.set(IWindowList.SETTING_WINDOW, {
|
||||
})
|
||||
bus.emit(CREATE_APP_MENU)
|
||||
windowManager.create(IWindowList.MINI_WINDOW)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
windowList.set(IWindowList.MINI_WINDOW, {
|
||||
@@ -223,10 +223,10 @@ windowList.set(IWindowList.MINI_WINDOW, {
|
||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#mini-page`)
|
||||
} else {
|
||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||
hash: 'mini-page'
|
||||
hash: 'mini-page',
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
windowList.set(IWindowList.RENAME_WINDOW, {
|
||||
@@ -238,7 +238,7 @@ windowList.set(IWindowList.RENAME_WINDOW, {
|
||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#rename-page`)
|
||||
} else {
|
||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||
hash: 'rename-page'
|
||||
hash: 'rename-page',
|
||||
})
|
||||
}
|
||||
const currentWindow = windowManager.getAvailableWindow(true)
|
||||
@@ -248,7 +248,7 @@ windowList.set(IWindowList.RENAME_WINDOW, {
|
||||
const positionY = Math.floor(y + height / 2 - (height > 400 ? 88 : 0))
|
||||
window.setPosition(positionX, positionY, false)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
windowList.set(IWindowList.TOOLBOX_WINDOW, {
|
||||
@@ -260,7 +260,7 @@ windowList.set(IWindowList.TOOLBOX_WINDOW, {
|
||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#toolbox-page`)
|
||||
} else {
|
||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||
hash: 'toolbox-page'
|
||||
hash: 'toolbox-page',
|
||||
})
|
||||
}
|
||||
const currentWindow = windowManager.getAvailableWindow(true)
|
||||
@@ -270,7 +270,7 @@ windowList.set(IWindowList.TOOLBOX_WINDOW, {
|
||||
const positionY = Math.floor(y + height / 2 - (height > 400 ? 225 : 0))
|
||||
window.setPosition(positionX, positionY, false)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default windowList
|
||||
|
||||
@@ -5,8 +5,8 @@ import type { IWindowListItem, IWindowManager } from '#/types/electron'
|
||||
import { IWindowList } from '~/utils/enum'
|
||||
|
||||
class WindowManager implements IWindowManager {
|
||||
#windowMap: Map<string, BrowserWindow> = new Map()
|
||||
#windowIdMap: Map<number, string> = new Map()
|
||||
#windowMap = new Map<string, BrowserWindow>()
|
||||
#windowIdMap = new Map<number, string>()
|
||||
|
||||
create(name: string) {
|
||||
const windowConfig: IWindowListItem = windowList.get(name)!
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
UPLOAD_WITH_CLIPBOARD_FILES,
|
||||
UPLOAD_WITH_CLIPBOARD_FILES_RESPONSE,
|
||||
UPLOAD_WITH_FILES,
|
||||
UPLOAD_WITH_FILES_RESPONSE
|
||||
UPLOAD_WITH_FILES_RESPONSE,
|
||||
} from '@core/bus/constants'
|
||||
import bus from '@core/bus/index'
|
||||
|
||||
@@ -21,11 +21,11 @@ export const uploadWithClipboardFiles = (): Promise<{
|
||||
if (result) {
|
||||
return resolve({
|
||||
success: true,
|
||||
result: [result]
|
||||
result: [result],
|
||||
})
|
||||
} else {
|
||||
return resolve({
|
||||
success: false
|
||||
success: false,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -34,7 +34,7 @@ export const uploadWithClipboardFiles = (): Promise<{
|
||||
}
|
||||
|
||||
export const uploadWithFiles = (
|
||||
pathList: IFileWithPath[]
|
||||
pathList: IFileWithPath[],
|
||||
): Promise<{
|
||||
success: boolean
|
||||
result?: string[]
|
||||
@@ -44,11 +44,11 @@ export const uploadWithFiles = (
|
||||
if (result.length) {
|
||||
return resolve({
|
||||
success: true,
|
||||
result
|
||||
result,
|
||||
})
|
||||
} else {
|
||||
return resolve({
|
||||
success: false
|
||||
success: false,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ let hasCheckPath = false
|
||||
|
||||
const errorMsg = {
|
||||
broken: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT'),
|
||||
brokenButBackup: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP')
|
||||
brokenButBackup: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP'),
|
||||
}
|
||||
|
||||
function dbChecker() {
|
||||
@@ -42,28 +42,28 @@ function dbChecker() {
|
||||
let configFile: string = '{}'
|
||||
const optionsTpl = {
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: ''
|
||||
body: '',
|
||||
}
|
||||
// config save bak
|
||||
try {
|
||||
configFile = fs.readFileSync(configFilePath, { encoding: 'utf-8' })
|
||||
JSON.parse(configFile)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
fs.unlinkSync(configFilePath)
|
||||
if (fs.existsSync(configFileBackupPath)) {
|
||||
try {
|
||||
configFile = fs.readFileSync(configFileBackupPath, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
JSON.parse(configFile)
|
||||
writeFile.sync(configFilePath, configFile, { encoding: 'utf-8' })
|
||||
const stats = fs.statSync(configFileBackupPath)
|
||||
optionsTpl.body = `${errorMsg.brokenButBackup}\n${$t('TIPS_PICGO_BACKUP_FILE_VERSION', {
|
||||
v: dayjs(stats.mtime).format('YYYY-MM-DD HH:mm:ss')
|
||||
v: dayjs(stats.mtime).format('YYYY-MM-DD HH:mm:ss'),
|
||||
})}`
|
||||
notificationList.push(optionsTpl)
|
||||
return
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
optionsTpl.body = errorMsg.broken
|
||||
notificationList.push(optionsTpl)
|
||||
return
|
||||
@@ -92,7 +92,7 @@ function dbPathChecker(): string {
|
||||
}
|
||||
try {
|
||||
const configString = fs.readFileSync(defaultConfigPath, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
const config = JSON.parse(configString)
|
||||
const userConfigPath: string = config.configPath || ''
|
||||
@@ -109,7 +109,7 @@ function dbPathChecker(): string {
|
||||
if (!hasCheckPath) {
|
||||
const optionsTpl = {
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR')
|
||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR'),
|
||||
}
|
||||
notificationList.push(optionsTpl)
|
||||
hasCheckPath = true
|
||||
@@ -133,7 +133,7 @@ function getGalleryDBPath(): {
|
||||
const dbBackupPath = path.join(path.dirname(dbPath), 'piclist.bak.db')
|
||||
return {
|
||||
dbPath,
|
||||
dbBackupPath
|
||||
dbBackupPath,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ class ConfigStore {
|
||||
current: 'smms', // deprecated
|
||||
uploader: 'smms',
|
||||
smms: {
|
||||
token: ''
|
||||
}
|
||||
token: '',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class ConfigStore {
|
||||
enable: true,
|
||||
key: 'CommandOrControl+Alt+P',
|
||||
name: 'upload',
|
||||
label: $t('QUICK_UPLOAD')
|
||||
label: $t('QUICK_UPLOAD'),
|
||||
})
|
||||
}
|
||||
this.read()
|
||||
|
||||
@@ -14,7 +14,7 @@ const picgo = await PicGo.create(CONFIG_PATH)
|
||||
|
||||
picgo.saveConfig({
|
||||
debug: true,
|
||||
PICGO_ENV: 'GUI'
|
||||
PICGO_ENV: 'GUI',
|
||||
})
|
||||
|
||||
picgo.GUI_VERSION = pkg.version
|
||||
|
||||
@@ -21,7 +21,7 @@ const checkLogFileIsLarge = (logPath: string): CheckLogFileResult => {
|
||||
return {
|
||||
isLarge: logFileSize > DEFAULT_LOG_FILE_SIZE_LIMIT,
|
||||
logFileSize,
|
||||
logFileSizeLimit: DEFAULT_LOG_FILE_SIZE_LIMIT
|
||||
logFileSizeLimit: DEFAULT_LOG_FILE_SIZE_LIMIT,
|
||||
}
|
||||
}
|
||||
return { isLarge: false }
|
||||
|
||||
@@ -26,12 +26,12 @@ export default class AlistApi {
|
||||
url: `${url}/api/fs/remove`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: token
|
||||
Authorization: token,
|
||||
},
|
||||
data: {
|
||||
dir: path.join('/', uploadPath, path.dirname(fileName)),
|
||||
names: [path.basename(fileName)]
|
||||
}
|
||||
names: [path.basename(fileName)],
|
||||
},
|
||||
})
|
||||
const ok = result.data.code === 200
|
||||
deleteLog(fileName, 'Alist', ok)
|
||||
|
||||
@@ -18,7 +18,7 @@ interface IConfigMap {
|
||||
const getAListToken = async (url: string, username: string, password: string) => {
|
||||
const res = await axios.post(`${url}/api/auth/login`, {
|
||||
username,
|
||||
password
|
||||
password,
|
||||
})
|
||||
if (res.data.code === 200 && res.data.message === 'success') {
|
||||
return res.data.data.token
|
||||
@@ -43,12 +43,12 @@ export default class AListplistApi {
|
||||
url: `${url}/api/fs/remove`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: token
|
||||
Authorization: token,
|
||||
},
|
||||
data: {
|
||||
dir: path.join('/', uploadPath, path.dirname(fileName)),
|
||||
names: [path.basename(fileName)]
|
||||
}
|
||||
names: [path.basename(fileName)],
|
||||
},
|
||||
})
|
||||
const ok = result.data.code === 200
|
||||
deleteLog(fileName, 'Alist', ok)
|
||||
|
||||
@@ -35,7 +35,7 @@ const apiMap: IStringKeyMap = {
|
||||
smms: SmmsApi,
|
||||
tcyun: TcyunApi,
|
||||
upyun: UpyunApi,
|
||||
webdavplist: WebdavApi
|
||||
webdavplist: WebdavApi,
|
||||
}
|
||||
|
||||
export default class ALLApi {
|
||||
|
||||
@@ -12,7 +12,7 @@ interface IConfigMap {
|
||||
export default class GithubApi {
|
||||
static #createOctokit(token: string) {
|
||||
return new Octokit({
|
||||
auth: token
|
||||
auth: token,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export default class GithubApi {
|
||||
const {
|
||||
fileName,
|
||||
hash,
|
||||
config: { repo, token, branch, path }
|
||||
config: { repo, token, branch, path },
|
||||
} = configMap
|
||||
const [owner, repoName] = repo.split('/')
|
||||
const octokit = GithubApi.#createOctokit(token)
|
||||
@@ -37,7 +37,7 @@ export default class GithubApi {
|
||||
path: key,
|
||||
message: `delete ${fileName} by PicList`,
|
||||
sha: hash,
|
||||
branch
|
||||
branch,
|
||||
})
|
||||
const ok = status === 200
|
||||
deleteLog(fileName, 'GitHub', ok)
|
||||
|
||||
@@ -28,7 +28,7 @@ export default class ImgurApi {
|
||||
try {
|
||||
const response: AxiosResponse = await axios.delete(apiUrl, {
|
||||
headers: { Authorization },
|
||||
timeout: 30000
|
||||
timeout: 30000,
|
||||
})
|
||||
const ok = response.status === 200
|
||||
deleteLog(hash, 'Imgur', ok)
|
||||
|
||||
@@ -21,17 +21,17 @@ export default class LskyplistApi {
|
||||
|
||||
const v2Headers = {
|
||||
Accept: 'application/json',
|
||||
Authorization: token || undefined
|
||||
Authorization: token || undefined,
|
||||
}
|
||||
|
||||
const requestAgent = new https.Agent({
|
||||
rejectUnauthorized: false
|
||||
rejectUnauthorized: false,
|
||||
})
|
||||
try {
|
||||
const response: AxiosResponse = await axios.delete(`${host}/api/v1/images/${hash}`, {
|
||||
headers: v2Headers,
|
||||
timeout: 30000,
|
||||
httpsAgent: requestAgent
|
||||
httpsAgent: requestAgent,
|
||||
})
|
||||
const ok = response.status === 200 && response.data.status === true
|
||||
deleteLog(hash, 'Lskyplist', ok)
|
||||
|
||||
@@ -18,7 +18,7 @@ export default class PiclistApi {
|
||||
|
||||
try {
|
||||
const response: AxiosResponse = await axios.post(url, {
|
||||
list: [fullResult]
|
||||
list: [fullResult],
|
||||
})
|
||||
const ok = response.status === 200 && response.data?.success
|
||||
deleteLog(fullResult, 'Piclist', ok)
|
||||
|
||||
@@ -11,7 +11,7 @@ export default class QiniuApi {
|
||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||
const {
|
||||
fileName,
|
||||
config: { accessKey, secretKey, bucket, path }
|
||||
config: { accessKey, secretKey, bucket, path },
|
||||
} = configMap
|
||||
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey)
|
||||
const qiniuConfig = new qiniu.conf.Config()
|
||||
@@ -26,7 +26,7 @@ export default class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -23,13 +23,13 @@ export default class SmmsApi {
|
||||
try {
|
||||
const response: AxiosResponse = await axios.get(`${SmmsApi.#baseUrl}/delete/${hash}`, {
|
||||
headers: {
|
||||
Authorization: token
|
||||
Authorization: token,
|
||||
},
|
||||
params: {
|
||||
hash,
|
||||
format: 'json'
|
||||
format: 'json',
|
||||
},
|
||||
timeout: 30000
|
||||
timeout: 30000,
|
||||
})
|
||||
const ok = response.status === 200
|
||||
deleteLog(hash, 'Smms', ok)
|
||||
|
||||
@@ -10,14 +10,14 @@ export default class TcyunApi {
|
||||
static #createCOS(SecretId: string, SecretKey: string): COS {
|
||||
return new COS({
|
||||
SecretId,
|
||||
SecretKey
|
||||
SecretKey,
|
||||
})
|
||||
}
|
||||
|
||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||
const {
|
||||
fileName,
|
||||
config: { secretId, secretKey, bucket, area, path }
|
||||
config: { secretId, secretKey, bucket, area, path },
|
||||
} = configMap
|
||||
try {
|
||||
const cos = TcyunApi.#createCOS(secretId, secretKey)
|
||||
@@ -30,7 +30,7 @@ export default class TcyunApi {
|
||||
const result = await cos.deleteObject({
|
||||
Bucket: bucket,
|
||||
Region: area,
|
||||
Key: key
|
||||
Key: key,
|
||||
})
|
||||
const ok = result.statusCode === 204
|
||||
deleteLog(fileName, 'Tcyun', ok)
|
||||
|
||||
@@ -12,7 +12,7 @@ export default class UpyunApi {
|
||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||
const {
|
||||
fileName,
|
||||
config: { bucket, operator, password, path }
|
||||
config: { bucket, operator, password, path },
|
||||
} = configMap
|
||||
try {
|
||||
const service = new Upyun.Service(bucket, operator, password)
|
||||
|
||||
@@ -13,12 +13,12 @@ export default class WebdavApi {
|
||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||
const {
|
||||
fileName,
|
||||
config: { host, username, password, path, sslEnabled, authType }
|
||||
config: { host, username, password, path, sslEnabled, authType },
|
||||
} = configMap
|
||||
const endpoint = formatEndpoint(host, sslEnabled)
|
||||
const options: WebDAVClientOptions = {
|
||||
username,
|
||||
password
|
||||
password,
|
||||
}
|
||||
if (authType === 'digest') {
|
||||
options.authType = AuthType.Digest
|
||||
|
||||
@@ -16,7 +16,7 @@ import type {
|
||||
IShowMessageBoxOption,
|
||||
IShowMessageBoxResult,
|
||||
IShowNotificationOption,
|
||||
IUploadOption
|
||||
IUploadOption,
|
||||
} from '#/types/types'
|
||||
import { SHOW_INPUT_BOX } from '~/events/constant'
|
||||
import { T as $t } from '~/i18n'
|
||||
@@ -62,8 +62,8 @@ class GuiApi implements IGuiApi {
|
||||
async showInputBox(
|
||||
options: IShowInputBoxOption = {
|
||||
title: '',
|
||||
placeholder: ''
|
||||
}
|
||||
placeholder: '',
|
||||
},
|
||||
) {
|
||||
await this.showSettingWindow()
|
||||
this.getWebcontentsByWindowId(this.settingWindowId)?.send(SHOW_INPUT_BOX, options)
|
||||
@@ -103,7 +103,7 @@ class GuiApi implements IGuiApi {
|
||||
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
||||
pasteStyle,
|
||||
imgs[i],
|
||||
db.get(configPaths.settings.customLink)
|
||||
db.get(configPaths.settings.customLink),
|
||||
)
|
||||
imgs[i].shortUrl = shortUrl
|
||||
pasteText.push(pasteTextItem)
|
||||
@@ -114,7 +114,7 @@ class GuiApi implements IGuiApi {
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || (imgs[i].imgUrl! as string)
|
||||
body: shortUrl || (imgs[i].imgUrl! as string),
|
||||
// icon: imgs[i].imgUrl
|
||||
})
|
||||
setTimeout(() => {
|
||||
@@ -134,12 +134,12 @@ class GuiApi implements IGuiApi {
|
||||
showNotification(
|
||||
options: IShowNotificationOption = {
|
||||
title: '',
|
||||
body: ''
|
||||
}
|
||||
body: '',
|
||||
},
|
||||
) {
|
||||
const notification = new Notification({
|
||||
title: options.title,
|
||||
body: options.body
|
||||
body: options.body,
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
@@ -149,8 +149,8 @@ class GuiApi implements IGuiApi {
|
||||
title: '',
|
||||
message: '',
|
||||
type: 'info',
|
||||
buttons: ['Yes', 'No']
|
||||
}
|
||||
buttons: ['Yes', 'No'],
|
||||
},
|
||||
) {
|
||||
return new Promise<IShowMessageBoxResult>(resolve => {
|
||||
getWindowId().then(id => {
|
||||
@@ -158,7 +158,7 @@ class GuiApi implements IGuiApi {
|
||||
dialog.showMessageBox(BrowserWindow.fromId(id)!, options as MessageBoxOptions).then(res => {
|
||||
resolve({
|
||||
result: res.response,
|
||||
checkboxChecked: res.checkboxChecked
|
||||
checkboxChecked: res.checkboxChecked,
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -174,7 +174,7 @@ class GuiApi implements IGuiApi {
|
||||
return {
|
||||
defaultConfigPath,
|
||||
currentConfigPath,
|
||||
galleryDBPath
|
||||
galleryDBPath,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class GuiApi implements IGuiApi {
|
||||
title: $t('TIPS_WARNING'),
|
||||
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||
type: 'info',
|
||||
buttons: ['Yes', 'No']
|
||||
buttons: ['Yes', 'No'],
|
||||
})
|
||||
.then(res => {
|
||||
if (res.result === 0) {
|
||||
@@ -201,7 +201,7 @@ class GuiApi implements IGuiApi {
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
if (prop === 'removeById') {
|
||||
@@ -214,7 +214,7 @@ class GuiApi implements IGuiApi {
|
||||
title: $t('TIPS_WARNING'),
|
||||
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||
type: 'info',
|
||||
buttons: ['Yes', 'No']
|
||||
buttons: ['Yes', 'No'],
|
||||
})
|
||||
.then(res => {
|
||||
if (res.result === 0) {
|
||||
@@ -224,11 +224,11 @@ class GuiApi implements IGuiApi {
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
return Reflect.get(target, prop)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user