mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-11 18:10:32 +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)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,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 { createMenu } from 'apis/app/system'
|
||||
import { uploadChoosedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis'
|
||||
@@ -24,7 +24,7 @@ function initEventCenter() {
|
||||
[UPLOAD_WITH_FILES]: busCallUploadFiles,
|
||||
[GET_WINDOW_ID]: busCallGetWindowId,
|
||||
[GET_SETTING_WINDOW_ID]: busCallGetSettingWindowId,
|
||||
[CREATE_APP_MENU]: createMenu
|
||||
[CREATE_APP_MENU]: createMenu,
|
||||
}
|
||||
for (const i in eventList) {
|
||||
bus.on(i, eventList[i])
|
||||
@@ -57,5 +57,5 @@ function busCallGetSettingWindowId() {
|
||||
export default {
|
||||
listen() {
|
||||
initEventCenter()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
PICGO_HANDLE_PLUGIN_DONE,
|
||||
PICGO_HANDLE_PLUGIN_ING,
|
||||
PICGO_TOGGLE_PLUGIN,
|
||||
SHOW_MAIN_PAGE_QRCODE
|
||||
SHOW_MAIN_PAGE_QRCODE,
|
||||
} from '~/events/constant'
|
||||
import { handlePluginUninstall, handlePluginUpdate } from '~/events/rpc/routes/plugin/utils'
|
||||
import { T as $t } from '~/i18n'
|
||||
@@ -37,24 +37,24 @@ const buildMiniPageMenu = () => {
|
||||
const template: (MenuItemConstructorOptions | MenuItem)[] = [
|
||||
{
|
||||
label: $t('OPEN_MAIN_WINDOW'),
|
||||
click: openMainWindow
|
||||
click: openMainWindow,
|
||||
},
|
||||
{
|
||||
label: $t('CHOOSE_DEFAULT_PICBED'),
|
||||
type: 'submenu',
|
||||
submenu
|
||||
submenu,
|
||||
},
|
||||
{
|
||||
label: $t('UPLOAD_BY_CLIPBOARD'),
|
||||
click() {
|
||||
uploadClipboardFiles()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('HIDE_MINI_WINDOW'),
|
||||
click() {
|
||||
BrowserWindow.getFocusedWindow()!.hide()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
@@ -67,7 +67,7 @@ const buildMiniPageMenu = () => {
|
||||
})
|
||||
buildMiniPageMenu()
|
||||
},
|
||||
visible: !isListeningClipboard
|
||||
visible: !isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
@@ -77,19 +77,19 @@ const buildMiniPageMenu = () => {
|
||||
ClipboardWatcher.removeAllListeners()
|
||||
buildMiniPageMenu()
|
||||
},
|
||||
visible: isListeningClipboard
|
||||
visible: isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('RELOAD_APP'),
|
||||
click() {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
role: 'quit',
|
||||
label: $t('QUIT')
|
||||
}
|
||||
label: $t('QUIT'),
|
||||
},
|
||||
]
|
||||
return Menu.buildFromTemplate(template)
|
||||
}
|
||||
@@ -102,36 +102,36 @@ const buildMainPageMenu = (win: BrowserWindow) => {
|
||||
dialog.showMessageBox({
|
||||
title: 'PicList',
|
||||
message: 'PicList',
|
||||
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('SHOW_PICBED_QRCODE'),
|
||||
click() {
|
||||
win?.webContents?.send(SHOW_MAIN_PAGE_QRCODE)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('OPEN_TOOLBOX'),
|
||||
click() {
|
||||
const window = windowManager.create(IWindowList.TOOLBOX_WINDOW)
|
||||
window?.show()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('SHOW_DEVTOOLS'),
|
||||
click() {
|
||||
win?.webContents?.openDevTools({ mode: 'detach' })
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('FEEDBACK'),
|
||||
click() {
|
||||
const url = 'https://github.com/Kuingsmile/PicList/issues'
|
||||
shell.openExternal(url)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
] as (MenuItemConstructorOptions | MenuItem)[]
|
||||
return Menu.buildFromTemplate(template)
|
||||
}
|
||||
@@ -145,11 +145,11 @@ const buildSecondPicBedMenu = () => {
|
||||
const currentPicBedMenuItem = [
|
||||
{
|
||||
label: `${$t('CURRENT_SECOND_PICBED')} - ${currentPicBedName || 'None'}`,
|
||||
enabled: false
|
||||
enabled: false,
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
}
|
||||
type: 'separator',
|
||||
},
|
||||
]
|
||||
let submenu = picBeds
|
||||
.filter(item => item.visible)
|
||||
@@ -168,19 +168,19 @@ const buildSecondPicBedMenu = () => {
|
||||
// see: https://github.com/electron/electron/issues/21292
|
||||
type: 'checkbox',
|
||||
checked: config._id === defaultSecondUploaderId && item.type === secondUploader,
|
||||
click: function () {
|
||||
click() {
|
||||
changeSecondUploader(item.type, config, config._id)
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
: undefined,
|
||||
click: !hasSubmenu
|
||||
? function () {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.secondUploader]: item.type
|
||||
[configPaths.picBed.secondUploader]: item.type,
|
||||
})
|
||||
}
|
||||
: undefined
|
||||
: undefined,
|
||||
}
|
||||
})
|
||||
// @ts-expect-error submenu type
|
||||
@@ -197,11 +197,11 @@ const buildPicBedListMenu = () => {
|
||||
const currentPicBedMenuItem = [
|
||||
{
|
||||
label: `${$t('CURRENT_PICBED')} - ${currentPicBedName}`,
|
||||
enabled: false
|
||||
enabled: false,
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
}
|
||||
type: 'separator',
|
||||
},
|
||||
]
|
||||
let submenu = picBeds
|
||||
.filter(item => item.visible)
|
||||
@@ -221,13 +221,13 @@ const buildPicBedListMenu = () => {
|
||||
// see: https://github.com/electron/electron/issues/21292
|
||||
type: 'checkbox',
|
||||
checked: config._id === defaultId && item.type === currentPicBed,
|
||||
click: function () {
|
||||
click() {
|
||||
changeCurrentUploader(item.type, config, config._id)
|
||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('syncPicBed')
|
||||
}
|
||||
setTrayToolTip(`${item.type} ${config._configName || 'Default'}`)
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
: undefined,
|
||||
@@ -235,14 +235,14 @@ const buildPicBedListMenu = () => {
|
||||
? function () {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.current]: item.type,
|
||||
[configPaths.picBed.uploader]: item.type
|
||||
[configPaths.picBed.uploader]: item.type,
|
||||
})
|
||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('syncPicBed')
|
||||
}
|
||||
setTrayToolTip(item.type)
|
||||
}
|
||||
: undefined
|
||||
: undefined,
|
||||
}
|
||||
})
|
||||
// @ts-expect-error submenu type
|
||||
@@ -259,7 +259,7 @@ const handleRestoreState = (item: string, name: string): void => {
|
||||
if (current === name) {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.current]: 'smms',
|
||||
[configPaths.picBed.uploader]: 'smms'
|
||||
[configPaths.picBed.uploader]: 'smms',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,7 @@ const handleRestoreState = (item: string, name: string): void => {
|
||||
const current = picgo.getConfig(configPaths.picBed.transformer)
|
||||
if (current === name) {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.transformer]: 'path'
|
||||
[configPaths.picBed.transformer]: 'path',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -280,18 +280,18 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
enabled: !plugin.enabled,
|
||||
click() {
|
||||
picgo.saveConfig({
|
||||
[`picgoPlugins.${plugin.fullName}`]: true
|
||||
[`picgoPlugins.${plugin.fullName}`]: true,
|
||||
})
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_TOGGLE_PLUGIN, plugin.fullName, true)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('DISABLE_PLUGIN'),
|
||||
enabled: plugin.enabled,
|
||||
click() {
|
||||
picgo.saveConfig({
|
||||
[`picgoPlugins.${plugin.fullName}`]: false
|
||||
[`picgoPlugins.${plugin.fullName}`]: false,
|
||||
})
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||
@@ -303,7 +303,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
if (plugin.config.uploader.name) {
|
||||
handleRestoreState('uploader', plugin.config.uploader.name)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('UNINSTALL_PLUGIN'),
|
||||
@@ -311,7 +311,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||
handlePluginUninstall(plugin.fullName)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('UPDATE_PLUGIN'),
|
||||
@@ -319,14 +319,14 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||
handlePluginUpdate(plugin.fullName)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
] as (MenuItemConstructorOptions | MenuItem)[]
|
||||
for (const i in plugin.config) {
|
||||
if (plugin.config[i].config.length > 0) {
|
||||
const obj = {
|
||||
label: $t('CONFIG_THING', {
|
||||
c: `${i} - ${plugin.config[i].fullName || plugin.config[i].name}`
|
||||
c: `${i} - ${plugin.config[i].fullName || plugin.config[i].name}`,
|
||||
}),
|
||||
click() {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
@@ -334,7 +334,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const configName = plugin.config[i].fullName || plugin.config[i].name
|
||||
const config = plugin.config[i].config
|
||||
window.webContents.send(PICGO_CONFIG_PLUGIN, currentType, configName, config)
|
||||
}
|
||||
},
|
||||
}
|
||||
menu.push(obj)
|
||||
}
|
||||
@@ -351,14 +351,14 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const currentTransformer = picgo.getConfig<string>(configPaths.picBed.transformer) || 'path'
|
||||
if (currentTransformer === transformer) {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.transformer]: 'path'
|
||||
[configPaths.picBed.transformer]: 'path',
|
||||
})
|
||||
} else {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.transformer]: transformer
|
||||
[configPaths.picBed.transformer]: transformer,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
menu.push(obj)
|
||||
}
|
||||
@@ -366,7 +366,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
// plugin custom menus
|
||||
if (plugin.guiMenu) {
|
||||
menu.push({
|
||||
type: 'separator'
|
||||
type: 'separator',
|
||||
})
|
||||
for (const i of plugin.guiMenu) {
|
||||
menu.push({
|
||||
@@ -381,7 +381,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ const routes = [
|
||||
toolboxRouter.routes(),
|
||||
trayRouter.routes(),
|
||||
uploadRouter.routes(),
|
||||
manageRouter.routes()
|
||||
manageRouter.routes(),
|
||||
]
|
||||
|
||||
for (const route of routes) {
|
||||
|
||||
@@ -34,7 +34,7 @@ const galleryRoutes = [
|
||||
}
|
||||
return [txt, shortUrl]
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_REMOVE_FILES,
|
||||
@@ -42,7 +42,7 @@ const galleryRoutes = [
|
||||
setTimeout(() => {
|
||||
picgo.emit(ICOREBuildInEvent.REMOVE, args[0], GuiApi.getInstance())
|
||||
}, 500)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_GET_DB,
|
||||
@@ -50,7 +50,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.get(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_GET_BY_ID_DB,
|
||||
@@ -58,7 +58,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.getById(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_UPDATE_BY_ID_DB,
|
||||
@@ -66,7 +66,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.updateById(args[0], args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_REMOVE_BY_ID_DB,
|
||||
@@ -74,7 +74,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.removeById(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_INSERT_DB,
|
||||
@@ -82,7 +82,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.insert(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_INSERT_DB_BATCH,
|
||||
@@ -90,8 +90,8 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.insertMany(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
galleryRouter.addBatch(galleryRoutes)
|
||||
|
||||
@@ -9,93 +9,93 @@ export default [
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string]) => {
|
||||
return new ManageApi(args[0]).getBucketList()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_BACKSTAGE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getBucketListBackstage(args[1])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_RECURSIVELY,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getBucketListRecursively(args[1])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_CREATE_BUCKET,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).createBucket(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_BUCKET_FILE_LIST,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getBucketFileList(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_BUCKET_DOMAIN,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getBucketDomain(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_SET_BUCKET_ACL_POLICY,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).setBucketAclPolicy(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_RENAME_BUCKET_FILE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).renameBucketFile(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_BUCKET_FILE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).deleteBucketFile(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_BUCKET_FOLDER,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).deleteBucketFolder(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_PRE_SIGNED_URL,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getPreSignedUrl(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_UPLOAD_BUCKET_FILE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).uploadBucketFile(args[1])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DOWNLOAD_BUCKET_FILE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).downloadBucketFile(args[1])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_CREATE_BUCKET_FOLDER,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).createBucketFolder(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -11,18 +11,18 @@ export default [
|
||||
handler: async (_: IIPCEvent, args: [key?: string]) => {
|
||||
return manageApi.getConfig(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_SAVE_CONFIG,
|
||||
handler: async (_: IIPCEvent, args: [data: IObj]) => {
|
||||
manageApi.saveConfig(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_REMOVE_CONFIG,
|
||||
handler: async (_: IIPCEvent, args: [key: string, propName: string]) => {
|
||||
manageApi.removeConfig(args[0], args[1])
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -13,66 +13,66 @@ export default [
|
||||
action: IRPCActionType.MANAGE_OPEN_FILE_SELECT_DIALOG,
|
||||
handler: async () => {
|
||||
const res = await dialog.showOpenDialog({
|
||||
properties: ['openFile', 'multiSelections']
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
})
|
||||
return res.canceled ? [] : res.filePaths
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_UPLOAD_TASK_LIST,
|
||||
handler: async () => {
|
||||
return UpDownTaskQueue.getInstance().getAllUploadTask()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_DOWNLOAD_TASK_LIST,
|
||||
handler: async () => {
|
||||
return UpDownTaskQueue.getInstance().getAllDownloadTask()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_UPLOADED_TASK,
|
||||
handler: async () => {
|
||||
UpDownTaskQueue.getInstance().removeUploadedTask()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_ALL_UPLOADED_TASK,
|
||||
handler: async () => {
|
||||
UpDownTaskQueue.getInstance().clearUploadTaskQueue()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_DOWNLOADED_TASK,
|
||||
handler: async () => {
|
||||
UpDownTaskQueue.getInstance().removeDownloadedTask()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_ALL_DOWNLOADED_TASK,
|
||||
handler: async () => {
|
||||
UpDownTaskQueue.getInstance().clearDownloadTaskQueue()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_SELECT_DOWNLOAD_FOLDER,
|
||||
handler: async () => {
|
||||
const res = await dialog.showOpenDialog({
|
||||
properties: ['openDirectory']
|
||||
properties: ['openDirectory'],
|
||||
})
|
||||
return res.filePaths[0]
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER,
|
||||
handler: async () => {
|
||||
return app.getPath('downloads')
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_OPEN_DOWNLOADED_FOLDER,
|
||||
@@ -83,27 +83,27 @@ export default [
|
||||
} else {
|
||||
shell.openPath(app.getPath('downloads'))
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_OPEN_LOCAL_FILE,
|
||||
handler: async (_: IIPCEvent, args: [fullPath: string]) => {
|
||||
const fullPath = args[0]
|
||||
fs.existsSync(fullPath) ? shell.showItemInFolder(fullPath) : shell.openPath(path.dirname(fullPath))
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DOWNLOAD_FILE_FROM_URL,
|
||||
handler: async (_: IIPCEvent, args: [urls: string[]]) => {
|
||||
return await downloadFileFromUrl(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_CONVERT_PATH_TO_BASE64,
|
||||
handler: async (_: IIPCEvent, args: [filePath: string]) => {
|
||||
return fs.readFileSync(args[0], 'base64')
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -10,6 +10,6 @@ export default [
|
||||
handler: async (_: IIPCEvent, args: [item: ImgInfo]) => {
|
||||
return await ALLApi.delete(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
getUploaderConfigList,
|
||||
resetUploaderConfig,
|
||||
selectUploaderConfig,
|
||||
updateUploaderConfig
|
||||
updateUploaderConfig,
|
||||
} from '~/utils/handleUploaderConfig'
|
||||
|
||||
const picbedRouter = new RPCRouter()
|
||||
@@ -34,7 +34,7 @@ const picbedRoutes = [
|
||||
const config = getUploaderConfigList(args[0])
|
||||
return config
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICBED_DELETE_CONFIG,
|
||||
@@ -43,7 +43,7 @@ const picbedRoutes = [
|
||||
const config = deleteUploaderConfig(type, id)
|
||||
return config
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOADER_SELECT,
|
||||
@@ -52,7 +52,7 @@ const picbedRoutes = [
|
||||
selectUploaderConfig(type, id)
|
||||
return true
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOADER_UPDATE_CONFIG,
|
||||
@@ -61,7 +61,7 @@ const picbedRoutes = [
|
||||
updateUploaderConfig(type, id, config)
|
||||
return true
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOADER_RESET_CONFIG,
|
||||
@@ -70,7 +70,7 @@ const picbedRoutes = [
|
||||
resetUploaderConfig(type, id)
|
||||
return true
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICBED_GET_PICBED_CONFIG,
|
||||
@@ -82,17 +82,17 @@ const picbedRoutes = [
|
||||
const config = handleConfigWithFunction(_config)
|
||||
return {
|
||||
config,
|
||||
name
|
||||
name,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
config: [],
|
||||
name
|
||||
name,
|
||||
}
|
||||
}
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
const picBedsRoutes = [...picbedRoutes, ...deleteRoutes]
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
pluginGetListFunc,
|
||||
pluginImportLocalFunc,
|
||||
pluginInstallFunc,
|
||||
pluginUpdateAllFunc
|
||||
pluginUpdateAllFunc,
|
||||
} from '~/events/rpc/routes/plugin/utils'
|
||||
import { IRPCActionType } from '~/utils/enum'
|
||||
|
||||
@@ -12,20 +12,20 @@ const pluginRouter = new RPCRouter()
|
||||
const pluginRoutes = [
|
||||
{
|
||||
action: IRPCActionType.PLUGIN_GET_LIST,
|
||||
handler: pluginGetListFunc
|
||||
handler: pluginGetListFunc,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PLUGIN_INSTALL,
|
||||
handler: pluginInstallFunc
|
||||
handler: pluginInstallFunc,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PLUGIN_IMPORT_LOCAL,
|
||||
handler: pluginImportLocalFunc
|
||||
handler: pluginImportLocalFunc,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PLUGIN_UPDATE_ALL,
|
||||
handler: pluginUpdateAllFunc
|
||||
}
|
||||
handler: pluginUpdateAllFunc,
|
||||
},
|
||||
]
|
||||
|
||||
pluginRouter.addBatch(pluginRoutes)
|
||||
|
||||
@@ -60,7 +60,7 @@ const getPluginList = async (): Promise<IPicGoPlugin[]> => {
|
||||
let menu: Omit<IGuiMenuItem, 'handle'>[] = []
|
||||
if (plugin.guiMenu) {
|
||||
menu = plugin.guiMenu(picgo).map(item => ({
|
||||
label: item.label
|
||||
label: item.label,
|
||||
}))
|
||||
}
|
||||
let gui = false
|
||||
@@ -81,25 +81,25 @@ const getPluginList = async (): Promise<IPicGoPlugin[]> => {
|
||||
plugin: {
|
||||
fullName: pluginList[i],
|
||||
name: handleStreamlinePluginName(pluginList[i]),
|
||||
config: plugin.config ? handleConfigWithFunction(plugin.config(picgo)) : []
|
||||
config: plugin.config ? handleConfigWithFunction(plugin.config(picgo)) : [],
|
||||
},
|
||||
uploader: {
|
||||
name: uploaderName,
|
||||
config: handleConfigWithFunction(
|
||||
getConfig(uploaderName, IPicGoHelperType.uploader as keyof typeof IPicGoHelperType, picgo)
|
||||
)
|
||||
getConfig(uploaderName, IPicGoHelperType.uploader as keyof typeof IPicGoHelperType, picgo),
|
||||
),
|
||||
},
|
||||
transformer: {
|
||||
name: transformerName,
|
||||
config: handleConfigWithFunction(
|
||||
getConfig(uploaderName, IPicGoHelperType.transformer as keyof typeof IPicGoHelperType, picgo)
|
||||
)
|
||||
}
|
||||
getConfig(uploaderName, IPicGoHelperType.transformer as keyof typeof IPicGoHelperType, picgo),
|
||||
),
|
||||
},
|
||||
},
|
||||
enabled: picgo.getConfig(`picgoPlugins.${pluginList[i]}`),
|
||||
homepage: pluginPKG.homepage ? pluginPKG.homepage : '',
|
||||
guiMenu: menu,
|
||||
ing: false
|
||||
ing: false,
|
||||
}
|
||||
list.push(obj)
|
||||
}
|
||||
@@ -113,7 +113,7 @@ const handleNPMError = (): IDispose => {
|
||||
.showMessageBox({
|
||||
title: $t('TIPS_ERROR'),
|
||||
message: $t('TIPS_INSTALL_NODE_AND_RELOAD_PICGO'),
|
||||
buttons: ['Yes']
|
||||
buttons: ['Yes'],
|
||||
})
|
||||
.then(res => {
|
||||
if (res.response === 0) {
|
||||
@@ -135,7 +135,7 @@ export const handlePluginUpdate = async (fullName: string | string[]) => {
|
||||
} else {
|
||||
showNotification({
|
||||
title: $t('PLUGIN_UPDATE_FAILED'),
|
||||
body: res.body as string
|
||||
body: res.body as string,
|
||||
})
|
||||
}
|
||||
window.webContents.send('hideLoading')
|
||||
@@ -152,7 +152,7 @@ export const handlePluginUninstall = async (fullName: string) => {
|
||||
} else {
|
||||
showNotification({
|
||||
title: $t('PLUGIN_UNINSTALL_FAILED'),
|
||||
body: res.body as string
|
||||
body: res.body as string,
|
||||
})
|
||||
}
|
||||
window.webContents.send('hideLoading')
|
||||
@@ -169,7 +169,7 @@ export const pluginGetListFunc = async (event: IIPCEvent) => {
|
||||
event.sender.send('pluginList', [])
|
||||
showNotification({
|
||||
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||
body: e.message
|
||||
body: e.message,
|
||||
})
|
||||
picgo.log.error(e)
|
||||
}
|
||||
@@ -182,14 +182,14 @@ export const pluginInstallFunc = async (event: IIPCEvent, args: [fullName: strin
|
||||
event.sender.send('installPlugin', {
|
||||
success: res.success,
|
||||
body: fullName,
|
||||
errMsg: res.success ? '' : res.body
|
||||
errMsg: res.success ? '' : res.body,
|
||||
})
|
||||
if (res.success) {
|
||||
await shortKeyHandler.registerPluginShortKey(res.body[0])
|
||||
} else {
|
||||
showNotification({
|
||||
title: $t('PLUGIN_INSTALL_FAILED'),
|
||||
body: res.body as string
|
||||
body: res.body as string,
|
||||
})
|
||||
}
|
||||
event.sender.send('hideLoading')
|
||||
@@ -199,7 +199,7 @@ export const pluginInstallFunc = async (event: IIPCEvent, args: [fullName: strin
|
||||
export const pluginImportLocalFunc = async (event: IIPCEvent) => {
|
||||
const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const res = await dialog.showOpenDialog(settingWindow, {
|
||||
properties: ['openDirectory']
|
||||
properties: ['openDirectory'],
|
||||
})
|
||||
const filePaths = res.filePaths
|
||||
if (filePaths.length > 0) {
|
||||
@@ -212,17 +212,17 @@ export const pluginImportLocalFunc = async (event: IIPCEvent) => {
|
||||
event.sender.send('pluginList', [])
|
||||
showNotification({
|
||||
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||
body: e.message
|
||||
body: e.message,
|
||||
})
|
||||
}
|
||||
showNotification({
|
||||
title: $t('PLUGIN_IMPORT_SUCCEED'),
|
||||
body: ''
|
||||
body: '',
|
||||
})
|
||||
} else {
|
||||
showNotification({
|
||||
title: $t('PLUGIN_IMPORT_FAILED'),
|
||||
body: res.body as string
|
||||
body: res.body as string,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,18 +7,18 @@ export default [
|
||||
action: IRPCActionType.ADVANCED_UPDATE_SERVER,
|
||||
handler: async () => {
|
||||
server.restart()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.ADVANCED_STOP_WEB_SERVER,
|
||||
handler: async () => {
|
||||
webServer.stop()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.ADVANCED_RESTART_WEB_SERVER,
|
||||
handler: async () => {
|
||||
webServer.restart()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -24,7 +24,7 @@ export default [
|
||||
const sourcePath = path.join(picGoConfigPath, file)
|
||||
const targetPath = path.join(STORE_PATH, file.replace('picgo', 'piclist'))
|
||||
await fs.copy(sourcePath, targetPath, { overwrite: true })
|
||||
})
|
||||
}),
|
||||
)
|
||||
return true
|
||||
} catch (err: any) {
|
||||
@@ -32,48 +32,48 @@ export default [
|
||||
throw new Error('Migrate failed')
|
||||
}
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_UPLOAD_COMMON_CONFIG,
|
||||
handler: async () => {
|
||||
return await uploadFile(commonConfigList)
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_UPLOAD_MANAGE_CONFIG,
|
||||
handler: async () => {
|
||||
return await uploadFile(manageConfigList)
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_UPLOAD_ALL_CONFIG,
|
||||
handler: async () => {
|
||||
return await uploadFile([...commonConfigList, ...manageConfigList])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_DOWNLOAD_COMMON_CONFIG,
|
||||
handler: async () => {
|
||||
return await downloadFile(commonConfigList)
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_DOWNLOAD_MANAGE_CONFIG,
|
||||
handler: async () => {
|
||||
return await downloadFile(manageConfigList)
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_DOWNLOAD_ALL_CONFIG,
|
||||
handler: async () => {
|
||||
return await downloadFile([...commonConfigList, ...manageConfigList])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -18,7 +18,7 @@ export default [
|
||||
handler: async (_: IIPCEvent, args: [key?: string]) => {
|
||||
return picgo.getConfig(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_GET_CONFIG_SYNC,
|
||||
@@ -26,13 +26,13 @@ export default [
|
||||
const result = picgo.getConfig(args[0])
|
||||
const eventInstance = event as IpcMainEvent
|
||||
eventInstance.returnValue = result
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_SAVE_CONFIG,
|
||||
handler: async (_: IIPCEvent, args: [data: IObj]) => {
|
||||
picgo.saveConfig(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_OPEN_FILE,
|
||||
@@ -42,12 +42,13 @@ export default [
|
||||
fs.writeFileSync(abFilePath, '')
|
||||
}
|
||||
shell.openPath(abFilePath)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_OPEN_DIRECTORY,
|
||||
handler: async (_: IIPCEvent, args: [dirPath?: string, inStorePath?: boolean]) => {
|
||||
let [dirPath, inStorePath = true] = args
|
||||
let [dirPath] = args
|
||||
const [inStorePath = true] = args
|
||||
if (inStorePath) {
|
||||
dirPath = path.join(STORE_PATH, dirPath || '')
|
||||
}
|
||||
@@ -55,19 +56,19 @@ export default [
|
||||
return
|
||||
}
|
||||
shell.openPath(dirPath)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_AUTO_START,
|
||||
handler: async (_: IIPCEvent, args: [val: boolean]) => {
|
||||
await setAutoStart(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_AUTO_START_STATUS,
|
||||
handler: async (_: IIPCEvent) => {
|
||||
return await isAutoStartEnabled()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -11,7 +11,7 @@ import { IRPCActionType, IRPCType } from '~/utils/enum'
|
||||
const notificationFunc = (result: boolean) => {
|
||||
const notification = new Notification({
|
||||
title: $t(`OPERATION_${result ? 'SUCCEED' : 'FAILED'}`),
|
||||
body: $t(`TIPS_SHORTCUT_MODIFIED_${result ? 'SUCCEED' : 'CONFLICT'}`)
|
||||
body: $t(`TIPS_SHORTCUT_MODIFIED_${result ? 'SUCCEED' : 'CONFLICT'}`),
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
@@ -25,7 +25,7 @@ export default [
|
||||
notificationFunc(result)
|
||||
return result
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHORTKEY_BIND_OR_UNBIND,
|
||||
@@ -33,13 +33,13 @@ export default [
|
||||
const [item, from] = args
|
||||
const result = shortKeyHandler.bindOrUnbindShortKey(item, from)
|
||||
notificationFunc(result)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHORTKEY_TOGGLE_SHORTKEY_MODIFIED_MODE,
|
||||
handler: async (_: IIPCEvent, args: [status: boolean]) => {
|
||||
const [status] = args
|
||||
bus.emit(TOGGLE_SHORTKEY_MODIFIED_MODE, status)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -11,19 +11,19 @@ export default [
|
||||
handler: async () => {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.OPEN_FILE,
|
||||
handler: async (_: IIPCEvent, args: [filePath: string]) => {
|
||||
shell.openPath(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.OPEN_URL,
|
||||
handler: async (_: IIPCEvent, args: [url: string]) => {
|
||||
shell.openExternal(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SET_CURRENT_LANGUAGE,
|
||||
@@ -31,6 +31,6 @@ export default [
|
||||
i18nManager.setCurrentLanguage(args[0])
|
||||
const { lang } = i18nManager.getCurrentLocales()
|
||||
picgo.i18n.setLanguage(lang)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
buildMiniPageMenu,
|
||||
buildPicBedListMenu,
|
||||
buildPluginPageMenu,
|
||||
buildSecondPicBedMenu
|
||||
buildSecondPicBedMenu,
|
||||
} from '~/events/remotes/menu'
|
||||
import { IRPCActionType, IWindowList } from '~/utils/enum'
|
||||
import { openMiniWindow } from '~/utils/windowHelper'
|
||||
@@ -18,7 +18,7 @@ export default [
|
||||
action: IRPCActionType.HIDE_DOCK,
|
||||
handler: async (_: IIPCEvent, args: [value: boolean]) => {
|
||||
args[0] ? app.dock?.hide() : app.dock?.show()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.OPEN_WINDOW,
|
||||
@@ -27,13 +27,13 @@ export default [
|
||||
if (window) {
|
||||
window.show()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.OPEN_MINI_WINDOW,
|
||||
handler: async () => {
|
||||
openMiniWindow()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CLOSE_WINDOW,
|
||||
@@ -44,14 +44,14 @@ export default [
|
||||
} else {
|
||||
window?.close()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MINIMIZE_WINDOW,
|
||||
handler: async () => {
|
||||
const window = BrowserWindow.getFocusedWindow()
|
||||
window?.minimize()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_MINI_PAGE_MENU,
|
||||
@@ -59,9 +59,9 @@ export default [
|
||||
const window = windowManager.get(IWindowList.MINI_WINDOW)!
|
||||
const menu = buildMiniPageMenu()
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_MAIN_PAGE_MENU,
|
||||
@@ -69,9 +69,9 @@ export default [
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const menu = buildMainPageMenu(window)
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_UPLOAD_PAGE_MENU,
|
||||
@@ -79,9 +79,9 @@ export default [
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const menu = buildPicBedListMenu()
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_SECOND_UPLOADER_MENU,
|
||||
@@ -89,9 +89,9 @@ export default [
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const menu = buildSecondPicBedMenu()
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_PLUGIN_PAGE_MENU,
|
||||
@@ -99,23 +99,23 @@ export default [
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const menu = buildPluginPageMenu(args[0])
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SET_MINI_WINDOW_POS,
|
||||
handler: async (_: IIPCEvent, args: [pos: IMiniWindowPos]) => {
|
||||
const window = BrowserWindow.getFocusedWindow()
|
||||
window?.setBounds(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MINI_WINDOW_ON_TOP,
|
||||
handler: async (_: IIPCEvent, args: [isOnTop: boolean]) => {
|
||||
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
|
||||
miniWindow.setAlwaysOnTop(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MAIN_WINDOW_ON_TOP,
|
||||
@@ -123,14 +123,14 @@ export default [
|
||||
const mainWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const isAlwaysOnTop = mainWindow.isAlwaysOnTop()
|
||||
mainWindow.setAlwaysOnTop(!isAlwaysOnTop)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPDATE_MINI_WINDOW_ICON,
|
||||
handler: async (_: IIPCEvent, args: [iconPath: string]) => {
|
||||
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
|
||||
miniWindow.webContents.send('updateMiniIcon', args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.REFRESH_SETTING_WINDOW,
|
||||
@@ -139,6 +139,6 @@ export default [
|
||||
settingWindow.webContents.session.clearCache().then(() => {
|
||||
settingWindow.webContents.reloadIgnoringCache()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -16,7 +16,7 @@ const defaultClipboardImagePath = path.join(defaultConfigPath, CLIPBOARD_IMAGE_F
|
||||
export const checkClipboardUploadMap: IToolboxCheckerMap<string> = {
|
||||
[IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD]: async event => {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.LOADING
|
||||
status: IToolboxItemCheckStatus.LOADING,
|
||||
})
|
||||
const configFilePath = dbPathChecker()
|
||||
if (fs.existsSync(configFilePath)) {
|
||||
@@ -26,29 +26,29 @@ export const checkClipboardUploadMap: IToolboxCheckerMap<string> = {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS', {
|
||||
path: clipboardImagePath
|
||||
path: clipboardImagePath,
|
||||
}),
|
||||
value: clipboardImagePath
|
||||
value: clipboardImagePath,
|
||||
})
|
||||
} else {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
||||
path: clipboardImagePath
|
||||
path: clipboardImagePath,
|
||||
}),
|
||||
value: path.dirname(clipboardImagePath)
|
||||
value: path.dirname(clipboardImagePath),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
||||
path: defaultClipboardImagePath
|
||||
path: defaultClipboardImagePath,
|
||||
}),
|
||||
value: path.dirname(defaultClipboardImagePath)
|
||||
value: path.dirname(defaultClipboardImagePath),
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export const fixClipboardUploadMap: IToolboxFixMap<string> = {
|
||||
@@ -60,17 +60,17 @@ export const fixClipboardUploadMap: IToolboxFixMap<string> = {
|
||||
fs.mkdirsSync(clipboardImagePath)
|
||||
return {
|
||||
type: IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD,
|
||||
status: IToolboxItemCheckStatus.SUCCESS
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
return {
|
||||
type: IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD,
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS', {
|
||||
path: clipboardImagePath
|
||||
path: clipboardImagePath,
|
||||
}),
|
||||
value: path.dirname(clipboardImagePath)
|
||||
value: path.dirname(clipboardImagePath),
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export const checkFileMap: IToolboxCheckerMap<string> = {
|
||||
[IToolboxItemType.IS_CONFIG_FILE_BROKEN]: async (event: IpcMainEvent) => {
|
||||
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.IS_CONFIG_FILE_BROKEN)
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.LOADING
|
||||
status: IToolboxItemCheckStatus.LOADING,
|
||||
})
|
||||
const configFilePath = dbPathChecker()
|
||||
try {
|
||||
@@ -23,64 +23,64 @@ export const checkFileMap: IToolboxCheckerMap<string> = {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_PATH_TIPS', {
|
||||
path: configFilePath
|
||||
path: configFilePath,
|
||||
}),
|
||||
value: configFilePath
|
||||
value: configFilePath,
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_BROKEN_TIPS'),
|
||||
value: path.dirname(configFilePath)
|
||||
value: path.dirname(configFilePath),
|
||||
})
|
||||
}
|
||||
},
|
||||
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async event => {
|
||||
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.IS_GALLERY_FILE_BROKEN)
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.LOADING
|
||||
status: IToolboxItemCheckStatus.LOADING,
|
||||
})
|
||||
const galleryDB = GalleryDB.getInstance()
|
||||
if (galleryDB.errorList.length === 0) {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_GALLERY_FILE_PATH_TIPS', {
|
||||
path: DB_PATH
|
||||
path: DB_PATH,
|
||||
}),
|
||||
value: path.dirname(DB_PATH)
|
||||
value: path.dirname(DB_PATH),
|
||||
})
|
||||
} else {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_GALLERY_FILE_BROKEN_TIPS'),
|
||||
value: path.dirname(DB_PATH)
|
||||
value: path.dirname(DB_PATH),
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export const fixFileMap: IToolboxFixMap<string> = {
|
||||
[IToolboxItemType.IS_CONFIG_FILE_BROKEN]: async () => {
|
||||
try {
|
||||
fs.unlinkSync(dbPathChecker())
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// do nothing
|
||||
}
|
||||
return {
|
||||
type: IToolboxItemType.IS_CONFIG_FILE_BROKEN,
|
||||
status: IToolboxItemCheckStatus.SUCCESS
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
}
|
||||
},
|
||||
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async () => {
|
||||
try {
|
||||
fs.unlinkSync(DB_PATH)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// do nothing
|
||||
}
|
||||
return {
|
||||
type: IToolboxItemType.IS_GALLERY_FILE_BROKEN,
|
||||
status: IToolboxItemCheckStatus.SUCCESS
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ function getProxy(proxyStr: string): AxiosRequestConfig['proxy'] | null {
|
||||
return {
|
||||
host: proxyOptions.hostname,
|
||||
port: parseInt(proxyOptions.port || '0', 10),
|
||||
protocol: proxyOptions.protocol
|
||||
protocol: proxyOptions.protocol,
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (_e) {}
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -28,18 +28,18 @@ const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.HAS_PROBLEM_WITH_
|
||||
export const checkProxyMap: IToolboxCheckerMap<string> = {
|
||||
[IToolboxItemType.HAS_PROBLEM_WITH_PROXY]: async event => {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.LOADING
|
||||
status: IToolboxItemCheckStatus.LOADING,
|
||||
})
|
||||
const configFilePath = dbPathChecker()
|
||||
if (fs.existsSync(configFilePath)) {
|
||||
let config: IConfig | undefined
|
||||
try {
|
||||
config = (await fs.readJSON(configFilePath)) as IConfig
|
||||
} catch (e) {}
|
||||
} catch (_e) {}
|
||||
if (!config) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS'),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -47,34 +47,34 @@ export const checkProxyMap: IToolboxCheckerMap<string> = {
|
||||
if (!proxy) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS'),
|
||||
})
|
||||
} else {
|
||||
const proxyOptions = getProxy(proxy)
|
||||
if (!proxyOptions) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_CORRECT')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_CORRECT'),
|
||||
})
|
||||
} else {
|
||||
const httpsAgent = tunnel.httpsOverHttp({
|
||||
proxy: {
|
||||
host: proxyOptions.host,
|
||||
port: proxyOptions.port
|
||||
}
|
||||
port: proxyOptions.port,
|
||||
},
|
||||
})
|
||||
try {
|
||||
await axios.get('https://www.google.com', {
|
||||
httpsAgent
|
||||
httpsAgent,
|
||||
})
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_SUCCESS_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_SUCCESS_TIPS'),
|
||||
})
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_WORKING')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_WORKING'),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ export const checkProxyMap: IToolboxCheckerMap<string> = {
|
||||
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS'),
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ const toolboxRouter = new RPCRouter()
|
||||
const toolboxCheckMap: Partial<IToolboxCheckerMap<string>> = {
|
||||
...checkFileMap,
|
||||
...checkClipboardUploadMap,
|
||||
...checkProxyMap
|
||||
...checkProxyMap,
|
||||
}
|
||||
|
||||
const toolboxFixMap: Partial<IToolboxFixMap<string>> = {
|
||||
...fixFileMap,
|
||||
...fixClipboardUploadMap
|
||||
...fixClipboardUploadMap,
|
||||
}
|
||||
|
||||
toolboxRouter
|
||||
@@ -40,7 +40,7 @@ toolboxRouter
|
||||
}
|
||||
}
|
||||
},
|
||||
IRPCType.SEND
|
||||
IRPCType.SEND,
|
||||
)
|
||||
.add(
|
||||
IRPCActionType.TOOLBOX_CHECK_FIX,
|
||||
@@ -51,7 +51,7 @@ toolboxRouter
|
||||
return await handler(event as IpcMainEvent)
|
||||
}
|
||||
},
|
||||
IRPCType.INVOKE
|
||||
IRPCType.INVOKE,
|
||||
)
|
||||
|
||||
export { toolboxRouter }
|
||||
|
||||
@@ -7,7 +7,7 @@ export function sendToolboxResWithType(type: string) {
|
||||
return (event: IpcMainEvent, res?: Omit<IToolboxCheckRes, 'type'>) => {
|
||||
return event.sender.send(IRPCActionType.TOOLBOX_CHECK_RES, {
|
||||
...res,
|
||||
type
|
||||
type,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ const trayRoutes = [
|
||||
action: IRPCActionType.TRAY_SET_TOOL_TIP,
|
||||
handler: async (_: IIPCEvent, args: [text: string]) => {
|
||||
setTrayToolTip(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.TRAY_GET_SHORT_URL,
|
||||
handler: async (_: IIPCEvent, args: [url: string]) => {
|
||||
return await generateShortUrl(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.TRAY_UPLOAD_CLIPBOARD_FILES,
|
||||
@@ -45,7 +45,7 @@ const trayRoutes = [
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || img[0].imgUrl!
|
||||
body: shortUrl || img[0].imgUrl!,
|
||||
// icon: file[0]
|
||||
// icon: img[0].imgUrl
|
||||
})
|
||||
@@ -58,8 +58,8 @@ const trayRoutes = [
|
||||
}
|
||||
}
|
||||
trayWindow.webContents.send('uploadFiles')
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
trayRouter.addBatch(trayRoutes)
|
||||
|
||||
@@ -14,20 +14,20 @@ const uploadRoutes = [
|
||||
handler: async () => {
|
||||
return getPicBeds()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOAD_CLIPBOARD_FILES_FROM_UPLOAD_PAGE,
|
||||
handler: async () => {
|
||||
uploadClipboardFiles()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOAD_CHOOSED_FILES,
|
||||
handler: async (evt: IIPCEvent, args: [files: IFileWithPath[]]) => {
|
||||
return uploadChoosedFiles(evt.sender, args[0])
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
uploadRouter.addBatch(uploadRoutes)
|
||||
|
||||
@@ -13,22 +13,22 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const builtinI18nList: II18nItem[] = [
|
||||
{
|
||||
label: '简体中文',
|
||||
value: 'zh-CN'
|
||||
value: 'zh-CN',
|
||||
},
|
||||
{
|
||||
label: '繁體中文',
|
||||
value: 'zh-TW'
|
||||
value: 'zh-TW',
|
||||
},
|
||||
{
|
||||
label: 'English',
|
||||
value: 'en'
|
||||
}
|
||||
value: 'en',
|
||||
},
|
||||
]
|
||||
class I18nManager {
|
||||
private i18n: I18n | null = null
|
||||
private builtinI18nFolder = path.join(__dirname, '../../resources', 'i18n').replace('app.asar', 'app.asar.unpacked')
|
||||
private outterI18nFolder = ''
|
||||
private localesMap: Map<string, ILocales> = new Map()
|
||||
private localesMap = new Map<string, ILocales>()
|
||||
private currentLanguage: string = 'zh-CN'
|
||||
readonly defaultLanguage: string = 'zh-CN'
|
||||
private i18nFileList: II18nItem[] = builtinI18nList
|
||||
@@ -40,7 +40,7 @@ class I18nManager {
|
||||
addI18nFile(file: string, label: string) {
|
||||
this.i18nFileList.push({
|
||||
label,
|
||||
value: file
|
||||
value: file,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,11 +79,11 @@ class I18nManager {
|
||||
|
||||
private initI18n(lang: string = this.defaultLanguage, locales: ILocales) {
|
||||
const objectAdapter = new ObjectAdapter({
|
||||
[lang]: locales
|
||||
[lang]: locales,
|
||||
})
|
||||
this.i18n = new I18n({
|
||||
adapter: objectAdapter,
|
||||
defaultLanguage: lang
|
||||
defaultLanguage: lang,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class I18nManager {
|
||||
getCurrentLocales() {
|
||||
return {
|
||||
lang: this.currentLanguage,
|
||||
locales: this.getLocales(this.currentLanguage)
|
||||
locales: this.getLocales(this.currentLanguage),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ function bootstrapEPIPESuppression() {
|
||||
bootstrapEPIPESuppression()
|
||||
|
||||
function epipeBomb(stream: any, callback: any) {
|
||||
if (stream == null) stream = process.stdout
|
||||
if (callback == null) callback = process.exit
|
||||
if (stream === null) stream = process.stdout
|
||||
if (callback === null) callback = process.exit
|
||||
|
||||
function epipeFilter(err: any) {
|
||||
if (err.code === 'EPIPE') return callback()
|
||||
|
||||
@@ -62,7 +62,7 @@ const handleStartUpFiles = (argv: string[], cwd: string) => {
|
||||
updater.autoUpdater.setFeedURL({
|
||||
provider: 'generic',
|
||||
url: 'https://release.piclist.cn/latest',
|
||||
channel: 'latest'
|
||||
channel: 'latest',
|
||||
})
|
||||
|
||||
updater.autoUpdater.autoDownload = false
|
||||
@@ -101,13 +101,13 @@ updater.autoUpdater.on('update-available', async (info: updater.UpdateInfo) => {
|
||||
buttons: ['Yes', 'Go to download page'],
|
||||
message:
|
||||
$t('TIPS_FIND_NEW_VERSION', {
|
||||
v: info.version
|
||||
v: info.version,
|
||||
}) +
|
||||
'\n\n' +
|
||||
displayLog +
|
||||
truncatedNote,
|
||||
checkboxLabel: $t('NO_MORE_NOTICE'),
|
||||
checkboxChecked: false
|
||||
checkboxChecked: false,
|
||||
})
|
||||
.then(result => {
|
||||
if (result.response === 0) {
|
||||
@@ -124,7 +124,7 @@ updater.autoUpdater.on('update-available', async (info: updater.UpdateInfo) => {
|
||||
|
||||
updater.autoUpdater.on('download-progress', progressObj => {
|
||||
const percent = {
|
||||
progress: progressObj.percent
|
||||
progress: progressObj.percent,
|
||||
}
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send('updateProgress', percent)
|
||||
@@ -136,7 +136,7 @@ updater.autoUpdater.on('update-downloaded', () => {
|
||||
type: 'info',
|
||||
title: $t('UPDATE_DOWNLOADED'),
|
||||
buttons: ['Yes', 'No'],
|
||||
message: $t('TIPS_UPDATE_DOWNLOADED')
|
||||
message: $t('TIPS_UPDATE_DOWNLOADED'),
|
||||
})
|
||||
.then(result => {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
@@ -243,7 +243,7 @@ class LifeCycle {
|
||||
miniWindow.setPosition(width - miniWindow.getSize()[0], height - miniWindow.getSize()[1])
|
||||
db.set(configPaths.settings.miniWindowPosition, [
|
||||
width - miniWindow.getSize()[0],
|
||||
height - miniWindow.getSize()[1]
|
||||
height - miniWindow.getSize()[1],
|
||||
])
|
||||
} else {
|
||||
miniWindow.setPosition(lastPosition[0], lastPosition[1])
|
||||
@@ -297,7 +297,7 @@ class LifeCycle {
|
||||
.then(actualAutoStartEnabled => {
|
||||
if (actualAutoStartEnabled !== storedAutoStartEnabled) {
|
||||
logger.warn(
|
||||
`Auto-start state mismatch detected. Stored: ${storedAutoStartEnabled}, Actual: ${actualAutoStartEnabled}. Syncing...`
|
||||
`Auto-start state mismatch detected. Stored: ${storedAutoStartEnabled}, Actual: ${actualAutoStartEnabled}. Syncing...`,
|
||||
)
|
||||
setAutoStart(storedAutoStartEnabled).catch(err => {
|
||||
logger.error('Failed to sync auto-start:', err)
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
formatError,
|
||||
getFileMimeType,
|
||||
hmacSha1Base64,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import { ManageLogger } from '~/manage/utils/logger'
|
||||
import { isImage } from '~/utils/common'
|
||||
@@ -32,7 +32,7 @@ class AliyunApi {
|
||||
this.ctx = new OSS({
|
||||
accessKeyId,
|
||||
accessKeySecret,
|
||||
secure: true
|
||||
secure: true,
|
||||
})
|
||||
this.accessKeyId = accessKeyId
|
||||
this.accessKeySecret = accessKeySecret
|
||||
@@ -50,7 +50,7 @@ class AliyunApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
Key: item
|
||||
Key: item,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class AliyunApi {
|
||||
match: false,
|
||||
isImage: isImage(fileName),
|
||||
rawUrl: item.url,
|
||||
url: `${urlPrefix}/${item.name}`
|
||||
url: `${urlPrefix}/${item.name}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class AliyunApi {
|
||||
canonicalizedResource: string,
|
||||
headers: IStringKeyMap,
|
||||
contentMd5: string,
|
||||
contentType: string
|
||||
contentType: string,
|
||||
) {
|
||||
const date = new Date().toUTCString()
|
||||
const stringToSign = `${method.toUpperCase()}\n${contentMd5}\n${contentType}\n${date}\n${this.getCanonicalizedOSSHeaders(headers)}${canonicalizedResource}`
|
||||
@@ -102,7 +102,7 @@ class AliyunApi {
|
||||
accessKeySecret: this.accessKeySecret,
|
||||
region,
|
||||
bucket,
|
||||
secure: true
|
||||
secure: true,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -113,18 +113,18 @@ class AliyunApi {
|
||||
const getBuckets = async (marker?: string) => {
|
||||
const res = (await this.ctx.listBuckets({
|
||||
marker,
|
||||
'max-keys': 1000
|
||||
'max-keys': 1000,
|
||||
})) as IStringKeyMap
|
||||
if (res?.res?.statusCode !== 200 || !res?.buckets) return { result: [], isTruncated: false }
|
||||
const formattedBuckets = res.buckets.map((item: OSS.Bucket) => ({
|
||||
Name: item.name,
|
||||
Location: item.region,
|
||||
CreationDate: item.creationDate
|
||||
CreationDate: item.creationDate,
|
||||
}))
|
||||
return {
|
||||
result: formattedBuckets,
|
||||
isTruncated: res.isTruncated,
|
||||
nextMarker: res.nextMarker
|
||||
nextMarker: res.nextMarker,
|
||||
}
|
||||
}
|
||||
const result: IStringKeyMap[] = []
|
||||
@@ -145,7 +145,7 @@ class AliyunApi {
|
||||
*/
|
||||
async getBucketDomain(param: IStringKeyMap): Promise<any> {
|
||||
const headers = {
|
||||
Date: new Date().toUTCString()
|
||||
Date: new Date().toUTCString(),
|
||||
}
|
||||
const authorization = this.authorization('GET', `/${param.bucketName}/?cname`, headers, '', '')
|
||||
|
||||
@@ -154,8 +154,8 @@ class AliyunApi {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
...headers,
|
||||
Authorization: authorization
|
||||
}
|
||||
Authorization: authorization,
|
||||
},
|
||||
})
|
||||
|
||||
if (res?.status === 200) {
|
||||
@@ -191,18 +191,18 @@ class AliyunApi {
|
||||
accessKeyId: this.accessKeyId,
|
||||
accessKeySecret: this.accessKeySecret,
|
||||
region: configMap.region,
|
||||
secure: true
|
||||
secure: true,
|
||||
})
|
||||
const aclTransMap: IStringKeyMap = {
|
||||
private: 'private',
|
||||
publicRead: 'public-read',
|
||||
publicReadWrite: 'public-read-write'
|
||||
publicReadWrite: 'public-read-write',
|
||||
}
|
||||
const res = await client.putBucket(configMap.BucketName, {
|
||||
acl: aclTransMap[configMap.acl],
|
||||
storageClass: 'Standard',
|
||||
dataRedundancyType: 'LRS',
|
||||
timeout: this.timeOut
|
||||
timeout: this.timeOut,
|
||||
})
|
||||
return res?.res?.status === 200
|
||||
}
|
||||
@@ -213,7 +213,7 @@ class AliyunApi {
|
||||
bucketName: bucket,
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
||||
@@ -229,7 +229,7 @@ class AliyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const client = this.getNewCtx(region, bucket)
|
||||
do {
|
||||
@@ -237,11 +237,11 @@ class AliyunApi {
|
||||
{
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
'max-keys': '1000',
|
||||
'continuation-token': marker
|
||||
'continuation-token': marker,
|
||||
},
|
||||
{
|
||||
timeout: this.timeOut
|
||||
}
|
||||
timeout: this.timeOut,
|
||||
},
|
||||
)
|
||||
if (res?.res?.statusCode === 200) {
|
||||
res?.objects?.forEach((item: OSS.ObjectMeta) => {
|
||||
@@ -268,7 +268,7 @@ class AliyunApi {
|
||||
bucketName: bucket,
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
||||
@@ -284,7 +284,7 @@ class AliyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const client = this.getNewCtx(region, bucket)
|
||||
do {
|
||||
@@ -293,11 +293,11 @@ class AliyunApi {
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
delimiter: '/',
|
||||
'max-keys': '1000',
|
||||
'continuation-token': marker
|
||||
'continuation-token': marker,
|
||||
},
|
||||
{
|
||||
timeout: this.timeOut
|
||||
}
|
||||
timeout: this.timeOut,
|
||||
},
|
||||
)
|
||||
if (res?.res?.statusCode === 200) {
|
||||
res?.prefixes?.forEach((item: string) => {
|
||||
@@ -342,7 +342,7 @@ class AliyunApi {
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
marker,
|
||||
itemsPerPage
|
||||
itemsPerPage,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
||||
@@ -353,11 +353,11 @@ class AliyunApi {
|
||||
prefix: slicedPrefix || undefined,
|
||||
delimiter: '/',
|
||||
'max-keys': itemsPerPage.toString(),
|
||||
'continuation-token': marker
|
||||
'continuation-token': marker,
|
||||
},
|
||||
{
|
||||
timeout: this.timeOut
|
||||
}
|
||||
timeout: this.timeOut,
|
||||
},
|
||||
)) as any
|
||||
// prefixes can be null
|
||||
// objects will be [] when no file
|
||||
@@ -366,20 +366,20 @@ class AliyunApi {
|
||||
fullList: [],
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
}
|
||||
const fullList = [
|
||||
...(res.prefixes?.map((item: string) => this.formatFolder(item, slicedPrefix, urlPrefix)) || []),
|
||||
...(res.objects
|
||||
?.filter((item: OSS.ObjectMeta) => item.size !== 0)
|
||||
.map((item: OSS.ObjectMeta) => this.formatFile(item, slicedPrefix, urlPrefix)) || [])
|
||||
.map((item: OSS.ObjectMeta) => this.formatFile(item, slicedPrefix, urlPrefix)) || []),
|
||||
]
|
||||
return {
|
||||
fullList,
|
||||
isTruncated: res.isTruncated,
|
||||
nextMarker: res.nextContinuationToken || '',
|
||||
success: true
|
||||
success: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ class AliyunApi {
|
||||
let isTruncated
|
||||
const allFileList = {
|
||||
CommonPrefixes: [] as any[],
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
do {
|
||||
const res = (await client.listV2(
|
||||
@@ -439,11 +439,11 @@ class AliyunApi {
|
||||
prefix: key,
|
||||
delimiter: '/',
|
||||
'max-keys': '1000',
|
||||
'continuation-token': marker
|
||||
'continuation-token': marker,
|
||||
},
|
||||
{
|
||||
timeout: this.timeOut
|
||||
}
|
||||
timeout: this.timeOut,
|
||||
},
|
||||
)) as any
|
||||
if (res?.res.statusCode !== 200) return false
|
||||
|
||||
@@ -458,7 +458,7 @@ class AliyunApi {
|
||||
const successfully = await this.deleteBucketFolder({
|
||||
bucketName,
|
||||
region,
|
||||
key: item
|
||||
key: item,
|
||||
})
|
||||
if (!successfully) return false
|
||||
}
|
||||
@@ -467,7 +467,7 @@ class AliyunApi {
|
||||
const cycle = Math.ceil(allFileList.Contents.length / 1000)
|
||||
for (let i = 0; i < cycle; i++) {
|
||||
const deleteRes = (await client.deleteMulti(
|
||||
allFileList.Contents.slice(i * 1000, (i + 1) * 1000).map((item: any) => item.name)
|
||||
allFileList.Contents.slice(i * 1000, (i + 1) * 1000).map((item: any) => item.name),
|
||||
)) as any
|
||||
if (deleteRes?.res.statusCode !== 200) return false
|
||||
}
|
||||
@@ -490,7 +490,7 @@ class AliyunApi {
|
||||
const { bucketName, region, key, expires, customUrl } = configMap
|
||||
const client = this.getNewCtx(region, bucketName)
|
||||
const res = client.signatureUrl(key, {
|
||||
expires: expires || 3600
|
||||
expires: expires || 3600,
|
||||
})
|
||||
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
|
||||
}
|
||||
@@ -527,7 +527,7 @@ class AliyunApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
client
|
||||
.multipartUpload(key, filePath, {
|
||||
@@ -538,9 +538,9 @@ class AliyunApi {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: Math.floor(p * 100),
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
.then((res: any) => {
|
||||
const id = `${bucketName}-${region}-${key}-${filePath}`
|
||||
@@ -550,7 +550,7 @@ class AliyunApi {
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
response: JSON.stringify(res),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
@@ -558,7 +558,7 @@ class AliyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: JSON.stringify(res),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -566,8 +566,8 @@ class AliyunApi {
|
||||
this.logger.error(
|
||||
formatError(err, {
|
||||
class: 'AliyunApi',
|
||||
method: 'uploadBucketFile'
|
||||
})
|
||||
method: 'uploadBucketFile',
|
||||
}),
|
||||
)
|
||||
const id = `${bucketName}-${region}-${key}-${filePath}`
|
||||
instance.updateUploadTask({
|
||||
@@ -575,7 +575,7 @@ class AliyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: JSON.stringify(err),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -614,10 +614,10 @@ class AliyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
const preSignedUrl = client.signatureUrl(key, {
|
||||
expires: 60 * 60 * 48
|
||||
expires: 60 * 60 * 48,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -629,7 +629,7 @@ class AliyunApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
@@ -637,8 +637,8 @@ class AliyunApi {
|
||||
this.logger.error(
|
||||
formatError(error, {
|
||||
class: 'AliyunApi',
|
||||
method: 'downloadBucketFile'
|
||||
})
|
||||
method: 'downloadBucketFile',
|
||||
}),
|
||||
)
|
||||
})
|
||||
return true
|
||||
|
||||
@@ -21,5 +21,5 @@ export default {
|
||||
SmmsApi,
|
||||
TcyunApi,
|
||||
UpyunApi,
|
||||
WebdavplistApi
|
||||
WebdavplistApi,
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
getAgent,
|
||||
getOptions,
|
||||
gotUpload,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import { ManageLogger } from '~/manage/utils/logger'
|
||||
import { formatHttpProxy, isImage, trimPath } from '~/utils/common'
|
||||
@@ -37,7 +37,7 @@ class GithubApi {
|
||||
this.proxyStr = formatHttpProxy(proxy, 'string') as string | undefined
|
||||
this.commonHeaders = {
|
||||
Authorization: this.token,
|
||||
Accept: 'application/vnd.github+json'
|
||||
Accept: 'application/vnd.github+json',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class GithubApi {
|
||||
isDir: true,
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false
|
||||
match: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ class GithubApi {
|
||||
match: false,
|
||||
isImage: isImage(item.path),
|
||||
rawUrl: item.url,
|
||||
url: rawUrl
|
||||
url: rawUrl,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,8 +133,8 @@ class GithubApi {
|
||||
'json',
|
||||
undefined,
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (res.statusCode === 200) {
|
||||
res.body.forEach((item: any) => {
|
||||
@@ -142,7 +142,7 @@ class GithubApi {
|
||||
...item,
|
||||
Name: item.name,
|
||||
Location: item.id,
|
||||
CreationDate: item.created_at
|
||||
CreationDate: item.created_at,
|
||||
})
|
||||
})
|
||||
} else {
|
||||
@@ -171,8 +171,8 @@ class GithubApi {
|
||||
'json',
|
||||
undefined,
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (res.statusCode === 200) {
|
||||
res.body.forEach((item: any) => result.push(item.name))
|
||||
@@ -199,7 +199,7 @@ class GithubApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const treeQueue = [slicedPrefix]
|
||||
while (treeQueue.length) {
|
||||
@@ -210,7 +210,7 @@ class GithubApi {
|
||||
const currentPrefix = treeQueue[0]
|
||||
res = (await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${treeQueue.shift()}`,
|
||||
getOptions('GET', this.commonHeaders, {}, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.commonHeaders, {}, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (res && res.statusCode === 200) {
|
||||
const { tree } = res.body
|
||||
@@ -250,11 +250,11 @@ class GithubApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
res = await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${slicedPrefix}`,
|
||||
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)
|
||||
if (res && res.statusCode === 200) {
|
||||
res.body.tree.forEach((item: any) => {
|
||||
@@ -290,11 +290,11 @@ class GithubApi {
|
||||
const body = {
|
||||
message: 'deleted by PicList',
|
||||
sha,
|
||||
branch
|
||||
branch,
|
||||
}
|
||||
const res = await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/contents/${key}`,
|
||||
getOptions('DELETE', this.commonHeaders, undefined, 'json', JSON.stringify(body), undefined, this.proxy)
|
||||
getOptions('DELETE', this.commonHeaders, undefined, 'json', JSON.stringify(body), undefined, this.proxy),
|
||||
)
|
||||
return res.statusCode === 200
|
||||
}
|
||||
@@ -308,14 +308,14 @@ class GithubApi {
|
||||
// get sha of the branch
|
||||
const refRes = (await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/refs/heads/${branch}`,
|
||||
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (refRes.statusCode !== 200) return false
|
||||
const refSha = refRes.body.object.sha
|
||||
// get sha of the root tree
|
||||
const rootRes = (await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/branches/${branch}`,
|
||||
getOptions('GET', undefined, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', undefined, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (rootRes.statusCode !== 200) return false
|
||||
const rootSha = rootRes.body.commit.commit.tree.sha
|
||||
@@ -328,13 +328,13 @@ class GithubApi {
|
||||
'GET',
|
||||
this.commonHeaders,
|
||||
{
|
||||
recursive: true
|
||||
recursive: true,
|
||||
},
|
||||
'json',
|
||||
undefined,
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (treeRes.statusCode !== 200) return false
|
||||
const oldTree = treeRes.body.tree
|
||||
@@ -345,7 +345,7 @@ class GithubApi {
|
||||
path: `${key.replace(/(^\/+|\/+$)/g, '')}/${item.path}`,
|
||||
mode: item.mode,
|
||||
type: item.type,
|
||||
sha: null
|
||||
sha: null,
|
||||
}))
|
||||
const newTreeShaRes = (await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees`,
|
||||
@@ -356,11 +356,11 @@ class GithubApi {
|
||||
'json',
|
||||
JSON.stringify({
|
||||
base_tree: rootSha,
|
||||
tree: newTree
|
||||
tree: newTree,
|
||||
}),
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (newTreeShaRes.statusCode !== 201) return false
|
||||
const newTreeSha = newTreeShaRes.body.sha
|
||||
@@ -375,11 +375,11 @@ class GithubApi {
|
||||
JSON.stringify({
|
||||
message: 'deleted by PicList',
|
||||
tree: newTreeSha,
|
||||
parents: [refSha]
|
||||
parents: [refSha],
|
||||
}),
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (commitRes.statusCode !== 201) return false
|
||||
const commitSha = commitRes.body.sha
|
||||
@@ -392,11 +392,11 @@ class GithubApi {
|
||||
undefined,
|
||||
'json',
|
||||
JSON.stringify({
|
||||
sha: commitSha
|
||||
sha: commitSha,
|
||||
}),
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
return updateRefRes.statusCode === 200
|
||||
}
|
||||
@@ -421,13 +421,13 @@ class GithubApi {
|
||||
'GET',
|
||||
this.commonHeaders,
|
||||
{
|
||||
ref: branch
|
||||
ref: branch,
|
||||
},
|
||||
'json',
|
||||
undefined,
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
return res.statusCode === 200 ? res.body.download_url : ''
|
||||
}
|
||||
@@ -443,11 +443,11 @@ class GithubApi {
|
||||
const body = {
|
||||
message: `created a new folder named ${key} by PicList`,
|
||||
content: base64Content,
|
||||
branch
|
||||
branch,
|
||||
}
|
||||
const res = await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/contents/${newFileKey}`,
|
||||
getOptions('PUT', this.commonHeaders, undefined, 'json', JSON.stringify(body), undefined, this.proxy)
|
||||
getOptions('PUT', this.commonHeaders, undefined, 'json', JSON.stringify(body), undefined, this.proxy),
|
||||
)
|
||||
return res.statusCode === 201
|
||||
}
|
||||
@@ -479,7 +479,7 @@ class GithubApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: repo,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
gotUpload(
|
||||
instance,
|
||||
@@ -488,14 +488,14 @@ class GithubApi {
|
||||
JSON.stringify({
|
||||
message: 'uploaded by PicList',
|
||||
branch,
|
||||
content: base64Content
|
||||
content: base64Content,
|
||||
}),
|
||||
this.commonHeaders,
|
||||
id,
|
||||
this.logger,
|
||||
30000,
|
||||
false,
|
||||
getAgent(this.proxy)
|
||||
getAgent(this.proxy),
|
||||
)
|
||||
}
|
||||
return true
|
||||
@@ -521,7 +521,7 @@ class GithubApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
let downloadUrl: string
|
||||
if (githubPrivate) {
|
||||
@@ -530,7 +530,7 @@ class GithubApi {
|
||||
customUrl: branch,
|
||||
key,
|
||||
rawUrl: githubUrl,
|
||||
githubPrivate
|
||||
githubPrivate,
|
||||
})
|
||||
downloadUrl = preSignedUrl
|
||||
} else {
|
||||
@@ -546,7 +546,7 @@ class GithubApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
@@ -554,8 +554,8 @@ class GithubApi {
|
||||
this.logger.error(
|
||||
formatError(error, {
|
||||
class: 'GithubApi',
|
||||
method: 'downloadBucketFile'
|
||||
})
|
||||
method: 'downloadBucketFile',
|
||||
}),
|
||||
)
|
||||
})
|
||||
return true
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
getFileMimeType,
|
||||
getOptions,
|
||||
gotUpload,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import ManageLogger from '~/manage/utils/logger'
|
||||
import { formatHttpProxy, isImage } from '~/utils/common'
|
||||
@@ -38,7 +38,7 @@ class ImgurApi {
|
||||
this.proxyStr = formatHttpProxy(proxy, 'string') as string | undefined
|
||||
this.logger = logger
|
||||
this.tokenHeaders = {
|
||||
Authorization: this.accessToken
|
||||
Authorization: this.accessToken,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class ImgurApi {
|
||||
match: false,
|
||||
isImage: isImg,
|
||||
url: item.link,
|
||||
sha: item.deletehash
|
||||
sha: item.deletehash,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class ImgurApi {
|
||||
do {
|
||||
res = (await got(
|
||||
`${this.baseUrl}/account/${this.userName}/albums/${initPage}`,
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (!(res.statusCode === 200 && res.body.success)) {
|
||||
return []
|
||||
@@ -83,12 +83,12 @@ class ImgurApi {
|
||||
...item,
|
||||
Name: item.title,
|
||||
Location: item.id,
|
||||
CreationDate: item.datetime
|
||||
CreationDate: item.datetime,
|
||||
})) as any[]
|
||||
finalResult.push({
|
||||
Name: '全部',
|
||||
Location: 'unclassified',
|
||||
CreationDate: new Date().getTime()
|
||||
CreationDate: new Date().getTime(),
|
||||
})
|
||||
return finalResult
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class ImgurApi {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const {
|
||||
bucketConfig: { Location: albumHash },
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const cancelTask = [false]
|
||||
ipcMain.on('cancelLoadingFileList', (_: IpcMainEvent, token: string) => {
|
||||
@@ -110,12 +110,12 @@ class ImgurApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
if (albumHash !== 'unclassified') {
|
||||
res = (await got(
|
||||
`${this.baseUrl}/account/${this.userName}/album/${albumHash}`,
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (res.statusCode === 200 && res.body.success) {
|
||||
res.body.data.images.forEach((item: any) => {
|
||||
@@ -132,7 +132,7 @@ class ImgurApi {
|
||||
do {
|
||||
res = (await got(
|
||||
`${this.baseUrl}/account/${this.userName}/images/${initPage}`,
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (res.statusCode === 200 && res.body.success) {
|
||||
res.body.data.forEach((item: any) => {
|
||||
@@ -157,7 +157,7 @@ class ImgurApi {
|
||||
const { DeleteHash: deleteHash } = configMap
|
||||
const res = (await got(
|
||||
`${this.baseUrl}/account/${this.userName}/image/${deleteHash}`,
|
||||
getOptions('DELETE', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('DELETE', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
return res.statusCode === 200 && res.body.success
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class ImgurApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: albumHash
|
||||
targetFileRegion: albumHash,
|
||||
})
|
||||
const form = new FormData()
|
||||
form.append('type', 'file')
|
||||
@@ -195,12 +195,12 @@ class ImgurApi {
|
||||
if (fileSize > 1024 * 1024 * 10) {
|
||||
form.append('video', fs.createReadStream(filePath), {
|
||||
filename: path.basename(key),
|
||||
contentType: getFileMimeType(fileName)
|
||||
contentType: getFileMimeType(fileName),
|
||||
})
|
||||
} else {
|
||||
form.append('image', fs.createReadStream(filePath), {
|
||||
filename: path.basename(key),
|
||||
contentType: getFileMimeType(fileName)
|
||||
contentType: getFileMimeType(fileName),
|
||||
})
|
||||
}
|
||||
albumHash !== 'unclassified' && form.append('album', albumHash)
|
||||
@@ -216,7 +216,7 @@ class ImgurApi {
|
||||
this.logger,
|
||||
30000,
|
||||
false,
|
||||
getAgent(this.proxy)
|
||||
getAgent(this.proxy),
|
||||
)
|
||||
}
|
||||
return true
|
||||
@@ -242,7 +242,7 @@ class ImgurApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -254,7 +254,7 @@ class ImgurApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -53,7 +53,7 @@ class LocalApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
url: urlPrefix
|
||||
url: urlPrefix,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class LocalApi {
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(fileName),
|
||||
url: urlPrefix
|
||||
url: urlPrefix,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,20 +89,20 @@ class LocalApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
res = fsWalk.walkSync(this.transBack(prefix), {
|
||||
followSymbolicLinks: true,
|
||||
fs,
|
||||
stats: true,
|
||||
throwErrorOnBrokenSymbolicLink: false
|
||||
throwErrorOnBrokenSymbolicLink: false,
|
||||
})
|
||||
if (res.length) {
|
||||
result.fullList.push(
|
||||
...res
|
||||
.filter((item: fsWalk.Entry) => item.stats?.isFile())
|
||||
.map((item: any) => this.formatFile(item, urlPrefix, item.name, item.path, true))
|
||||
.map((item: any) => this.formatFile(item, urlPrefix, item.name, item.path, true)),
|
||||
)
|
||||
result.success = true
|
||||
}
|
||||
@@ -135,11 +135,11 @@ class LocalApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
const res = await fs.readdir(prefix, {
|
||||
withFileTypes: true
|
||||
withFileTypes: true,
|
||||
})
|
||||
if (res.length) {
|
||||
let urlPrefixF
|
||||
@@ -199,7 +199,7 @@ class LocalApi {
|
||||
let result = false
|
||||
try {
|
||||
await fs.rm(this.transBack(key), {
|
||||
recursive: true
|
||||
recursive: true,
|
||||
})
|
||||
result = true
|
||||
} catch (error) {
|
||||
@@ -226,7 +226,7 @@ class LocalApi {
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: '',
|
||||
noProgress: true
|
||||
noProgress: true,
|
||||
})
|
||||
try {
|
||||
fs.ensureFileSync(this.transBack(key))
|
||||
@@ -235,7 +235,7 @@ class LocalApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} catch (error) {
|
||||
this.logParam(error, 'uploadBucketFile')
|
||||
@@ -243,7 +243,7 @@ class LocalApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@ class LocalApi {
|
||||
let result = false
|
||||
try {
|
||||
await fs.mkdir(this.transBack(key), {
|
||||
recursive: true
|
||||
recursive: true,
|
||||
})
|
||||
result = true
|
||||
} catch (error) {
|
||||
@@ -279,7 +279,7 @@ class LocalApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
try {
|
||||
fs.ensureFileSync(savedFilePath)
|
||||
@@ -288,7 +288,7 @@ class LocalApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: downloadTaskSpecialStatus.downloaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} catch (error) {
|
||||
this.logParam(error, 'downloadBucketFile')
|
||||
@@ -296,7 +296,7 @@ class LocalApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
formatError,
|
||||
getFileMimeType,
|
||||
hmacSha1Base64,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import { ManageLogger } from '~/manage/utils/logger'
|
||||
import { isImage } from '~/utils/common'
|
||||
@@ -30,7 +30,7 @@ class QiniuApi {
|
||||
|
||||
hostList = {
|
||||
getBucketList: 'https://uc.qiniuapi.com/buckets',
|
||||
getBucketDomain: 'https://uc.qiniuapi.com/v2/domains'
|
||||
getBucketDomain: 'https://uc.qiniuapi.com/v2/domains',
|
||||
}
|
||||
|
||||
constructor(accessKey: string, secretKey: string, logger: ManageLogger) {
|
||||
@@ -50,7 +50,7 @@ class QiniuApi {
|
||||
isDir: true,
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false
|
||||
match: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class QiniuApi {
|
||||
isDir: false,
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(fileName)
|
||||
isImage: isImage(fileName),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class QiniuApi {
|
||||
body: string,
|
||||
query: string,
|
||||
contentType: string,
|
||||
xQiniuHeaders?: IStringKeyMap
|
||||
xQiniuHeaders?: IStringKeyMap,
|
||||
) {
|
||||
let signStr = `${method.toUpperCase()} ${urlPath}${query ? `?${query}` : ''}\nHost: ${host}`
|
||||
|
||||
@@ -104,9 +104,9 @@ class QiniuApi {
|
||||
const res = await axios.get(host, {
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': this.commonType
|
||||
'Content-Type': this.commonType,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
if (res?.status === 200 && res?.data?.length) {
|
||||
const result = [] as any[]
|
||||
@@ -117,7 +117,7 @@ class QiniuApi {
|
||||
Name: dataItem,
|
||||
Location: info.zone,
|
||||
CreationDate: new Date().toISOString(),
|
||||
Private: info.private
|
||||
Private: info.private,
|
||||
})
|
||||
}
|
||||
return result
|
||||
@@ -137,23 +137,23 @@ class QiniuApi {
|
||||
url: `https://${this.host}/v2/bucketInfo`,
|
||||
params: {
|
||||
bucket: bucketName,
|
||||
fs: true
|
||||
fs: true,
|
||||
},
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': 'application/json',
|
||||
Host: this.host
|
||||
Host: this.host,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
return res?.status === 200
|
||||
? {
|
||||
success: true,
|
||||
private: res.data.private,
|
||||
zone: res.data.zone
|
||||
zone: res.data.zone,
|
||||
}
|
||||
: {
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,13 +166,13 @@ class QiniuApi {
|
||||
const authorization = qiniu.util.generateAccessToken(this.mac, `${host}?tbl=${bucketName}`, undefined)
|
||||
const res = await axios.get(host, {
|
||||
params: {
|
||||
tbl: bucketName
|
||||
tbl: bucketName,
|
||||
},
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': this.commonType
|
||||
'Content-Type': this.commonType,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
return res?.status === 200 && res?.data?.length ? res.data : []
|
||||
}
|
||||
@@ -192,14 +192,14 @@ class QiniuApi {
|
||||
url: `https://${this.host}/private`,
|
||||
params: {
|
||||
bucket: bucketName,
|
||||
private: isPrivate
|
||||
private: isPrivate,
|
||||
},
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': this.commonType,
|
||||
Host: this.host
|
||||
Host: this.host,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
return res?.status === 200
|
||||
}
|
||||
@@ -223,14 +223,14 @@ class QiniuApi {
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': 'application/json',
|
||||
Host: this.host
|
||||
Host: this.host,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
return res?.status === 200
|
||||
? await this.setBucketAclPolicy({
|
||||
bucketName: BucketName,
|
||||
isPrivate: !acl
|
||||
isPrivate: !acl,
|
||||
})
|
||||
: false
|
||||
}
|
||||
@@ -251,7 +251,7 @@ class QiniuApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const config = new qiniu.conf.Config()
|
||||
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
||||
@@ -262,7 +262,7 @@ class QiniuApi {
|
||||
{
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
marker,
|
||||
limit: 1000
|
||||
limit: 1000,
|
||||
},
|
||||
(err: any, respBody: any, respInfo: any) => {
|
||||
if (err) {
|
||||
@@ -270,10 +270,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
if (res && res.respInfo.statusCode === 200) {
|
||||
@@ -313,7 +313,7 @@ class QiniuApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const config = new qiniu.conf.Config()
|
||||
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
||||
@@ -325,7 +325,7 @@ class QiniuApi {
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
delimiter: '/',
|
||||
marker,
|
||||
limit: 1000
|
||||
limit: 1000,
|
||||
},
|
||||
(err: any, respBody: any, respInfo: any) => {
|
||||
if (err) {
|
||||
@@ -333,10 +333,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
if (res && res.respInfo.statusCode === 200) {
|
||||
@@ -390,7 +390,7 @@ class QiniuApi {
|
||||
fullList: [] as any,
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
res = await new Promise((resolve, reject) => {
|
||||
bucketManager.listPrefix(
|
||||
@@ -399,7 +399,7 @@ class QiniuApi {
|
||||
limit: itemsPerPage,
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
marker,
|
||||
delimiter: '/'
|
||||
delimiter: '/',
|
||||
},
|
||||
(err, respBody, respInfo) => {
|
||||
if (err) {
|
||||
@@ -407,10 +407,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
if (res?.respInfo?.statusCode === 200) {
|
||||
@@ -451,7 +451,7 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -470,7 +470,7 @@ class QiniuApi {
|
||||
let marker = ''
|
||||
let isTruncated = true
|
||||
const allFileList = {
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
do {
|
||||
const res = (await new Promise((resolve, reject) => {
|
||||
@@ -479,7 +479,7 @@ class QiniuApi {
|
||||
{
|
||||
prefix: key,
|
||||
marker,
|
||||
limit: 1000
|
||||
limit: 1000,
|
||||
},
|
||||
(err, respBody, respInfo) => {
|
||||
if (err) {
|
||||
@@ -487,10 +487,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})) as any
|
||||
if (res?.respInfo?.statusCode === 200) {
|
||||
@@ -515,7 +515,7 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -546,7 +546,7 @@ class QiniuApi {
|
||||
bucketName,
|
||||
newKey,
|
||||
{
|
||||
force: true
|
||||
force: true,
|
||||
},
|
||||
(err, respBody, respInfo) => {
|
||||
if (err) {
|
||||
@@ -554,10 +554,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})) as any
|
||||
return res?.respInfo?.statusCode === 200
|
||||
@@ -604,14 +604,14 @@ class QiniuApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
const config = new qiniu.conf.Config()
|
||||
const resumeUploader = new qiniu.resume_up.ResumeUploader(config)
|
||||
const putExtra = new qiniu.resume_up.PutExtra()
|
||||
const uploadToken = new qiniu.rs.PutPolicy({
|
||||
scope: `${bucketName}:${key}`,
|
||||
expires: 36000
|
||||
expires: 36000,
|
||||
}).uploadToken(this.mac)
|
||||
putExtra.fname = key
|
||||
putExtra.params = {}
|
||||
@@ -623,7 +623,7 @@ class QiniuApi {
|
||||
instance.updateUploadTask({
|
||||
id: `${bucketName}-${region}-${key}-${filePath}`,
|
||||
progress,
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
}
|
||||
resumeUploader.putFile(uploadToken, key, filePath, putExtra, (respErr, respBody, respInfo) => {
|
||||
@@ -631,14 +631,14 @@ class QiniuApi {
|
||||
this.logger.error(
|
||||
formatError(respErr, {
|
||||
class: 'Qiniu',
|
||||
method: 'uploadBucketFile'
|
||||
})
|
||||
method: 'uploadBucketFile',
|
||||
}),
|
||||
)
|
||||
instance.updateUploadTask({
|
||||
id: `${bucketName}-${region}-${key}-${filePath}`,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -648,14 +648,14 @@ class QiniuApi {
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
response: JSON.stringify(respBody),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
id: `${bucketName}-${region}-${key}-${filePath}`,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -670,7 +670,7 @@ class QiniuApi {
|
||||
async createBucketFolder(configMap: IStringKeyMap): Promise<boolean> {
|
||||
const { bucketName, key } = configMap
|
||||
const putPolicy = new qiniu.rs.PutPolicy({
|
||||
scope: `${bucketName}:${key}`
|
||||
scope: `${bucketName}:${key}`,
|
||||
})
|
||||
const uploadToken = putPolicy.uploadToken(this.mac)
|
||||
const FormUploader = new qiniu.form_up.FormUploader()
|
||||
@@ -682,7 +682,7 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -710,12 +710,12 @@ class QiniuApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
const preSignedUrl = await this.getPreSignedUrl({
|
||||
key,
|
||||
expires: 36000,
|
||||
customUrl
|
||||
customUrl,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -727,7 +727,7 @@ class QiniuApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
PutObjectCommand,
|
||||
PutPublicAccessBlockCommand,
|
||||
S3Client,
|
||||
S3ClientConfig
|
||||
S3ClientConfig,
|
||||
} from '@aws-sdk/client-s3'
|
||||
import { Progress, Upload } from '@aws-sdk/lib-storage'
|
||||
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
|
||||
@@ -55,7 +55,7 @@ class S3plistApi {
|
||||
proxy: string | undefined,
|
||||
logger: ManageLogger,
|
||||
dogeCloudSupport: boolean = false,
|
||||
bucketName: string = ''
|
||||
bucketName: string = '',
|
||||
) {
|
||||
this.accessKeyId = accessKeyId
|
||||
this.secretAccessKey = secretAccessKey
|
||||
@@ -64,12 +64,12 @@ class S3plistApi {
|
||||
this.baseOptions = {
|
||||
credentials: {
|
||||
accessKeyId,
|
||||
secretAccessKey
|
||||
secretAccessKey,
|
||||
},
|
||||
endpoint: endpoint ? formatEndpoint(endpoint, sslEnabled) : undefined,
|
||||
tls: sslEnabled,
|
||||
forcePathStyle: s3ForcePathStyle,
|
||||
requestHandler: this.setAgent(proxy, sslEnabled)
|
||||
requestHandler: this.setAgent(proxy, sslEnabled),
|
||||
}
|
||||
this.logger = logger
|
||||
this.proxy = formatHttpProxy(proxy, 'string') as string | undefined
|
||||
@@ -84,7 +84,7 @@ class S3plistApi {
|
||||
this.baseOptions.credentials = {
|
||||
accessKeyId: token.accessKeyId,
|
||||
secretAccessKey: token.secretAccessKey,
|
||||
sessionToken: token.sessionToken
|
||||
sessionToken: token.sessionToken,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class S3plistApi {
|
||||
const commonOptions: AgentOptions = {
|
||||
keepAlive: true,
|
||||
keepAliveMsecs: 1000,
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
|
||||
}
|
||||
const extraOptions = sslEnabled ? { rejectUnauthorized: false } : {}
|
||||
return sslEnabled
|
||||
@@ -102,16 +102,16 @@ class S3plistApi {
|
||||
? agent.https
|
||||
: new https.Agent({
|
||||
...commonOptions,
|
||||
...extraOptions
|
||||
})
|
||||
...extraOptions,
|
||||
}),
|
||||
})
|
||||
: new NodeHttpHandler({
|
||||
httpAgent: agent.http
|
||||
? agent.http
|
||||
: new http.Agent({
|
||||
...commonOptions,
|
||||
...extraOptions
|
||||
})
|
||||
...extraOptions,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class S3plistApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
key: item.Prefix
|
||||
key: item.Prefix,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ class S3plistApi {
|
||||
isDir: false,
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(fileName || '')
|
||||
isImage: isImage(fileName || ''),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ class S3plistApi {
|
||||
BlockPublicAcls: false,
|
||||
IgnorePublicAcls: false,
|
||||
BlockPublicPolicy: false,
|
||||
RestrictPublicBuckets: false
|
||||
}
|
||||
RestrictPublicBuckets: false,
|
||||
},
|
||||
}
|
||||
const command = new PutPublicAccessBlockCommand(input)
|
||||
const data = await client.send(command)
|
||||
@@ -193,7 +193,7 @@ class S3plistApi {
|
||||
if (endpoint === '' || endpoint.includes('amazonaws')) {
|
||||
const createCommand = new CreateBucketCommand({
|
||||
Bucket: BucketName,
|
||||
ObjectOwnership: 'BucketOwnerPreferred'
|
||||
ObjectOwnership: 'BucketOwnerPreferred',
|
||||
})
|
||||
const createData = await client.send(createCommand)
|
||||
if (createData.$metadata.httpStatusCode === 200) {
|
||||
@@ -201,7 +201,7 @@ class S3plistApi {
|
||||
await this.putPublicAccess(BucketName, client)
|
||||
const putACLCommand = new PutBucketAclCommand({
|
||||
Bucket: BucketName,
|
||||
ACL: acl
|
||||
ACL: acl,
|
||||
})
|
||||
const putACLData = await client.send(putACLCommand)
|
||||
if (putACLData.$metadata.httpStatusCode !== 200) {
|
||||
@@ -216,7 +216,7 @@ class S3plistApi {
|
||||
} else {
|
||||
const createCommand = new CreateBucketCommand({
|
||||
Bucket: BucketName,
|
||||
ACL: acl
|
||||
ACL: acl,
|
||||
})
|
||||
const createData = await client.send(createCommand)
|
||||
if (createData.$metadata.httpStatusCode === 200) {
|
||||
@@ -244,8 +244,8 @@ class S3plistApi {
|
||||
{
|
||||
Name: item.s3Bucket,
|
||||
CreationDate: item.ctime,
|
||||
Location: item.region
|
||||
}
|
||||
Location: item.region,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -274,16 +274,16 @@ class S3plistApi {
|
||||
...data.Buckets.map(bucket => ({
|
||||
Name: bucket.Name,
|
||||
CreationDate: bucket.CreationDate,
|
||||
Location: 'auto'
|
||||
}))
|
||||
Location: 'auto',
|
||||
})),
|
||||
)
|
||||
} else {
|
||||
for (const bucket of data.Buckets) {
|
||||
const bucketName = bucket.Name
|
||||
const bucketConfig = await client.send(
|
||||
new GetBucketLocationCommand({
|
||||
Bucket: bucketName
|
||||
})
|
||||
Bucket: bucketName,
|
||||
}),
|
||||
)
|
||||
result.push({
|
||||
Name: bucketName,
|
||||
@@ -291,7 +291,7 @@ class S3plistApi {
|
||||
Location:
|
||||
bucketConfig.$metadata.httpStatusCode === 200
|
||||
? bucketConfig.LocationConstraint?.toLowerCase() || 'us-east-1'
|
||||
: 'us-east-1'
|
||||
: 'us-east-1',
|
||||
})
|
||||
if (bucketConfig.$metadata.httpStatusCode !== 200) {
|
||||
this.logParam(bucketConfig, 'getBucketList')
|
||||
@@ -311,7 +311,7 @@ class S3plistApi {
|
||||
bucketName: bucket,
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
||||
@@ -327,7 +327,7 @@ class S3plistApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
do {
|
||||
@@ -338,7 +338,7 @@ class S3plistApi {
|
||||
Bucket: bucket,
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
MaxKeys: 1000,
|
||||
ContinuationToken: marker
|
||||
ContinuationToken: marker,
|
||||
})
|
||||
res = await client.send(command)
|
||||
if (res.$metadata.httpStatusCode === 200) {
|
||||
@@ -375,7 +375,7 @@ class S3plistApi {
|
||||
bucketName: bucket,
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
||||
@@ -391,7 +391,7 @@ class S3plistApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
await this.getDogeCloudToken()
|
||||
@@ -404,7 +404,7 @@ class S3plistApi {
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
MaxKeys: 1000,
|
||||
ContinuationToken: marker,
|
||||
Delimiter: '/'
|
||||
Delimiter: '/',
|
||||
})
|
||||
res = await client.send(command)
|
||||
if (res.$metadata.httpStatusCode === 200) {
|
||||
@@ -445,7 +445,7 @@ class S3plistApi {
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
marker,
|
||||
itemsPerPage
|
||||
itemsPerPage,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
||||
@@ -453,13 +453,13 @@ class S3plistApi {
|
||||
fullList: [] as any,
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
try {
|
||||
await this.getDogeCloudToken()
|
||||
const options = {
|
||||
...this.baseOptions,
|
||||
region: String(region) || 'us-east-1'
|
||||
region: String(region) || 'us-east-1',
|
||||
} as S3ClientConfig
|
||||
const client = new S3Client(options)
|
||||
const command = new ListObjectsV2Command({
|
||||
@@ -467,13 +467,13 @@ class S3plistApi {
|
||||
Prefix: slicedPrefix,
|
||||
ContinuationToken: marker === '' ? undefined : marker,
|
||||
Delimiter: '/',
|
||||
MaxKeys: itemsPerPage
|
||||
MaxKeys: itemsPerPage,
|
||||
})
|
||||
const data = await client.send(command)
|
||||
if (data.$metadata.httpStatusCode === 200) {
|
||||
result.fullList = [
|
||||
...(data.CommonPrefixes?.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)) || []),
|
||||
...(data.Contents?.map(item => this.formatFile(item, slicedPrefix, urlPrefix)) || [])
|
||||
...(data.Contents?.map(item => this.formatFile(item, slicedPrefix, urlPrefix)) || []),
|
||||
]
|
||||
result.isTruncated = data.IsTruncated || false
|
||||
result.nextMarker = data.NextContinuationToken || ''
|
||||
@@ -502,19 +502,19 @@ class S3plistApi {
|
||||
await this.getDogeCloudToken()
|
||||
const options = {
|
||||
...this.baseOptions,
|
||||
region: String(region) || 'us-east-1'
|
||||
region: String(region) || 'us-east-1',
|
||||
} as S3ClientConfig
|
||||
const client = new S3Client(options)
|
||||
const command = new CopyObjectCommand({
|
||||
Bucket: bucketName,
|
||||
CopySource: encodeURI(`${bucketName}/${oldKey}`),
|
||||
Key: newKey
|
||||
Key: newKey,
|
||||
})
|
||||
const data = await client.send(command)
|
||||
if (data.$metadata.httpStatusCode === 200) {
|
||||
const deleteCommand = new DeleteObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: oldKey
|
||||
Key: oldKey,
|
||||
})
|
||||
const deleteData = await client.send(deleteCommand)
|
||||
if (deleteData.$metadata.httpStatusCode === 204) {
|
||||
@@ -550,7 +550,7 @@ class S3plistApi {
|
||||
const client = new S3Client(options)
|
||||
const command = new DeleteObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: key
|
||||
Key: key,
|
||||
})
|
||||
const data = await client.send(command)
|
||||
if (data.$metadata.httpStatusCode === 204) {
|
||||
@@ -576,7 +576,7 @@ class S3plistApi {
|
||||
let res
|
||||
const allFileList = {
|
||||
CommonPrefixes: [] as any[],
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
try {
|
||||
await this.getDogeCloudToken()
|
||||
@@ -589,7 +589,7 @@ class S3plistApi {
|
||||
Prefix: key,
|
||||
ContinuationToken: marker === '' ? undefined : marker,
|
||||
Delimiter: '/',
|
||||
MaxKeys: 1000
|
||||
MaxKeys: 1000,
|
||||
})
|
||||
res = (await client.send(command)) as ListObjectsV2CommandOutput
|
||||
if (res.$metadata.httpStatusCode === 200) {
|
||||
@@ -607,7 +607,7 @@ class S3plistApi {
|
||||
res = await this.deleteBucketFolder({
|
||||
bucketName,
|
||||
region,
|
||||
key: item.Prefix
|
||||
key: item.Prefix,
|
||||
})
|
||||
if (!res) {
|
||||
return result
|
||||
@@ -626,10 +626,10 @@ class S3plistApi {
|
||||
Delete: {
|
||||
Objects: deleteList.map(item => {
|
||||
return {
|
||||
Key: item.Key
|
||||
Key: item.Key,
|
||||
}
|
||||
})
|
||||
}
|
||||
}),
|
||||
},
|
||||
})
|
||||
res = await client.send(deleteCommand)
|
||||
if (res.$metadata.httpStatusCode !== 200) {
|
||||
@@ -668,11 +668,11 @@ class S3plistApi {
|
||||
client,
|
||||
new GetObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: key
|
||||
Key: key,
|
||||
}),
|
||||
{
|
||||
expiresIn: expires || 3600
|
||||
}
|
||||
expiresIn: expires || 3600,
|
||||
},
|
||||
)
|
||||
return signedUrl
|
||||
} catch (error) {
|
||||
@@ -695,7 +695,7 @@ class S3plistApi {
|
||||
const client = new S3Client(options)
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: key
|
||||
Key: key,
|
||||
})
|
||||
const data = await client.send(command)
|
||||
if (data.$metadata.httpStatusCode === 200) {
|
||||
@@ -733,7 +733,7 @@ class S3plistApi {
|
||||
'aws-exec-read',
|
||||
'authenticated-read',
|
||||
'bucket-owner-read',
|
||||
'bucket-owner-full-control'
|
||||
'bucket-owner-full-control',
|
||||
]
|
||||
for (const item of fileArray) {
|
||||
const { bucketName, region, key, filePath, fileName, aclForUpload } = item
|
||||
@@ -749,7 +749,7 @@ class S3plistApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: String(region)
|
||||
targetFileRegion: String(region),
|
||||
})
|
||||
try {
|
||||
await this.getDogeCloudToken()
|
||||
@@ -760,7 +760,7 @@ class S3plistApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: JSON.stringify(error),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
continue
|
||||
}
|
||||
@@ -777,15 +777,15 @@ class S3plistApi {
|
||||
ContentType: getFileMimeType(fileName),
|
||||
ACL: allowedAcl.includes(aclForUpload) ? aclForUpload : 'private',
|
||||
Metadata: {
|
||||
description: 'uploaded by PicList'
|
||||
}
|
||||
}
|
||||
description: 'uploaded by PicList',
|
||||
},
|
||||
},
|
||||
})
|
||||
parallelUploads3.on('httpUploadProgress', (progress: Progress) => {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: progress.loaded && progress.total ? Math.floor((progress.loaded / progress.total) * 100) : 0,
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
})
|
||||
parallelUploads3
|
||||
@@ -796,14 +796,14 @@ class S3plistApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -814,7 +814,7 @@ class S3plistApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: JSON.stringify(error),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -841,14 +841,14 @@ class S3plistApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
const preSignedUrl = await this.getPreSignedUrl({
|
||||
bucketName,
|
||||
region: String(region),
|
||||
key,
|
||||
expires: 36000,
|
||||
customUrl
|
||||
customUrl,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -860,7 +860,7 @@ class S3plistApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -53,7 +53,7 @@ class SftpApi {
|
||||
passphrase: Undefinable<string>,
|
||||
fileMode: Undefinable<string>,
|
||||
dirMode: Undefinable<string>,
|
||||
logger: ManageLogger
|
||||
logger: ManageLogger,
|
||||
) {
|
||||
this.host = host
|
||||
this.port = Number(port) || 22
|
||||
@@ -71,7 +71,7 @@ class SftpApi {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
privateKey: this.privateKey,
|
||||
passphrase: this.passphrase
|
||||
passphrase: this.passphrase,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class SftpApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
url
|
||||
url,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class SftpApi {
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(item.filename),
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ class SftpApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
await this.connectClient()
|
||||
@@ -211,7 +211,7 @@ class SftpApi {
|
||||
size: Number(size) || 0,
|
||||
mtime,
|
||||
filename,
|
||||
key
|
||||
key,
|
||||
})
|
||||
})
|
||||
return result
|
||||
@@ -237,7 +237,7 @@ class SftpApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
await this.connectClient()
|
||||
@@ -339,13 +339,13 @@ class SftpApi {
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region,
|
||||
noProgress: false
|
||||
noProgress: false,
|
||||
})
|
||||
try {
|
||||
await this.connectClient()
|
||||
const res = await this.ctx.putFile(filePath, `/${key.replace(/^\/+/, '')}`, {
|
||||
fileMode: this.fileMode,
|
||||
dirMode: this.dirMode
|
||||
dirMode: this.dirMode,
|
||||
})
|
||||
this.ctx.close()
|
||||
if (res) {
|
||||
@@ -353,14 +353,14 @@ class SftpApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -369,7 +369,7 @@ class SftpApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -405,7 +405,7 @@ class SftpApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
try {
|
||||
await this.connectClient()
|
||||
@@ -416,14 +416,14 @@ class SftpApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: downloadTaskSpecialStatus.downloaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateDownloadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -432,7 +432,7 @@ class SftpApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ class SmmsApi {
|
||||
baseURL: this.baseUrl,
|
||||
timeout: this.timeout,
|
||||
headers: {
|
||||
Authorization: this.token
|
||||
Authorization: this.token,
|
||||
},
|
||||
httpsAgent: new Agent({
|
||||
keepAlive: true,
|
||||
timeout: this.timeout
|
||||
})
|
||||
timeout: this.timeout,
|
||||
}),
|
||||
})
|
||||
this.logger = logger
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class SmmsApi {
|
||||
match: false,
|
||||
isImage: isImage(item.storename),
|
||||
sha: item.hash,
|
||||
downloadUrl: item.url
|
||||
downloadUrl: item.url,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,17 +69,17 @@ class SmmsApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
do {
|
||||
res = await this.axiosInstance('/upload_history', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
params: {
|
||||
page: marker
|
||||
}
|
||||
page: marker,
|
||||
},
|
||||
})
|
||||
if (res && res.status === 200 && res.data && res.data.success) {
|
||||
if (res.data.Count === 0) {
|
||||
@@ -128,16 +128,16 @@ class SmmsApi {
|
||||
fullList: [] as any,
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
const res = await this.axiosInstance('/upload_history', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
params: {
|
||||
page: currentPage
|
||||
}
|
||||
page: currentPage,
|
||||
},
|
||||
})
|
||||
if (res?.status !== 200 || !res?.data?.success) return result
|
||||
|
||||
@@ -167,8 +167,8 @@ class SmmsApi {
|
||||
method: 'GET',
|
||||
params: {
|
||||
hash: DeleteHash,
|
||||
format: 'json'
|
||||
}
|
||||
format: 'json',
|
||||
},
|
||||
})
|
||||
return res?.status === 200 && res?.data?.success
|
||||
}
|
||||
@@ -194,13 +194,13 @@ class SmmsApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
const form = new FormData()
|
||||
form.append('format', 'json')
|
||||
form.append('smfile', fs.createReadStream(filePath), {
|
||||
filename: path.basename(fileName),
|
||||
contentType: getFileMimeType(fileName)
|
||||
contentType: getFileMimeType(fileName),
|
||||
})
|
||||
const headers = form.getHeaders()
|
||||
headers.Authorization = this.token
|
||||
@@ -230,7 +230,7 @@ class SmmsApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -242,7 +242,7 @@ class SmmsApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -20,7 +20,7 @@ class TcyunApi {
|
||||
constructor(secretId: string, secretKey: string, logger: ManageLogger) {
|
||||
this.ctx = new COS({
|
||||
SecretId: secretId,
|
||||
SecretKey: secretKey
|
||||
SecretKey: secretKey,
|
||||
})
|
||||
this.logger = logger
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class TcyunApi {
|
||||
isDir: true,
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false
|
||||
match: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class TcyunApi {
|
||||
checked: false,
|
||||
isImage: isImage(item.Key),
|
||||
match: false,
|
||||
url: `${urlPrefix}/${item.Key}`
|
||||
url: `${urlPrefix}/${item.Key}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class TcyunApi {
|
||||
const { bucketName, region } = param
|
||||
const res = await this.ctx.getBucketDomain({
|
||||
Bucket: bucketName,
|
||||
Region: region
|
||||
Region: region,
|
||||
})
|
||||
if (res?.statusCode !== 200 || !res?.DomainRule?.length) return []
|
||||
return res.DomainRule.filter((item: any) => item.Status === 'ENABLED').map(item => item.Name)
|
||||
@@ -91,7 +91,7 @@ class TcyunApi {
|
||||
const res = await this.ctx.putBucket({
|
||||
ACL: configMap.acl,
|
||||
Bucket: configMap.BucketName,
|
||||
Region: configMap.region
|
||||
Region: configMap.region,
|
||||
})
|
||||
return res?.statusCode === 200
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class TcyunApi {
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
customUrl,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1, prefix.length)
|
||||
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
||||
@@ -119,7 +119,7 @@ class TcyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
let res = {} as COS.GetBucketResult
|
||||
do {
|
||||
@@ -127,13 +127,13 @@ class TcyunApi {
|
||||
Bucket: bucket,
|
||||
Region: region,
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
Marker: marker
|
||||
Marker: marker,
|
||||
})
|
||||
if (res?.statusCode === 200) {
|
||||
result.fullList.push(
|
||||
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
||||
this.formatFile(item, slicedPrefix, urlPrefix)
|
||||
)
|
||||
this.formatFile(item, slicedPrefix, urlPrefix),
|
||||
),
|
||||
)
|
||||
window.webContents.send(refreshDownloadFileTransferList, result)
|
||||
} else {
|
||||
@@ -157,7 +157,7 @@ class TcyunApi {
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
customUrl,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1, prefix.length)
|
||||
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
||||
@@ -174,7 +174,7 @@ class TcyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
do {
|
||||
res = await this.ctx.getBucket({
|
||||
@@ -182,14 +182,14 @@ class TcyunApi {
|
||||
Region: region,
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
Delimiter: '/',
|
||||
Marker: marker
|
||||
Marker: marker,
|
||||
})
|
||||
if (res?.statusCode === 200) {
|
||||
result.fullList.push(
|
||||
...res.CommonPrefixes.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)),
|
||||
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
||||
this.formatFile(item, slicedPrefix, urlPrefix)
|
||||
)
|
||||
this.formatFile(item, slicedPrefix, urlPrefix),
|
||||
),
|
||||
)
|
||||
window.webContents.send('refreshFileTransferList', result)
|
||||
} else {
|
||||
@@ -228,7 +228,7 @@ class TcyunApi {
|
||||
prefix,
|
||||
customUrl,
|
||||
marker,
|
||||
itemsPerPage
|
||||
itemsPerPage,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
||||
@@ -238,26 +238,26 @@ class TcyunApi {
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
Delimiter: '/',
|
||||
Marker: marker,
|
||||
MaxKeys: itemsPerPage
|
||||
MaxKeys: itemsPerPage,
|
||||
})) as COS.GetBucketResult
|
||||
if (res?.statusCode !== 200) {
|
||||
return {
|
||||
fullList: [],
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
}
|
||||
const result = {
|
||||
fullList: [
|
||||
...res.CommonPrefixes.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)),
|
||||
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
||||
this.formatFile(item, slicedPrefix, urlPrefix)
|
||||
)
|
||||
this.formatFile(item, slicedPrefix, urlPrefix),
|
||||
),
|
||||
],
|
||||
isTruncated: res.IsTruncated === 'true',
|
||||
nextMarker: res.NextMarker || '',
|
||||
success: true
|
||||
success: true,
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -278,7 +278,7 @@ class TcyunApi {
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Key: newKey,
|
||||
CopySource: handleUrlEncode(`${bucketName}.cos.${region}.myqcloud.com/${oldKey}`)
|
||||
CopySource: handleUrlEncode(`${bucketName}.cos.${region}.myqcloud.com/${oldKey}`),
|
||||
})
|
||||
|
||||
if (copyRes?.statusCode !== 200) return false
|
||||
@@ -286,7 +286,7 @@ class TcyunApi {
|
||||
const deleteRes = await this.ctx.deleteObject({
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Key: oldKey
|
||||
Key: oldKey,
|
||||
})
|
||||
|
||||
return deleteRes?.statusCode === 204
|
||||
@@ -306,7 +306,7 @@ class TcyunApi {
|
||||
const res = await this.ctx.deleteObject({
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Key: key
|
||||
Key: key,
|
||||
})
|
||||
return res?.statusCode === 204
|
||||
}
|
||||
@@ -321,7 +321,7 @@ class TcyunApi {
|
||||
let res: any
|
||||
const allFileList = {
|
||||
CommonPrefixes: [] as any[],
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
do {
|
||||
res = await this.ctx.getBucket({
|
||||
@@ -330,7 +330,7 @@ class TcyunApi {
|
||||
Prefix: key,
|
||||
Delimiter: '/',
|
||||
MaxKeys: 1000,
|
||||
Marker: marker
|
||||
Marker: marker,
|
||||
})
|
||||
|
||||
if (res?.statusCode !== 200) return false
|
||||
@@ -344,7 +344,7 @@ class TcyunApi {
|
||||
!(await this.deleteBucketFolder({
|
||||
bucketName,
|
||||
region,
|
||||
key: item.Prefix
|
||||
key: item.Prefix,
|
||||
}))
|
||||
) {
|
||||
return false
|
||||
@@ -355,7 +355,7 @@ class TcyunApi {
|
||||
const res = await this.ctx.deleteMultipleObject({
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Objects: allFileList.Contents.slice(i * 1000, (i + 1) * 1000).map((item: any) => ({ Key: item.Key }))
|
||||
Objects: allFileList.Contents.slice(i * 1000, (i + 1) * 1000).map((item: any) => ({ Key: item.Key })),
|
||||
})
|
||||
if (res?.statusCode !== 200) return false
|
||||
}
|
||||
@@ -381,9 +381,9 @@ class TcyunApi {
|
||||
Region: region,
|
||||
Key: key,
|
||||
Expires: expires,
|
||||
Sign: true
|
||||
Sign: true,
|
||||
},
|
||||
() => {}
|
||||
() => {},
|
||||
)
|
||||
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
|
||||
}
|
||||
@@ -417,7 +417,7 @@ class TcyunApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
files.push({
|
||||
Bucket: bucketName,
|
||||
@@ -432,7 +432,7 @@ class TcyunApi {
|
||||
id,
|
||||
progress: Math.floor(progress.percent * 100),
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
})
|
||||
},
|
||||
onFileFinish: (err: any, data: any) => {
|
||||
@@ -442,27 +442,27 @@ class TcyunApi {
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
response: typeof data === 'object' ? JSON.stringify(data) : String(data),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
this.logger.error(
|
||||
formatError(err, {
|
||||
method: 'uploadBucketFile',
|
||||
class: 'TcyunApi'
|
||||
})
|
||||
class: 'TcyunApi',
|
||||
}),
|
||||
)
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: typeof err === 'object' ? JSON.stringify(err) : String(err),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
this.ctx.uploadFiles({
|
||||
files
|
||||
files,
|
||||
})
|
||||
}
|
||||
return true
|
||||
@@ -478,7 +478,7 @@ class TcyunApi {
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Key: key,
|
||||
Body: ''
|
||||
Body: '',
|
||||
})
|
||||
return res?.statusCode === 200
|
||||
}
|
||||
@@ -507,7 +507,7 @@ class TcyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: path.join(downloadPath, fileName)
|
||||
targetFilePath: path.join(downloadPath, fileName),
|
||||
})
|
||||
fs.ensureDirSync(path.dirname(path.join(downloadPath, fileName)))
|
||||
this.ctx
|
||||
@@ -522,9 +522,9 @@ class TcyunApi {
|
||||
instance.updateDownloadTask({
|
||||
id,
|
||||
progress: Math.floor(progress.percent * 100),
|
||||
status: downloadTaskSpecialStatus.downloading
|
||||
status: downloadTaskSpecialStatus.downloading,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
.then((res: any) => {
|
||||
instance.updateDownloadTask({
|
||||
@@ -532,22 +532,22 @@ class TcyunApi {
|
||||
progress: res && res.statusCode === 200 ? 100 : 0,
|
||||
status: res && res.statusCode === 200 ? downloadTaskSpecialStatus.downloaded : commonTaskStatus.failed,
|
||||
response: typeof res === 'object' ? JSON.stringify(res) : String(res),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
.catch((err: any) => {
|
||||
this.logger.error(
|
||||
formatError(err, {
|
||||
method: 'downloadBucketFile',
|
||||
class: 'TcyunApi'
|
||||
})
|
||||
class: 'TcyunApi',
|
||||
}),
|
||||
)
|
||||
instance.updateDownloadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: typeof err === 'object' ? JSON.stringify(err) : String(err),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
gotUpload,
|
||||
hmacSha1Base64,
|
||||
md5,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import { ManageLogger } from '~/manage/utils/logger'
|
||||
import { isImage } from '~/utils/common'
|
||||
@@ -40,7 +40,7 @@ class UpyunApi {
|
||||
password: string,
|
||||
logger: ManageLogger,
|
||||
antiLeechToken?: string,
|
||||
expireTime?: number
|
||||
expireTime?: number,
|
||||
) {
|
||||
this.ser = new Upyun.Service(bucket, operator, password)
|
||||
this.cli = new Upyun.Client(this.ser)
|
||||
@@ -78,7 +78,7 @@ class UpyunApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
Key: key
|
||||
Key: key,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,14 +98,14 @@ class UpyunApi {
|
||||
match: false,
|
||||
isImage: isImage(item.name),
|
||||
url,
|
||||
key
|
||||
key,
|
||||
}
|
||||
}
|
||||
|
||||
authorization(method: string, uri: string, contentMd5: string, operator: string, password: string) {
|
||||
return `UPYUN ${operator}:${hmacSha1Base64(
|
||||
md5(password, 'hex'),
|
||||
`${method.toUpperCase()}&${encodeURI(uri)}&${new Date().toUTCString()}${contentMd5 ? `&${contentMd5}` : ''}`
|
||||
`${method.toUpperCase()}&${encodeURI(uri)}&${new Date().toUTCString()}${contentMd5 ? `&${contentMd5}` : ''}`,
|
||||
)}`
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class UpyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const folderQueue = [prefix]
|
||||
const getFolderFile = async (folder: any) => {
|
||||
@@ -141,7 +141,7 @@ class UpyunApi {
|
||||
do {
|
||||
res = await this.cli.listDir(key, {
|
||||
limit: 10000,
|
||||
iter: marker
|
||||
iter: marker,
|
||||
})
|
||||
if (res) {
|
||||
res.files?.forEach((item: any) => {
|
||||
@@ -185,12 +185,12 @@ class UpyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
do {
|
||||
res = await this.cli.listDir(prefix, {
|
||||
limit: 10000,
|
||||
iter: marker
|
||||
iter: marker,
|
||||
})
|
||||
if (res) {
|
||||
res.files?.forEach((item: any) => {
|
||||
@@ -236,11 +236,11 @@ class UpyunApi {
|
||||
fullList: [] as any,
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
res = await this.cli.listDir(prefix, {
|
||||
limit: itemsPerPage,
|
||||
iter: marker || ''
|
||||
iter: marker || '',
|
||||
})
|
||||
if (res) {
|
||||
res.files?.forEach((item: any) => {
|
||||
@@ -278,12 +278,12 @@ class UpyunApi {
|
||||
Authorization: authorization,
|
||||
'X-Upyun-Move-Source': xUpyunMoveSource,
|
||||
'Content-Length': 0,
|
||||
Date: new Date().toUTCString()
|
||||
Date: new Date().toUTCString(),
|
||||
}
|
||||
const res = await axios({
|
||||
method,
|
||||
url: `http://v0.api.upyun.com${uri}`,
|
||||
headers
|
||||
headers,
|
||||
})
|
||||
return res.status === 200
|
||||
}
|
||||
@@ -313,24 +313,24 @@ class UpyunApi {
|
||||
let isTruncated
|
||||
const allFileList = {
|
||||
CommonPrefixes: [] as any[],
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
do {
|
||||
const res = await this.cli.listDir(key, {
|
||||
limit: 10000,
|
||||
iter: marker
|
||||
iter: marker,
|
||||
})
|
||||
if (res) {
|
||||
res.files.forEach((item: any) => {
|
||||
item.type === 'N' &&
|
||||
allFileList.Contents.push({
|
||||
...item,
|
||||
key: `${key}${item.name}`
|
||||
key: `${key}${item.name}`,
|
||||
})
|
||||
item.type === 'F' &&
|
||||
allFileList.CommonPrefixes.push({
|
||||
...item,
|
||||
key: `${key}${item.name}/`
|
||||
key: `${key}${item.name}/`,
|
||||
})
|
||||
})
|
||||
marker = res.next
|
||||
@@ -351,7 +351,7 @@ class UpyunApi {
|
||||
if (allFileList.CommonPrefixes.length > 0) {
|
||||
for (const item of allFileList.CommonPrefixes) {
|
||||
const res = await this.deleteBucketFolder({
|
||||
key: item.key
|
||||
key: item.key,
|
||||
})
|
||||
if (!res) {
|
||||
return false
|
||||
@@ -390,7 +390,7 @@ class UpyunApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
const date = new Date().toUTCString()
|
||||
const uri = `/${key}`
|
||||
@@ -400,7 +400,7 @@ class UpyunApi {
|
||||
'save-key': uri,
|
||||
expiration: Math.floor(Date.now() / 1000) + 2592000,
|
||||
date,
|
||||
'content-length': fileSize
|
||||
'content-length': fileSize,
|
||||
}
|
||||
const base64Policy = Buffer.from(JSON.stringify(uplpadPolicy)).toString('base64')
|
||||
const stringToSign = `${method}&/${bucketName}&${date}&${base64Policy}`
|
||||
@@ -411,7 +411,7 @@ class UpyunApi {
|
||||
form.append('authorization', authorization)
|
||||
form.append('file', fs.createReadStream(filePath), {
|
||||
filename: path.basename(key),
|
||||
contentType: getFileMimeType(fileName)
|
||||
contentType: getFileMimeType(fileName),
|
||||
})
|
||||
const headers = form.getHeaders()
|
||||
headers.Host = 'v0.api.upyun.com'
|
||||
@@ -452,7 +452,7 @@ class UpyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
const preSignedUrl = `${customUrl}/${key}`
|
||||
promises.push(
|
||||
@@ -465,7 +465,7 @@ class UpyunApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -35,7 +35,7 @@ class WebdavplistApi {
|
||||
sslEnabled: boolean,
|
||||
proxy: string | undefined,
|
||||
authType: 'basic' | 'digest' | undefined,
|
||||
logger: ManageLogger
|
||||
logger: ManageLogger,
|
||||
) {
|
||||
this.endpoint = formatEndpoint(endpoint, sslEnabled)
|
||||
this.username = username
|
||||
@@ -52,7 +52,7 @@ class WebdavplistApi {
|
||||
maxBodyLength: 4 * 1024 * 1024 * 1024,
|
||||
maxContentLength: 4 * 1024 * 1024 * 1024,
|
||||
httpsAgent: sslEnabled ? this.agent : undefined,
|
||||
httpAgent: !sslEnabled ? this.agent : undefined
|
||||
httpAgent: !sslEnabled ? this.agent : undefined,
|
||||
}
|
||||
if (this.authType === 'digest') {
|
||||
options.authType = AuthType.Digest
|
||||
@@ -75,7 +75,7 @@ class WebdavplistApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class WebdavplistApi {
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(item.basename),
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,12 +113,12 @@ class WebdavplistApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
res = await this.ctx.getDirectoryContents(prefix, {
|
||||
deep: true,
|
||||
details: true
|
||||
details: true,
|
||||
})
|
||||
if (this.isRequestSuccess(res.status)) {
|
||||
if (res.data?.length) {
|
||||
@@ -158,12 +158,12 @@ class WebdavplistApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
res = await this.ctx.getDirectoryContents(prefix, {
|
||||
deep: false,
|
||||
details: true
|
||||
details: true,
|
||||
})
|
||||
if (this.isRequestSuccess(res.status)) {
|
||||
if (res.data?.length) {
|
||||
@@ -263,7 +263,7 @@ class WebdavplistApi {
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region,
|
||||
noProgress: true
|
||||
noProgress: true,
|
||||
})
|
||||
this.ctx
|
||||
.putFileContents(key, this.authType === 'digest' ? fs.readFileSync(filePath) : fs.createReadStream(filePath), {
|
||||
@@ -272,9 +272,9 @@ class WebdavplistApi {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: Math.floor((progressEvent.loaded / progressEvent.total) * 100),
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
.then((res: boolean) => {
|
||||
if (res) {
|
||||
@@ -282,14 +282,14 @@ class WebdavplistApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -299,7 +299,7 @@ class WebdavplistApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -311,7 +311,7 @@ class WebdavplistApi {
|
||||
let result = false
|
||||
try {
|
||||
await this.ctx.createDirectory(key, {
|
||||
recursive: true
|
||||
recursive: true,
|
||||
})
|
||||
result = true
|
||||
} catch (error) {
|
||||
@@ -336,16 +336,16 @@ class WebdavplistApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
let preSignedUrl = await this.getPreSignedUrl({
|
||||
key
|
||||
key,
|
||||
})
|
||||
let headers = {} as IStringKeyMap
|
||||
if (this.authType === 'basic' || !this.authType) {
|
||||
const base64Str = Buffer.from(`${this.username}:${this.password}`).toString('base64')
|
||||
headers = {
|
||||
Authorization: `Basic ${base64Str}`
|
||||
Authorization: `Basic ${base64Str}`,
|
||||
}
|
||||
} else if (this.authType === 'digest') {
|
||||
const authHeader = await getAuthHeader(
|
||||
@@ -353,10 +353,10 @@ class WebdavplistApi {
|
||||
this.endpoint,
|
||||
`/${key.replace(/^\/+/, '')}`,
|
||||
this.username,
|
||||
this.password
|
||||
this.password,
|
||||
)
|
||||
headers = {
|
||||
Authorization: authHeader
|
||||
Authorization: authHeader,
|
||||
}
|
||||
preSignedUrl = `${this.endpoint}/${key.replace(/^\/+/, '')}`
|
||||
}
|
||||
@@ -370,9 +370,9 @@ class WebdavplistApi {
|
||||
} else {
|
||||
reject(res)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -14,7 +14,7 @@ class ManageDB {
|
||||
this.#db = new JSONStore(this.#ctx.configPath)
|
||||
const initParams: IStringKeyMap = {
|
||||
picBed: {},
|
||||
settings: {}
|
||||
settings: {},
|
||||
}
|
||||
for (const key in initParams) {
|
||||
if (!this.#db.has(key)) {
|
||||
|
||||
@@ -18,7 +18,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 manageDbChecker() {
|
||||
@@ -30,30 +30,30 @@ function manageDbChecker() {
|
||||
let configFile: string = '{}'
|
||||
const optionsTpl = {
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: ''
|
||||
body: '',
|
||||
}
|
||||
// config save bak
|
||||
try {
|
||||
configFile = fs.readFileSync(manageConfigFilePath, { encoding: 'utf-8' })
|
||||
JSON.parse(configFile)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
fs.unlinkSync(manageConfigFilePath)
|
||||
if (fs.existsSync(manageConfigFileBackupPath)) {
|
||||
try {
|
||||
configFile = fs.readFileSync(manageConfigFileBackupPath, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
JSON.parse(configFile)
|
||||
writeFile.sync(manageConfigFilePath, configFile, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
const stats = fs.statSync(manageConfigFileBackupPath)
|
||||
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
|
||||
@@ -64,7 +64,7 @@ function manageDbChecker() {
|
||||
return
|
||||
}
|
||||
writeFile.sync(manageConfigFileBackupPath, configFile, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ function managePathChecker(): string {
|
||||
}
|
||||
try {
|
||||
const configString = fs.readFileSync(defaultManageConfigPath, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
const config = JSON.parse(configString)
|
||||
const userConfigPath: string = config.configPath || ''
|
||||
@@ -102,7 +102,7 @@ function managePathChecker(): 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
|
||||
|
||||
@@ -108,7 +108,7 @@ class UpDownTaskQueue {
|
||||
item =>
|
||||
item.status !== uploadTaskSpecialStatus.uploaded &&
|
||||
item.status !== commonTaskStatus.canceled &&
|
||||
item.status !== commonTaskStatus.failed
|
||||
item.status !== commonTaskStatus.failed,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class UpDownTaskQueue {
|
||||
item =>
|
||||
item.status !== downloadTaskSpecialStatus.downloaded &&
|
||||
item.status !== commonTaskStatus.canceled &&
|
||||
item.status !== commonTaskStatus.failed
|
||||
item.status !== commonTaskStatus.failed,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ class UpDownTaskQueue {
|
||||
this.persistPath,
|
||||
JSON.stringify({
|
||||
uploadTaskQueue: this.uploadTaskQueue,
|
||||
downloadTaskQueue: this.downloadTaskQueue
|
||||
})
|
||||
downloadTaskQueue: this.downloadTaskQueue,
|
||||
}),
|
||||
)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -151,7 +151,7 @@ class UpDownTaskQueue {
|
||||
const persistData = JSON.parse(fs.readFileSync(this.persistPath, { encoding: 'utf-8' }))
|
||||
this.uploadTaskQueue = persistData.uploadTaskQueue
|
||||
this.downloadTaskQueue = persistData.downloadTaskQueue
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
this.uploadTaskQueue = []
|
||||
this.downloadTaskQueue = []
|
||||
}
|
||||
@@ -163,19 +163,19 @@ class UpDownTaskQueue {
|
||||
this.persistPath,
|
||||
JSON.stringify({
|
||||
uploadTaskQueue: this.uploadTaskQueue,
|
||||
downloadTaskQueue: this.downloadTaskQueue
|
||||
})
|
||||
downloadTaskQueue: this.downloadTaskQueue,
|
||||
}),
|
||||
)
|
||||
}
|
||||
try {
|
||||
JSON.parse(fs.readFileSync(this.persistPath, { encoding: 'utf-8' }))
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
fs.writeFileSync(
|
||||
this.persistPath,
|
||||
JSON.stringify({
|
||||
uploadTaskQueue: this.uploadTaskQueue,
|
||||
downloadTaskQueue: this.downloadTaskQueue
|
||||
})
|
||||
downloadTaskQueue: this.downloadTaskQueue,
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
's3plist',
|
||||
'webdavplist',
|
||||
'local',
|
||||
'sftp'
|
||||
'sftp',
|
||||
]
|
||||
|
||||
private readonly CLOUD_STORAGE_CLIENTS = ['tcyun', 'aliyun', 'qiniu', 's3plist']
|
||||
@@ -51,7 +51,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
's3plist',
|
||||
'webdavplist',
|
||||
'local',
|
||||
'sftp'
|
||||
'sftp',
|
||||
]
|
||||
|
||||
private readonly FILE_LIST_CLIENTS = ['tcyun', 'aliyun', 'qiniu', 'upyun', 'smms', 's3plist']
|
||||
@@ -70,7 +70,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
return {
|
||||
class: 'ManageApi',
|
||||
method,
|
||||
picbedName: this.currentPicBedConfig.picBedName
|
||||
picbedName: this.currentPicBedConfig.picBedName,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,14 +86,14 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.token,
|
||||
this.currentPicBedConfig.githubUsername,
|
||||
this.currentPicBedConfig.proxy,
|
||||
this.logger
|
||||
this.logger,
|
||||
),
|
||||
imgur: () =>
|
||||
new API.ImgurApi(
|
||||
this.currentPicBedConfig.imgurUserName,
|
||||
this.currentPicBedConfig.accessToken,
|
||||
this.currentPicBedConfig.proxy,
|
||||
this.logger
|
||||
this.logger,
|
||||
),
|
||||
local: () => new API.LocalApi(this.logger),
|
||||
qiniu: () => new API.QiniuApi(this.currentPicBedConfig.accessKey, this.currentPicBedConfig.secretKey, this.logger),
|
||||
@@ -108,7 +108,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.proxy,
|
||||
this.logger,
|
||||
this.currentPicBedConfig.dogeCloudSupport || false,
|
||||
this.currentPicBedConfig.bucketName || ''
|
||||
this.currentPicBedConfig.bucketName || '',
|
||||
),
|
||||
sftp: () =>
|
||||
new API.SftpApi(
|
||||
@@ -120,7 +120,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.passphrase,
|
||||
this.currentPicBedConfig.fileMode,
|
||||
this.currentPicBedConfig.dirMode,
|
||||
this.logger
|
||||
this.logger,
|
||||
),
|
||||
tcyun: () => new API.TcyunApi(this.currentPicBedConfig.secretId, this.currentPicBedConfig.secretKey, this.logger),
|
||||
upyun: () =>
|
||||
@@ -130,7 +130,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.password,
|
||||
this.logger,
|
||||
this.currentPicBedConfig.antiLeechToken,
|
||||
this.currentPicBedConfig.expireTime
|
||||
this.currentPicBedConfig.expireTime,
|
||||
),
|
||||
webdavplist: () =>
|
||||
new API.WebdavplistApi(
|
||||
@@ -140,8 +140,8 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.sslEnabled,
|
||||
this.currentPicBedConfig.proxy,
|
||||
this.currentPicBedConfig.authType,
|
||||
this.logger
|
||||
)
|
||||
this.logger,
|
||||
),
|
||||
}
|
||||
|
||||
createClient() {
|
||||
@@ -153,7 +153,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
supportedProviders: string[],
|
||||
method: string,
|
||||
operation: (client: any) => Promise<T>,
|
||||
defaultValue: T
|
||||
defaultValue: T,
|
||||
): Promise<T> {
|
||||
if (!supportedProviders.includes(this.currentPicBedConfig.picBedName)) {
|
||||
return defaultValue
|
||||
@@ -171,7 +171,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(eventName, defaultResult)
|
||||
ipcMain.removeAllListeners(
|
||||
eventName === refreshDownloadFileTransferList ? cancelDownloadLoadingFileList : 'cancelLoadingFileList'
|
||||
eventName === refreshDownloadFileTransferList ? cancelDownloadLoadingFileList : 'cancelLoadingFileList',
|
||||
)
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
smms: [{ Name: 'smms', Location: 'smms', CreationDate: new Date().toISOString() }],
|
||||
webdavplist: [{ Name: 'webdav', Location: 'webdav', CreationDate: new Date().toISOString() }],
|
||||
local: [{ Name: 'local', Location: 'local', CreationDate: new Date().toISOString() }],
|
||||
sftp: [{ Name: 'sftp', Location: 'sftp', CreationDate: new Date().toISOString() }]
|
||||
sftp: [{ Name: 'sftp', Location: 'sftp', CreationDate: new Date().toISOString() }],
|
||||
}
|
||||
|
||||
const staticResult = staticBuckets[this.currentPicBedConfig.picBedName as keyof typeof staticBuckets]
|
||||
@@ -262,7 +262,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
const staticDomains = {
|
||||
upyun: [this.currentPicBedConfig.customUrl],
|
||||
smms: ['https://smms.app'],
|
||||
imgur: ['https://imgur.com']
|
||||
imgur: ['https://imgur.com'],
|
||||
}
|
||||
|
||||
const staticResult = staticDomains[this.currentPicBedConfig.picBedName as keyof typeof staticDomains]
|
||||
@@ -277,7 +277,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.CLOUD_STORAGE_CLIENTS,
|
||||
'createBucket',
|
||||
client => client.createBucket(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -314,9 +314,9 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'getBucketListRecursively',
|
||||
client => client.getBucketListRecursively(param!),
|
||||
defaultResult
|
||||
defaultResult,
|
||||
)
|
||||
} catch (error: any) {
|
||||
} catch (_e: any) {
|
||||
this.sendDefaultResult(refreshDownloadFileTransferList, defaultResult)
|
||||
return {}
|
||||
}
|
||||
@@ -335,9 +335,9 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'getBucketListBackstage',
|
||||
client => client.getBucketListBackstage(param!),
|
||||
defaultResult
|
||||
defaultResult,
|
||||
)
|
||||
} catch (error: any) {
|
||||
} catch (_error: any) {
|
||||
this.sendDefaultResult('refreshFileTransferList', defaultResult)
|
||||
return {}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.FILE_LIST_CLIENTS,
|
||||
'getBucketFileList',
|
||||
client => client.getBucketFileList(param!),
|
||||
defaultResponse
|
||||
defaultResponse,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'deleteBucketFile',
|
||||
client => client.deleteBucketFile(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.FOLDER_SUPPORT_CLIENTS,
|
||||
'deleteBucketFolder',
|
||||
client => client.deleteBucketFolder(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
supportedClients,
|
||||
'renameBucketFile',
|
||||
client => client.renameBucketFile(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'downloadBucketFile',
|
||||
client => client.downloadBucketFile(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.FOLDER_SUPPORT_CLIENTS,
|
||||
'createBucketFolder',
|
||||
client => client.createBucketFolder(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'uploadBucketFile',
|
||||
client => client.uploadBucketFile(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
supportedClients,
|
||||
'getPreSignedUrl',
|
||||
client => client.getPreSignedUrl(param!),
|
||||
'error'
|
||||
'error',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ export const getFSFile = async (filePath: string, stream: boolean = false): Prom
|
||||
extension: path.extname(filePath),
|
||||
fileName: path.basename(filePath),
|
||||
buffer: stream ? fs.createReadStream(filePath) : await fs.readFile(filePath),
|
||||
success: true
|
||||
success: true,
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
return {
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ const getTempDirPath = () => {
|
||||
const checkTempFolderExist = async (tempPath: string) => {
|
||||
try {
|
||||
await fs.access(tempPath)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
await fs.mkdir(tempPath)
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ export const downloadFileFromUrl = async (urls: string[]) => {
|
||||
const res = await axios({
|
||||
method: 'get',
|
||||
url,
|
||||
responseType: 'stream'
|
||||
responseType: 'stream',
|
||||
})
|
||||
res.data.pipe(writer)
|
||||
await finishDownload(writer)
|
||||
@@ -87,7 +87,7 @@ export const NewDownloader = async (
|
||||
savedFilePath: string,
|
||||
logger?: ManageLogger,
|
||||
proxy?: string,
|
||||
headers?: any
|
||||
headers?: any,
|
||||
): Promise<boolean> => {
|
||||
const options = {
|
||||
url: encodeURI(preSignedUrl),
|
||||
@@ -98,10 +98,10 @@ export const NewDownloader = async (
|
||||
instance.updateDownloadTask({
|
||||
id,
|
||||
progress: Math.floor(Number(percentage)),
|
||||
status: downloadTaskSpecialStatus.downloading
|
||||
status: downloadTaskSpecialStatus.downloading,
|
||||
})
|
||||
},
|
||||
maxAttempts: 3
|
||||
maxAttempts: 3,
|
||||
} as any
|
||||
if (proxy) {
|
||||
options.proxy = proxy
|
||||
@@ -116,7 +116,7 @@ export const NewDownloader = async (
|
||||
id,
|
||||
progress: 100,
|
||||
status: downloadTaskSpecialStatus.downloaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
return true
|
||||
} catch (e: any) {
|
||||
@@ -127,7 +127,7 @@ export const NewDownloader = async (
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: formatError(e, { method: 'NewDownloader' }),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
return false
|
||||
}
|
||||
@@ -143,23 +143,23 @@ export const gotUpload = async (
|
||||
logger?: ManageLogger,
|
||||
timeout: number = 30000,
|
||||
throwHttpErrors: boolean = false,
|
||||
agent: any = {}
|
||||
agent: any = {},
|
||||
) => {
|
||||
got(url, {
|
||||
headers,
|
||||
method,
|
||||
body,
|
||||
timeout: {
|
||||
lookup: timeout
|
||||
lookup: timeout,
|
||||
},
|
||||
throwHttpErrors,
|
||||
agent
|
||||
agent,
|
||||
})
|
||||
.on('uploadProgress', (progress: any) => {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: Math.floor(progress.percent * 100),
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
})
|
||||
.then((res: any) => {
|
||||
@@ -170,7 +170,7 @@ export const gotUpload = async (
|
||||
res?.statusCode === 200 || res?.statusCode === 201
|
||||
? uploadTaskSpecialStatus.uploaded
|
||||
: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
.catch((err: any) => {
|
||||
@@ -180,7 +180,7 @@ export const gotUpload = async (
|
||||
progress: 0,
|
||||
response: formatError(err, { method: 'gotUpload' }),
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -193,14 +193,14 @@ export const formatError = (err: any, params: IStringKeyMap) => {
|
||||
name: 'RequestError',
|
||||
code: err.code,
|
||||
stack: err.stack ?? '',
|
||||
timings: err.timings ?? {}
|
||||
timings: err.timings ?? {},
|
||||
}
|
||||
} else if (err instanceof Error) {
|
||||
return {
|
||||
...params,
|
||||
name: err.name ?? '',
|
||||
message: err.message ?? '',
|
||||
stack: err.stack ?? ''
|
||||
stack: err.stack ?? '',
|
||||
}
|
||||
}
|
||||
if (typeof err === 'object') {
|
||||
@@ -212,12 +212,12 @@ export const formatError = (err: any, params: IStringKeyMap) => {
|
||||
const commonOptions = {
|
||||
keepAlive: true,
|
||||
keepAliveMsecs: 1000,
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
|
||||
} as any
|
||||
|
||||
export const getAgent = (
|
||||
proxy: any,
|
||||
https: boolean = true
|
||||
https: boolean = true,
|
||||
): {
|
||||
https?: HttpsProxyAgent
|
||||
http?: HttpProxyAgent
|
||||
@@ -225,7 +225,7 @@ export const getAgent = (
|
||||
const formatProxy = formatHttpProxy(proxy, 'string') as any
|
||||
const commonResult = {
|
||||
https: undefined,
|
||||
http: undefined
|
||||
http: undefined,
|
||||
}
|
||||
if (!formatProxy) return commonResult
|
||||
commonOptions.proxy = formatProxy.replace('127.0.0.1', 'localhost')
|
||||
@@ -233,16 +233,16 @@ export const getAgent = (
|
||||
return {
|
||||
https: new HttpsProxyAgent({
|
||||
...commonOptions,
|
||||
rejectUnauthorized: false
|
||||
rejectUnauthorized: false,
|
||||
}),
|
||||
http: undefined
|
||||
http: undefined,
|
||||
}
|
||||
}
|
||||
return {
|
||||
http: new HttpProxyAgent({
|
||||
...commonOptions
|
||||
...commonOptions,
|
||||
}),
|
||||
https: undefined
|
||||
https: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,14 +255,14 @@ export const getInnerAgent = (proxy: any, sslEnabled: boolean = true) => {
|
||||
...commonOptions,
|
||||
rejectUnauthorized: false,
|
||||
host: formatProxy.host,
|
||||
port: formatProxy.port
|
||||
})
|
||||
port: formatProxy.port,
|
||||
}),
|
||||
}
|
||||
: {
|
||||
agent: new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
keepAlive: true
|
||||
})
|
||||
keepAlive: true,
|
||||
}),
|
||||
}
|
||||
}
|
||||
return formatProxy
|
||||
@@ -270,13 +270,13 @@ export const getInnerAgent = (proxy: any, sslEnabled: boolean = true) => {
|
||||
agent: new http.Agent({
|
||||
...commonOptions,
|
||||
host: formatProxy.host,
|
||||
port: formatProxy.port
|
||||
})
|
||||
port: formatProxy.port,
|
||||
}),
|
||||
}
|
||||
: {
|
||||
agent: new http.Agent({
|
||||
...commonOptions
|
||||
})
|
||||
...commonOptions,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ export function getOptions(
|
||||
responseType?: string,
|
||||
body?: any,
|
||||
timeout?: number,
|
||||
proxy?: any
|
||||
proxy?: any,
|
||||
): OptionsOfTextResponseBody {
|
||||
return {
|
||||
...(method && { method: method.toUpperCase() }),
|
||||
@@ -297,9 +297,9 @@ export function getOptions(
|
||||
...(responseType && { responseType }),
|
||||
...(timeout !== undefined ? { timeout: { request: timeout } } : { timeout: { request: 30000 } }),
|
||||
...(proxy && {
|
||||
agent: Object.fromEntries(Object.entries(getAgent(proxy)).filter(([, v]) => v !== undefined))
|
||||
agent: Object.fromEntries(Object.entries(getAgent(proxy)).filter(([, v]) => v !== undefined)),
|
||||
}),
|
||||
throwHttpErrors: false
|
||||
throwHttpErrors: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function dogecloudApi(
|
||||
data = {},
|
||||
jsonMode: boolean = false,
|
||||
accessKey: string,
|
||||
secretKey: string
|
||||
secretKey: string,
|
||||
) {
|
||||
const body = jsonMode ? JSON.stringify(data) : querystring.encode(data)
|
||||
const sign = crypto
|
||||
@@ -33,14 +33,14 @@ export async function dogecloudApi(
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Content-Type': jsonMode ? 'application/json' : 'application/x-www-form-urlencoded',
|
||||
Authorization: authorization
|
||||
}
|
||||
Authorization: authorization,
|
||||
},
|
||||
})
|
||||
if (res.data.code !== 200) {
|
||||
throw new Error('API Error')
|
||||
}
|
||||
return res.data.data
|
||||
} catch (err: any) {
|
||||
} catch (_e: any) {
|
||||
throw new Error('API Error')
|
||||
}
|
||||
}
|
||||
@@ -55,23 +55,23 @@ export async function getTempToken(accessKey: string, secretKey: string): Promis
|
||||
'/auth/tmp_token.json',
|
||||
{
|
||||
channel: 'OSS_FULL',
|
||||
scopes: ['*']
|
||||
scopes: ['*'],
|
||||
},
|
||||
true,
|
||||
accessKey,
|
||||
secretKey
|
||||
secretKey,
|
||||
)
|
||||
const token = data.Credentials
|
||||
picgo.saveConfig({
|
||||
Credentials: {
|
||||
'doge-token': {
|
||||
token,
|
||||
expires: data.ExpiredAt * 1000
|
||||
}
|
||||
}
|
||||
expires: data.ExpiredAt * 1000,
|
||||
},
|
||||
},
|
||||
})
|
||||
return token
|
||||
} catch (err: any) {
|
||||
} catch (_e: any) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ManageLogger implements ILogger {
|
||||
[ILogType.success]: 'green',
|
||||
[ILogType.info]: 'blue',
|
||||
[ILogType.warn]: 'yellow',
|
||||
[ILogType.error]: 'red'
|
||||
[ILogType.error]: 'red',
|
||||
}
|
||||
|
||||
readonly #ctx: IManageApiType
|
||||
@@ -67,12 +67,12 @@ export class ManageLogger implements ILogger {
|
||||
return {
|
||||
isLarge: logFileSize > logFileSizeLimit,
|
||||
logFileSize,
|
||||
logFileSizeLimit
|
||||
logFileSizeLimit,
|
||||
}
|
||||
}
|
||||
fs.ensureFileSync(logPath)
|
||||
return {
|
||||
isLarge: false
|
||||
isLarge: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,20 +21,20 @@ const serverTempDir = path.join(appPath, 'serverTemp')
|
||||
fs.ensureDirSync(serverTempDir)
|
||||
|
||||
const multerStorage = multer.diskStorage({
|
||||
destination: function (_req: any, _file: any, cb: (arg0: null, arg1: any) => void) {
|
||||
destination(_req: any, _file: any, cb: (arg0: null, arg1: any) => void) {
|
||||
fs.ensureDirSync(serverTempDir)
|
||||
cb(null, serverTempDir)
|
||||
},
|
||||
filename: function (_req: any, file: { originalname: any }, cb: (arg0: null, arg1: any) => void) {
|
||||
filename(_req: any, file: { originalname: any }, cb: (arg0: null, arg1: any) => void) {
|
||||
if (!/[^\u0000-\u00ff]/.test(file.originalname)) {
|
||||
file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8')
|
||||
}
|
||||
cb(null, file.originalname)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const uploadMulter = multer({
|
||||
storage: multerStorage
|
||||
storage: multerStorage,
|
||||
})
|
||||
|
||||
class Server {
|
||||
@@ -85,8 +85,8 @@ class Server {
|
||||
response,
|
||||
statusCode: 404,
|
||||
body: {
|
||||
success: false
|
||||
}
|
||||
success: false,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
const remoteAddress = request.socket.remoteAddress || 'unknown'
|
||||
@@ -109,8 +109,8 @@ class Server {
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'Error processing formData'
|
||||
}
|
||||
message: 'Error processing formData',
|
||||
},
|
||||
})
|
||||
}
|
||||
// @ts-expect-error since the multer type is not correct
|
||||
@@ -121,7 +121,7 @@ class Server {
|
||||
handler({
|
||||
list,
|
||||
response,
|
||||
urlparams: urlSP
|
||||
urlparams: urlSP,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -140,8 +140,8 @@ class Server {
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'Not sending data in JSON format'
|
||||
}
|
||||
message: 'Not sending data in JSON format',
|
||||
},
|
||||
})
|
||||
}
|
||||
logger.info('[PicList Server] get the request', body)
|
||||
@@ -149,7 +149,7 @@ class Server {
|
||||
handler!({
|
||||
...postObj,
|
||||
response,
|
||||
urlparams: urlSP
|
||||
urlparams: urlSP,
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class Server {
|
||||
if (handler) {
|
||||
handler({
|
||||
response,
|
||||
urlparams: query ? new URLSearchParams(query) : undefined
|
||||
urlparams: query ? new URLSearchParams(query) : undefined,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class Server {
|
||||
await axios.post(ensureHTTPLink(`${this.#config.host}:${port}/heartbeat`))
|
||||
logger.info(`[PicList Server] server is already running at ${port}`)
|
||||
this.shutdown(true)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
logger.warn(`[PicList Server] ${port} is busy, trying with port ${(port as number) + 1}`)
|
||||
// fix a bug: not write an increase number to config file
|
||||
// to solve the auto number problem
|
||||
|
||||
@@ -42,7 +42,7 @@ router.post(
|
||||
async ({
|
||||
response,
|
||||
list = [],
|
||||
urlparams
|
||||
urlparams,
|
||||
}: {
|
||||
response: IHttpResponse
|
||||
list?: string[]
|
||||
@@ -58,8 +58,8 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'server key is uncorrect'
|
||||
}
|
||||
message: 'server key is uncorrect',
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -99,7 +99,7 @@ router.post(
|
||||
const treatedFullResult = {
|
||||
isEncrypted: 1,
|
||||
EncryptedData: new AESHelper().encrypt(JSON.stringify(fullResult)),
|
||||
...fullResult
|
||||
...fullResult,
|
||||
}
|
||||
delete treatedFullResult.config
|
||||
handleResponse({
|
||||
@@ -107,16 +107,16 @@ router.post(
|
||||
body: {
|
||||
success: true,
|
||||
result: [res],
|
||||
fullResult: [treatedFullResult]
|
||||
}
|
||||
fullResult: [treatedFullResult],
|
||||
},
|
||||
})
|
||||
} else {
|
||||
handleResponse({
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: errorMessage
|
||||
}
|
||||
message: errorMessage,
|
||||
},
|
||||
})
|
||||
}
|
||||
} else {
|
||||
@@ -124,7 +124,7 @@ router.post(
|
||||
// upload with files
|
||||
const pathList = list.map(item => {
|
||||
return {
|
||||
path: item
|
||||
path: item,
|
||||
}
|
||||
})
|
||||
const win = windowManager.getAvailableWindow()
|
||||
@@ -136,7 +136,7 @@ router.post(
|
||||
const treatedItem = {
|
||||
isEncrypted: 1,
|
||||
EncryptedData: new AESHelper().encrypt(JSON.stringify(item.fullResult)),
|
||||
...item.fullResult
|
||||
...item.fullResult,
|
||||
}
|
||||
delete treatedItem.config
|
||||
treatedItem.imgUrl = useShortUrl ? treatedItem.shortUrl || treatedItem.imgUrl : treatedItem.imgUrl
|
||||
@@ -149,16 +149,16 @@ router.post(
|
||||
body: {
|
||||
success: true,
|
||||
result: res,
|
||||
fullResult
|
||||
}
|
||||
fullResult,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
handleResponse({
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: errorMessage
|
||||
}
|
||||
message: errorMessage,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -172,11 +172,11 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: errorMessage
|
||||
}
|
||||
message: errorMessage,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
router.post(
|
||||
@@ -187,8 +187,8 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'no file to delete'
|
||||
}
|
||||
message: 'no file to delete',
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -205,8 +205,8 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: !!successCount,
|
||||
message: successCount ? `delete success: ${successCount}, fail: ${failCount}` : deleteErrorMessage
|
||||
}
|
||||
message: successCount ? `delete success: ${successCount}, fail: ${failCount}` : deleteErrorMessage,
|
||||
},
|
||||
})
|
||||
} catch (err: any) {
|
||||
logger.error(err)
|
||||
@@ -214,11 +214,11 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: deleteErrorMessage
|
||||
}
|
||||
message: deleteErrorMessage,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
router.any('/heartbeat', async ({ response }: { response: IHttpResponse }) => {
|
||||
@@ -226,8 +226,8 @@ router.any('/heartbeat', async ({ response }: { response: IHttpResponse }) => {
|
||||
response,
|
||||
body: {
|
||||
success: true,
|
||||
result: 'alive'
|
||||
}
|
||||
result: 'alive',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ export const handleResponse = ({
|
||||
'Content-Type': 'application/json',
|
||||
'access-control-allow-headers': '*',
|
||||
'access-control-allow-methods': 'POST, GET, OPTIONS',
|
||||
'access-control-allow-origin': '*'
|
||||
'access-control-allow-origin': '*',
|
||||
},
|
||||
body = {
|
||||
success: false
|
||||
}
|
||||
success: false,
|
||||
},
|
||||
}: {
|
||||
response: IHttpResponse
|
||||
statusCode?: number
|
||||
@@ -55,7 +55,7 @@ export const deleteChoosedFiles = async (list: ImgInfo[]): Promise<boolean[]> =>
|
||||
const noteFunc = (value: boolean) => {
|
||||
const notification = new Notification({
|
||||
title: $t('MANAGE_BUCKET_BATCH_DELETE_ERROR_MSG_MSG2'),
|
||||
body: $t(value ? 'GALLERY_SYNC_DELETE_NOTICE_SUCCEED' : 'GALLERY_SYNC_DELETE_NOTICE_FAILED')
|
||||
body: $t(value ? 'GALLERY_SYNC_DELETE_NOTICE_SUCCEED' : 'GALLERY_SYNC_DELETE_NOTICE_FAILED'),
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export const deleteChoosedFiles = async (list: ImgInfo[]): Promise<boolean[]> =>
|
||||
picgo.emit(ICOREBuildInEvent.REMOVE, [file], GuiApi.getInstance())
|
||||
}, 500)
|
||||
result.push(true)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
result.push(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,13 +383,13 @@ function generateDirectoryListingHtml(files: any[], requestPath: string, fullPat
|
||||
? new Date(fileInfo.mtime).toLocaleDateString('en-US', {
|
||||
year: '2-digit',
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
day: 'numeric',
|
||||
}) +
|
||||
' ' +
|
||||
new Date(fileInfo.mtime).toLocaleTimeString('en-US', {
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
hour12: true
|
||||
hour12: true,
|
||||
})
|
||||
: ''
|
||||
|
||||
@@ -454,7 +454,7 @@ function sortFiles(files: string[], fullPath: string): any[] {
|
||||
let stats
|
||||
try {
|
||||
stats = fs.statSync(filePath)
|
||||
} catch (err) {
|
||||
} catch (_e) {
|
||||
stats = null
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ function sortFiles(files: string[], fullPath: string): any[] {
|
||||
name: file,
|
||||
isDirectory: stats ? stats.isDirectory() : false,
|
||||
size: stats ? stats.size : 0,
|
||||
mtime: stats ? stats.mtime : null
|
||||
mtime: stats ? stats.mtime : null,
|
||||
}
|
||||
})
|
||||
.sort((a, b) => {
|
||||
@@ -474,25 +474,25 @@ function sortFiles(files: string[], fullPath: string): any[] {
|
||||
})
|
||||
}
|
||||
|
||||
function generateErrorPage(errorCode: number, errorMessage: string): string {
|
||||
const errorDescriptions: { [key: number]: { title: string; description: string } } = {
|
||||
function generateErrorPage(errorCode: number, _e: string): string {
|
||||
const errorDescriptions: Record<number, { title: string; description: string }> = {
|
||||
404: {
|
||||
title: 'Page Not Found',
|
||||
description: 'The file or directory you are looking for could not be found.'
|
||||
description: 'The file or directory you are looking for could not be found.',
|
||||
},
|
||||
500: {
|
||||
title: 'Server Error',
|
||||
description: 'An internal server error occurred while processing your request.'
|
||||
description: 'An internal server error occurred while processing your request.',
|
||||
},
|
||||
403: {
|
||||
title: 'Access Denied',
|
||||
description: 'You do not have permission to access this resource.'
|
||||
}
|
||||
description: 'You do not have permission to access this resource.',
|
||||
},
|
||||
}
|
||||
|
||||
const error = errorDescriptions[errorCode] || {
|
||||
title: 'Unknown Error',
|
||||
description: 'An unexpected error occurred.'
|
||||
description: 'An unexpected error occurred.',
|
||||
}
|
||||
|
||||
return `
|
||||
@@ -622,7 +622,7 @@ function serveFile(res: http.ServerResponse, filePath: fs.PathLike) {
|
||||
const readStream = fs.createReadStream(filePath)
|
||||
|
||||
const ext = path.extname(filePath.toString()).toLowerCase()
|
||||
const contentTypes: { [key: string]: string } = {
|
||||
const contentTypes: Record<string, string> = {
|
||||
'.html': 'text/html',
|
||||
'.css': 'text/css',
|
||||
'.js': 'application/javascript',
|
||||
@@ -634,7 +634,7 @@ function serveFile(res: http.ServerResponse, filePath: fs.PathLike) {
|
||||
'.svg': 'image/svg+xml',
|
||||
'.pdf': 'application/pdf',
|
||||
'.txt': 'text/plain',
|
||||
'.md': 'text/markdown'
|
||||
'.md': 'text/markdown',
|
||||
}
|
||||
|
||||
const contentType = contentTypes[ext] || 'application/octet-stream'
|
||||
@@ -662,7 +662,7 @@ class WebServer {
|
||||
enableWebServer: picgo.getConfig<boolean>(configPaths.settings.enableWebServer) || false,
|
||||
webServerHost: picgo.getConfig<string>(configPaths.settings.webServerHost) || '0.0.0.0',
|
||||
webServerPort: picgo.getConfig<number>(configPaths.settings.webServerPort) || 37777,
|
||||
webServerPath: picgo.getConfig<string>(configPaths.settings.webServerPath) || defaultPath
|
||||
webServerPath: picgo.getConfig<string>(configPaths.settings.webServerPath) || defaultPath,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ class WebServer {
|
||||
} else {
|
||||
serveFile(res, filePath)
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (_e) {
|
||||
logger.error(`File not found: ${filePath}`)
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||
res.end(generateErrorPage(404, 'The requested file or directory was not found'))
|
||||
@@ -694,9 +694,9 @@ class WebServer {
|
||||
this.#config.webServerHost,
|
||||
() => {
|
||||
logger.info(
|
||||
`Web server is running at http://${this.#config.webServerHost}:${this.#config.webServerPort}, root path is ${this.#config.webServerPath}`
|
||||
`Web server is running at http://${this.#config.webServerHost}:${this.#config.webServerPort}, root path is ${this.#config.webServerPath}`,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
.on('error', err => {
|
||||
logger.error(err)
|
||||
|
||||
@@ -8,7 +8,7 @@ export const setAutoStart = async (enable: boolean): Promise<void> => {
|
||||
try {
|
||||
if (process.platform !== 'linux') {
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin: enable
|
||||
openAtLogin: enable,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ function copyFileOutsideOfElectronAsar(sourceInAsarArchive: string, destOutsideA
|
||||
fs.readdirSync(sourceInAsarArchive).forEach(function (fileOrFolderName) {
|
||||
copyFileOutsideOfElectronAsar(
|
||||
`${sourceInAsarArchive}/${fileOrFolderName}`,
|
||||
`${destOutsideAsarArchive}/${fileOrFolderName}`
|
||||
`${destOutsideAsarArchive}/${fileOrFolderName}`,
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -52,7 +52,7 @@ function resolveMacWorkFlow() {
|
||||
path
|
||||
.join(__dirname, '../../resources', 'Upload pictures with PicList.workflow')
|
||||
.replace('app.asar', 'app.asar.unpacked'),
|
||||
dest
|
||||
dest,
|
||||
)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -94,7 +94,7 @@ function resolveClipboardImageGenerator() {
|
||||
return files.map(item => {
|
||||
return {
|
||||
origin: path.join(__dirname, '../../resources', item).replace('app.asar', 'app.asar.unpacked'),
|
||||
dest: path.join(CONFIG_DIR, item)
|
||||
dest: path.join(CONFIG_DIR, item),
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -110,7 +110,7 @@ function resolveOtherI18nFiles() {
|
||||
}
|
||||
i18nManager.setOutterI18nFolder(i18nFolder)
|
||||
const i18nFiles = fs.readdirSync(path.join(CONFIG_DIR, 'i18n'), {
|
||||
withFileTypes: true
|
||||
withFileTypes: true,
|
||||
})
|
||||
i18nFiles.forEach(item => {
|
||||
if (item.isFile() && item.name?.endsWith('.yml')) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import logger from '@core/picgo/logger'
|
||||
import { clipboard, NativeImage } from 'electron'
|
||||
|
||||
class ClipboardWatcher extends EventEmitter {
|
||||
// eslint-disable-next-line no-undef
|
||||
timer: NodeJS.Timeout | null
|
||||
lastImageHash: string | null
|
||||
|
||||
|
||||
@@ -64,12 +64,12 @@ export const showNotification = (
|
||||
body: '',
|
||||
clickToCopy: false,
|
||||
copyContent: '',
|
||||
clickFn: () => {}
|
||||
}
|
||||
clickFn: () => {},
|
||||
},
|
||||
) => {
|
||||
const notification = new Notification({
|
||||
title: options.title,
|
||||
body: options.body
|
||||
body: options.body,
|
||||
})
|
||||
const handleClick = () => {
|
||||
if (options.clickToCopy) {
|
||||
@@ -141,8 +141,8 @@ const createC1NShortUrl = async (url: string) => {
|
||||
form.append('url', url)
|
||||
const res = await axios.post(c1nApi, form, {
|
||||
headers: {
|
||||
token: c1nToken
|
||||
}
|
||||
token: c1nToken,
|
||||
},
|
||||
})
|
||||
if (res.status >= 200 && res.status < 300 && res.data?.code === 0) {
|
||||
return res.data.data
|
||||
@@ -168,7 +168,7 @@ const createYOURLSShortLink = async (url: string) => {
|
||||
signature,
|
||||
action: 'shorturl',
|
||||
format: 'json',
|
||||
url
|
||||
url,
|
||||
})
|
||||
try {
|
||||
const res = await axios.get(`${domain}/yourls-api.php?${params.toString()}`)
|
||||
@@ -222,7 +222,7 @@ const createShortUrlFromSink = async (url: string) => {
|
||||
const res = await axios.post(
|
||||
`${sinkDomain}/api/link/create`,
|
||||
{ url },
|
||||
{ headers: { Authorization: `Bearer ${sinkToken}` } }
|
||||
{ headers: { Authorization: `Bearer ${sinkToken}` } },
|
||||
)
|
||||
if (res.data?.link?.slug) {
|
||||
return `${sinkDomain}/${res.data.link.slug}`
|
||||
@@ -276,10 +276,10 @@ export const simpleClone = (obj: any) => JSON.parse(JSON.stringify(obj))
|
||||
export const enforceNumber = (num: number | string) => (isNaN(+num) ? 0 : +num)
|
||||
|
||||
export const trimValues = <T extends IStringKeyMap>(
|
||||
obj: T
|
||||
obj: T,
|
||||
): { [K in keyof T]: T[K] extends string ? string : T[K] } => {
|
||||
return Object.fromEntries(
|
||||
Object.entries(obj).map(([key, value]) => [key, typeof value === 'string' ? value.trim() : value])
|
||||
Object.entries(obj).map(([key, value]) => [key, typeof value === 'string' ? value.trim() : value]),
|
||||
) as { [K in keyof T]: T[K] extends string ? string : T[K] }
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ export const formatEndpoint = (endpoint: string, sslEnabled: boolean): string =>
|
||||
|
||||
export const formatHttpProxy = (
|
||||
proxy: string | undefined,
|
||||
type: 'object' | 'string'
|
||||
type: 'object' | 'string',
|
||||
): IHTTPProxy | undefined | string => {
|
||||
if (!proxy) return undefined
|
||||
if (/^https?:\/\//.test(proxy)) {
|
||||
@@ -303,7 +303,7 @@ export const formatHttpProxy = (
|
||||
: {
|
||||
host: hostname,
|
||||
port: Number(port),
|
||||
protocol: protocol.slice(0, -1)
|
||||
protocol: protocol.slice(0, -1),
|
||||
}
|
||||
}
|
||||
const [host, port] = proxy.split(':')
|
||||
@@ -312,7 +312,7 @@ export const formatHttpProxy = (
|
||||
: {
|
||||
host,
|
||||
port: port ? Number(port) : 80,
|
||||
protocol: 'http'
|
||||
protocol: 'http',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,12 @@ import type {
|
||||
ITcYunConfig,
|
||||
IUploaderConfig,
|
||||
IUpYunConfig,
|
||||
IWebdavPlistConfig
|
||||
IWebdavPlistConfig,
|
||||
} from '#/types/types'
|
||||
|
||||
export type manualPageOpenType = 'window' | 'browser'
|
||||
|
||||
interface IPicGoPlugins {
|
||||
[key: `picgo-plugin-${string}`]: boolean
|
||||
}
|
||||
type IPicGoPlugins = Record<`picgo-plugin-${string}`, boolean>
|
||||
|
||||
export interface IConfigStruct {
|
||||
picBed: {
|
||||
@@ -48,9 +46,7 @@ export interface IConfigStruct {
|
||||
[others: string]: any
|
||||
}
|
||||
settings: {
|
||||
shortKey: {
|
||||
[key: string]: IShortKeyConfig
|
||||
}
|
||||
shortKey: Record<string, IShortKeyConfig>
|
||||
logLevel: string[]
|
||||
logPath: string
|
||||
logFileSizeLimit: number
|
||||
@@ -132,12 +128,12 @@ export const configPaths = {
|
||||
secondUploaderConfig: 'picBed.secondUploaderConfig',
|
||||
proxy: 'picBed.proxy',
|
||||
transformer: 'picBed.transformer',
|
||||
list: 'picBed.list'
|
||||
list: 'picBed.list',
|
||||
},
|
||||
settings: {
|
||||
shortKey: {
|
||||
_path: 'settings.shortKey',
|
||||
'picgo:upload': 'settings.shortKey[picgo:upload]'
|
||||
'picgo:upload': 'settings.shortKey[picgo:upload]',
|
||||
},
|
||||
logLevel: 'settings.logLevel',
|
||||
logPath: 'settings.logPath',
|
||||
@@ -192,7 +188,7 @@ export const configPaths = {
|
||||
autoImport: 'settings.autoImport',
|
||||
autoImportPicBed: 'settings.autoImportPicBed',
|
||||
galleryPicBedFilter: 'settings.galleryPicBedFilter',
|
||||
enableSecondUploader: 'settings.enableSecondUploader'
|
||||
enableSecondUploader: 'settings.enableSecondUploader',
|
||||
},
|
||||
needReload: 'needReload',
|
||||
picgoPlugins: 'picgoPlugins',
|
||||
@@ -201,8 +197,8 @@ export const configPaths = {
|
||||
compress: 'buildIn.compress',
|
||||
watermark: 'buildIn.watermark',
|
||||
rename: 'buildIn.rename',
|
||||
skipProcess: 'buildIn.skipProcess'
|
||||
skipProcess: 'buildIn.skipProcess',
|
||||
},
|
||||
debug: 'debug',
|
||||
PICGO_ENV: 'PICGO_ENV'
|
||||
PICGO_ENV: 'PICGO_ENV',
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ const dogeRegionMap: IStringKeyMap = {
|
||||
'ap-shanghai': '0',
|
||||
'ap-beijing': '1',
|
||||
'ap-guangzhou': '2',
|
||||
'ap-chengdu': '3'
|
||||
'ap-chengdu': '3',
|
||||
}
|
||||
|
||||
async function dogecloudApi(
|
||||
@@ -41,7 +41,7 @@ async function dogecloudApi(
|
||||
data = {},
|
||||
jsonMode: boolean = false,
|
||||
accessKey: string,
|
||||
secretKey: string
|
||||
secretKey: string,
|
||||
) {
|
||||
const body = jsonMode ? JSON.stringify(data) : querystring.encode(data)
|
||||
const sign = crypto
|
||||
@@ -57,14 +57,14 @@ async function dogecloudApi(
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Content-Type': jsonMode ? 'application/json' : 'application/x-www-form-urlencoded',
|
||||
Authorization: authorization
|
||||
}
|
||||
Authorization: authorization,
|
||||
},
|
||||
})
|
||||
if (res.data.code !== 200) {
|
||||
throw new Error('API Error')
|
||||
}
|
||||
return res.data.data
|
||||
} catch (err: any) {
|
||||
} catch (_err: any) {
|
||||
throw new Error('API Error')
|
||||
}
|
||||
}
|
||||
@@ -75,11 +75,11 @@ async function getDogeToken(accessKey: string, secretKey: string): Promise<IObj
|
||||
'/auth/tmp_token.json',
|
||||
{
|
||||
channel: 'OSS_FULL',
|
||||
scopes: ['*']
|
||||
scopes: ['*'],
|
||||
},
|
||||
true,
|
||||
accessKey,
|
||||
secretKey
|
||||
secretKey,
|
||||
)
|
||||
return data
|
||||
} catch (err: any) {
|
||||
@@ -100,12 +100,12 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
||||
pathStyleAccess,
|
||||
rejectUnauthorized,
|
||||
proxy,
|
||||
urlPrefix
|
||||
}
|
||||
urlPrefix,
|
||||
},
|
||||
} = configMap
|
||||
let {
|
||||
imgUrl,
|
||||
config: { region }
|
||||
config: { region },
|
||||
} = configMap
|
||||
if (type === 'aws-s3' || type === 'aws-s3-plist') {
|
||||
imgUrl = rawUrl || imgUrl || ''
|
||||
@@ -139,7 +139,7 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
||||
const commonOptions: AgentOptions = {
|
||||
keepAlive: true,
|
||||
keepAliveMsecs: 1000,
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
|
||||
}
|
||||
const extraOptions = sslEnabled ? { rejectUnauthorized: !!rejectUnauthorized } : {}
|
||||
const handler = sslEnabled
|
||||
@@ -148,52 +148,52 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
||||
? agent.https
|
||||
: new https.Agent({
|
||||
...commonOptions,
|
||||
...extraOptions
|
||||
})
|
||||
...extraOptions,
|
||||
}),
|
||||
})
|
||||
: new NodeHttpHandler({
|
||||
httpAgent: agent.http
|
||||
? agent.http
|
||||
: new http.Agent({
|
||||
...commonOptions,
|
||||
...extraOptions
|
||||
})
|
||||
...extraOptions,
|
||||
}),
|
||||
})
|
||||
const s3Options: S3ClientConfig = {
|
||||
credentials: {
|
||||
accessKeyId: accessKeyID,
|
||||
secretAccessKey
|
||||
secretAccessKey,
|
||||
},
|
||||
endpoint: endpointUrl,
|
||||
tls: sslEnabled,
|
||||
forcePathStyle: pathStyleAccess,
|
||||
region,
|
||||
requestHandler: handler
|
||||
requestHandler: handler,
|
||||
}
|
||||
if (dogeMode) {
|
||||
s3Options.credentials = {
|
||||
accessKeyId: configMap.config.accessKeyID,
|
||||
secretAccessKey: configMap.config.secretAccessKey,
|
||||
sessionToken: configMap.config.sessionToken
|
||||
sessionToken: configMap.config.sessionToken,
|
||||
}
|
||||
}
|
||||
let result: any
|
||||
try {
|
||||
fileKey = decodeURIComponent(fileKey)
|
||||
} catch (err: any) {}
|
||||
} catch (_err: any) {}
|
||||
try {
|
||||
const client = new S3Client(s3Options)
|
||||
const command = new DeleteObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: fileKey
|
||||
Key: fileKey,
|
||||
})
|
||||
result = await client.send(command)
|
||||
} catch (err: any) {
|
||||
} catch (_err: any) {
|
||||
s3Options.region = 'us-east-1'
|
||||
const client = new S3Client(s3Options)
|
||||
const command = new DeleteObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: fileKey
|
||||
Key: fileKey,
|
||||
})
|
||||
result = await client.send(command)
|
||||
}
|
||||
@@ -202,7 +202,7 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
||||
|
||||
export async function removeFileFromDogeInMain(configMap: IStringKeyMap) {
|
||||
const {
|
||||
config: { bucketName, AccessKey, SecretKey }
|
||||
config: { bucketName, AccessKey, SecretKey },
|
||||
} = configMap
|
||||
const token = (await getDogeToken(AccessKey, SecretKey)) as DogecloudTokenFull
|
||||
const bucket = token.Buckets?.find(item => item.name === bucketName || item.s3Bucket === bucketName)
|
||||
@@ -214,7 +214,7 @@ export async function removeFileFromDogeInMain(configMap: IStringKeyMap) {
|
||||
sessionToken: token.Credentials?.sessionToken,
|
||||
endpoint: bucket?.s3Endpoint,
|
||||
region: dogeRegionMap[bucket?.s3Endpoint?.split('.')[1] || 'ap-shanghai'],
|
||||
bucketName: bucket?.s3Bucket
|
||||
bucketName: bucket?.s3Bucket,
|
||||
}
|
||||
return await removeFileFromS3InMain(newConfigMap, true)
|
||||
}
|
||||
@@ -225,7 +225,7 @@ function createHuaweiAuthorization(
|
||||
fileName: string,
|
||||
accessKey: string,
|
||||
secretKey: string,
|
||||
date: string = new Date().toUTCString()
|
||||
date: string = new Date().toUTCString(),
|
||||
) {
|
||||
const strToSign = `DELETE\n\n\n${date}\n/${bucketName}${path}/${fileName}`
|
||||
const singature = crypto.createHmac('sha1', secretKey).update(strToSign).digest('base64')
|
||||
@@ -247,8 +247,8 @@ export async function removeFileFromHuaweiInMain(configMap: IStringKeyMap) {
|
||||
headers: {
|
||||
Host: `${bucketName}.${endpoint}`,
|
||||
Date: date,
|
||||
Authorization: authorization
|
||||
}
|
||||
Authorization: authorization,
|
||||
},
|
||||
})
|
||||
return res.status === 204
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export function digestAuthHeader(
|
||||
uri: string,
|
||||
wwwAuthenticate: string,
|
||||
username: string,
|
||||
password: string
|
||||
password: string,
|
||||
) {
|
||||
const parts = wwwAuthenticate.split(',')
|
||||
const opts = {} as IStringKeyMap
|
||||
|
||||
@@ -2,7 +2,7 @@ export const ILogType = {
|
||||
success: 'success',
|
||||
info: 'info',
|
||||
warn: 'warn',
|
||||
error: 'error'
|
||||
error: 'error',
|
||||
}
|
||||
|
||||
export const ICOREBuildInEvent = {
|
||||
@@ -16,7 +16,7 @@ export const ICOREBuildInEvent = {
|
||||
UNINSTALL: 'uninstall',
|
||||
UPDATE: 'update',
|
||||
NOTIFICATION: 'notification',
|
||||
REMOVE: 'remove'
|
||||
REMOVE: 'remove',
|
||||
}
|
||||
|
||||
export const IPicGoHelperType = {
|
||||
@@ -24,7 +24,7 @@ export const IPicGoHelperType = {
|
||||
beforeTransformPlugins: 'beforeTransformPlugins',
|
||||
beforeUploadPlugins: 'beforeUploadPlugins',
|
||||
uploader: 'uploader',
|
||||
transformer: 'transformer'
|
||||
transformer: 'transformer',
|
||||
}
|
||||
|
||||
export const IPasteStyle = {
|
||||
@@ -32,7 +32,7 @@ export const IPasteStyle = {
|
||||
HTML: 'HTML',
|
||||
URL: 'URL',
|
||||
UBB: 'UBB',
|
||||
CUSTOM: 'Custom'
|
||||
CUSTOM: 'Custom',
|
||||
}
|
||||
|
||||
export const IWindowList = {
|
||||
@@ -40,7 +40,7 @@ export const IWindowList = {
|
||||
TRAY_WINDOW: 'TRAY_WINDOW',
|
||||
MINI_WINDOW: 'MINI_WINDOW',
|
||||
RENAME_WINDOW: 'RENAME_WINDOW',
|
||||
TOOLBOX_WINDOW: 'TOOLBOX_WINDOW'
|
||||
TOOLBOX_WINDOW: 'TOOLBOX_WINDOW',
|
||||
}
|
||||
|
||||
export const IRemoteNoticeActionType = {
|
||||
@@ -49,22 +49,22 @@ export const IRemoteNoticeActionType = {
|
||||
SHOW_DIALOG: 'SHOW_DIALOG', // dialog notice
|
||||
COMMON: 'COMMON',
|
||||
VOID: 'VOID', // do nothing
|
||||
SHOW_MESSAGE_BOX: 'SHOW_MESSAGE_BOX'
|
||||
SHOW_MESSAGE_BOX: 'SHOW_MESSAGE_BOX',
|
||||
}
|
||||
|
||||
export const IRemoteNoticeTriggerHook = {
|
||||
APP_START: 'APP_START',
|
||||
SETTING_WINDOW_OPEN: 'SETTING_WINDOW_OPEN'
|
||||
SETTING_WINDOW_OPEN: 'SETTING_WINDOW_OPEN',
|
||||
}
|
||||
|
||||
export const IRemoteNoticeTriggerCount = {
|
||||
ONCE: 'ONCE', // default
|
||||
ALWAYS: 'ALWAYS'
|
||||
ALWAYS: 'ALWAYS',
|
||||
}
|
||||
|
||||
export const IRPCType = {
|
||||
INVOKE: 'INVOKE',
|
||||
SEND: 'SEND'
|
||||
SEND: 'SEND',
|
||||
}
|
||||
|
||||
export const IRPCActionType = {
|
||||
@@ -186,58 +186,58 @@ export const IRPCActionType = {
|
||||
MANAGE_OPEN_DOWNLOADED_FOLDER: 'MANAGE_OPEN_DOWNLOADED_FOLDER',
|
||||
MANAGE_OPEN_LOCAL_FILE: 'MANAGE_OPEN_LOCAL_FILE',
|
||||
MANAGE_DOWNLOAD_FILE_FROM_URL: 'MANAGE_DOWNLOAD_FILE_FROM_URL',
|
||||
MANAGE_CONVERT_PATH_TO_BASE64: 'MANAGE_CONVERT_PATH_TO_BASE64'
|
||||
MANAGE_CONVERT_PATH_TO_BASE64: 'MANAGE_CONVERT_PATH_TO_BASE64',
|
||||
}
|
||||
|
||||
export const IToolboxItemType = {
|
||||
IS_CONFIG_FILE_BROKEN: 'IS_CONFIG_FILE_BROKEN',
|
||||
IS_GALLERY_FILE_BROKEN: 'IS_GALLERY_FILE_BROKEN',
|
||||
HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD: 'HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD',
|
||||
HAS_PROBLEM_WITH_PROXY: 'HAS_PROBLEM_WITH_PROXY'
|
||||
HAS_PROBLEM_WITH_PROXY: 'HAS_PROBLEM_WITH_PROXY',
|
||||
}
|
||||
|
||||
export const IToolboxItemCheckStatus = {
|
||||
INIT: 'init',
|
||||
LOADING: 'loading',
|
||||
SUCCESS: 'success',
|
||||
ERROR: 'error'
|
||||
ERROR: 'error',
|
||||
}
|
||||
|
||||
export const ISartMode = {
|
||||
QUIET: 'quiet',
|
||||
MINI: 'mini',
|
||||
MAIN: 'main',
|
||||
NO_TRAY: 'no-tray'
|
||||
NO_TRAY: 'no-tray',
|
||||
}
|
||||
|
||||
export const II18nLanguage = {
|
||||
ZH_CN: 'zh-CN',
|
||||
ZH_TW: 'zh-TW',
|
||||
EN: 'en'
|
||||
EN: 'en',
|
||||
}
|
||||
|
||||
export const IShortUrlServer = {
|
||||
C1N: 'c1n',
|
||||
YOURLS: 'yourls',
|
||||
CFWORKER: 'cf_worker',
|
||||
SINK: 'sink'
|
||||
SINK: 'sink',
|
||||
}
|
||||
|
||||
export const commonTaskStatus = {
|
||||
queuing: 'queuing',
|
||||
failed: 'failed',
|
||||
canceled: 'canceled',
|
||||
paused: 'paused'
|
||||
paused: 'paused',
|
||||
}
|
||||
|
||||
// manage task status
|
||||
|
||||
export const uploadTaskSpecialStatus = {
|
||||
uploading: 'uploading',
|
||||
uploaded: 'uploaded'
|
||||
uploaded: 'uploaded',
|
||||
}
|
||||
|
||||
export const downloadTaskSpecialStatus = {
|
||||
downloading: 'downloading',
|
||||
downloaded: 'downloaded'
|
||||
downloaded: 'downloaded',
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ const getPicBeds = () => {
|
||||
return {
|
||||
type: item,
|
||||
name: picgo.helper.uploader.get(item)!.name || item,
|
||||
visible: visible ? visible.visible : true
|
||||
visible: visible ? visible.visible : true,
|
||||
}
|
||||
})
|
||||
.sort(a => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
IPicGoPluginOriginConfig,
|
||||
IStringKeyMap,
|
||||
IUploaderConfigItem,
|
||||
IUploaderConfigListItem
|
||||
IUploaderConfigListItem,
|
||||
} from '#/types/types'
|
||||
import { setTrayToolTip, trimValues } from '~/utils/common'
|
||||
import { configPaths } from '~/utils/configPaths'
|
||||
@@ -30,7 +30,7 @@ export const completeUploaderMetaConfig = (originData: IStringKeyMap): IUploader
|
||||
...trimValues(originData),
|
||||
_id: uuid(),
|
||||
_createdAt: Date.now(),
|
||||
_updatedAt: Date.now()
|
||||
_updatedAt: Date.now(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ export const getPicBedConfig = (type: string) => {
|
||||
const config = handleConfigWithFunction(_config)
|
||||
return {
|
||||
config,
|
||||
name
|
||||
name,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
config: [],
|
||||
name
|
||||
name,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,16 +62,16 @@ export const changeSecondUploader = (type: string, config?: IStringKeyMap, id?:
|
||||
}
|
||||
if (id) {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.secondUploaderId]: id
|
||||
[configPaths.picBed.secondUploaderId]: id,
|
||||
})
|
||||
}
|
||||
if (config) {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.secondUploaderConfig]: config
|
||||
[configPaths.picBed.secondUploaderConfig]: config,
|
||||
})
|
||||
}
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.secondUploader]: type
|
||||
[configPaths.picBed.secondUploader]: type,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -81,17 +81,17 @@ export const changeCurrentUploader = (type: string, config?: IStringKeyMap, id?:
|
||||
}
|
||||
if (id) {
|
||||
picgo.saveConfig({
|
||||
[`uploader.${type}.defaultId`]: id
|
||||
[`uploader.${type}.defaultId`]: id,
|
||||
})
|
||||
}
|
||||
if (config) {
|
||||
picgo.saveConfig({
|
||||
[`picBed.${type}`]: config
|
||||
[`picBed.${type}`]: config,
|
||||
})
|
||||
}
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.current]: type,
|
||||
[configPaths.picBed.uploader]: type
|
||||
[configPaths.picBed.uploader]: type,
|
||||
})
|
||||
setTrayToolTip(`${type} ${config?._configName || ''}`)
|
||||
}
|
||||
@@ -102,7 +102,7 @@ export const selectUploaderConfig = (type: string, id: string) => {
|
||||
if (config) {
|
||||
picgo.saveConfig({
|
||||
[`uploader.${type}.defaultId`]: id,
|
||||
[`picBed.${type}`]: config
|
||||
[`picBed.${type}`]: config,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export const getUploaderConfigList = (type: string): IUploaderConfigItem => {
|
||||
if (!type) {
|
||||
return {
|
||||
configList: [],
|
||||
defaultId: ''
|
||||
defaultId: '',
|
||||
}
|
||||
}
|
||||
const currentUploaderConfig = picgo.getConfig<IStringKeyMap>(`uploader.${type}`) ?? {}
|
||||
@@ -124,7 +124,7 @@ export const getUploaderConfigList = (type: string): IUploaderConfigItem => {
|
||||
}
|
||||
return {
|
||||
configList,
|
||||
defaultId
|
||||
defaultId,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,11 +143,11 @@ export const deleteUploaderConfig = (type: string, id: string): IUploaderConfigI
|
||||
changeCurrentUploader(type, updatedConfigList[0], updatedConfigList[0]._id)
|
||||
}
|
||||
picgo.saveConfig({
|
||||
[`uploader.${type}.configList`]: updatedConfigList
|
||||
[`uploader.${type}.configList`]: updatedConfigList,
|
||||
})
|
||||
return {
|
||||
configList: updatedConfigList,
|
||||
defaultId: newDefaultId
|
||||
defaultId: newDefaultId,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ export const deleteUploaderConfig = (type: string, id: string): IUploaderConfigI
|
||||
* upgrade old uploader config to new format
|
||||
*/
|
||||
export const upgradeUploaderConfig = (
|
||||
type: string
|
||||
type: string,
|
||||
): {
|
||||
configList: IStringKeyMap[]
|
||||
defaultId: string
|
||||
@@ -169,13 +169,13 @@ export const upgradeUploaderConfig = (
|
||||
picgo.saveConfig({
|
||||
[`uploader.${type}`]: {
|
||||
configList: uploaderConfigList,
|
||||
defaultId: uploaderConfig._id
|
||||
defaultId: uploaderConfig._id,
|
||||
},
|
||||
[`picBed.${type}`]: uploaderConfig
|
||||
[`picBed.${type}`]: uploaderConfig,
|
||||
})
|
||||
return {
|
||||
configList: uploaderConfigList,
|
||||
defaultId: uploaderConfig._id
|
||||
defaultId: uploaderConfig._id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ export const updateUploaderConfig = (type: string, id: string, config: IStringKe
|
||||
let updatedDefaultId = defaultId
|
||||
if (existConfig) {
|
||||
updatedConfig = Object.assign(existConfig, trimValues(config), {
|
||||
_updatedAt: Date.now()
|
||||
_updatedAt: Date.now(),
|
||||
})
|
||||
} else {
|
||||
updatedConfig = completeUploaderMetaConfig(config)
|
||||
@@ -196,7 +196,7 @@ export const updateUploaderConfig = (type: string, id: string, config: IStringKe
|
||||
picgo.saveConfig({
|
||||
[`uploader.${type}.configList`]: configList,
|
||||
[`uploader.${type}.defaultId`]: updatedDefaultId,
|
||||
[`picBed.${type}`]: updatedConfig
|
||||
[`picBed.${type}`]: updatedConfig,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -216,12 +216,12 @@ export const resetUploaderConfig = (type: string, id: string) => {
|
||||
}
|
||||
})
|
||||
picgo.saveConfig({
|
||||
[`uploader.${type}.configList`]: configList
|
||||
[`uploader.${type}.configList`]: configList,
|
||||
})
|
||||
const currentDefault = picgo.getConfig<IStringKeyMap>(`picBed.${type}`) ?? {}
|
||||
if (currentDefault._id === id) {
|
||||
picgo.saveConfig({
|
||||
[`picBed.${type}`]: configList
|
||||
[`picBed.${type}`]: configList,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export const formatCustomLink = (customLink: string, item: ImgInfo) => {
|
||||
const formatObj = {
|
||||
url,
|
||||
fileName,
|
||||
extName
|
||||
extName,
|
||||
}
|
||||
const keys = Object.keys(formatObj) as ['url', 'fileName', 'extName']
|
||||
keys.forEach(item => {
|
||||
@@ -41,8 +41,8 @@ export default async (style: string, item: ImgInfo, customLink: string | undefin
|
||||
UBB: `[IMG]${url}[/IMG]`,
|
||||
Custom: formatCustomLink(_customLink, {
|
||||
...item,
|
||||
url
|
||||
})
|
||||
url,
|
||||
}),
|
||||
}
|
||||
return [tpl[style], useShortUrl ? url : '']
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
export class MemoryMonitor {
|
||||
// eslint-disable-next-line no-undef
|
||||
private static interval: NodeJS.Timeout | null = null
|
||||
|
||||
static start(intervalMs: number = 30000) {
|
||||
@@ -11,10 +10,10 @@ export class MemoryMonitor {
|
||||
rss: Math.round(memUsage.rss / 1024 / 1024),
|
||||
heapTotal: Math.round(memUsage.heapTotal / 1024 / 1024),
|
||||
heapUsed: Math.round(memUsage.heapUsed / 1024 / 1024),
|
||||
external: Math.round(memUsage.external / 1024 / 1024)
|
||||
external: Math.round(memUsage.external / 1024 / 1024),
|
||||
}
|
||||
console.log(
|
||||
`[Memory] RSS: ${mbUsage.rss}MB, Heap: ${mbUsage.heapUsed}/${mbUsage.heapTotal}MB, External: ${mbUsage.external}MB`
|
||||
`[Memory] RSS: ${mbUsage.rss}MB, Heap: ${mbUsage.heapUsed}/${mbUsage.heapTotal}MB, External: ${mbUsage.external}MB`,
|
||||
)
|
||||
|
||||
if (mbUsage.heapUsed / mbUsage.heapTotal > 0.8 && global.gc) {
|
||||
|
||||
@@ -29,14 +29,14 @@ class SSHClient {
|
||||
? {
|
||||
username,
|
||||
privateKeyPath: privateKey,
|
||||
passphrase: passphrase || undefined
|
||||
passphrase: passphrase || undefined,
|
||||
}
|
||||
: { username, password }
|
||||
try {
|
||||
await SSHClient.client.connect({
|
||||
host: config.host,
|
||||
port: Number(config.port) || 22,
|
||||
...loginInfo
|
||||
...loginInfo,
|
||||
})
|
||||
this._isConnected = true
|
||||
return true
|
||||
@@ -53,7 +53,7 @@ class SSHClient {
|
||||
? {
|
||||
username,
|
||||
privateKey: fs.readFileSync(privateKey),
|
||||
passphrase: passphrase || undefined
|
||||
passphrase: passphrase || undefined,
|
||||
}
|
||||
: { username, password }
|
||||
remote = this.changeWinStylePathToUnix(remote)
|
||||
@@ -66,23 +66,21 @@ class SSHClient {
|
||||
err: any,
|
||||
sftp: {
|
||||
unlink: (arg0: string, arg1: (err: any) => void) => void
|
||||
}
|
||||
},
|
||||
) => {
|
||||
// eslint-disable-next-line prefer-promise-reject-errors
|
||||
if (err) reject(false)
|
||||
sftp.unlink(remote, (err: any) => {
|
||||
// eslint-disable-next-line prefer-promise-reject-errors
|
||||
if (err) reject(false)
|
||||
client.end()
|
||||
resolve(true)
|
||||
})
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
.connect({
|
||||
host: config.host,
|
||||
port: Number(config.port) || 22,
|
||||
...loginInfo
|
||||
...loginInfo,
|
||||
})
|
||||
})
|
||||
return (await promise) as boolean
|
||||
@@ -110,7 +108,7 @@ class SSHClient {
|
||||
remote = this.changeWinStylePathToUnix(remote)
|
||||
local = this.changeWinStylePathToUnix(local)
|
||||
await SSHClient.client.getFile(local, remote, undefined, {
|
||||
concurrency: 1
|
||||
concurrency: 1,
|
||||
})
|
||||
return true
|
||||
} catch (err: any) {
|
||||
@@ -125,7 +123,7 @@ class SSHClient {
|
||||
config: {
|
||||
fileMode?: string
|
||||
dirMode?: string
|
||||
} = {}
|
||||
} = {},
|
||||
): Promise<boolean> {
|
||||
if (!this._isConnected) {
|
||||
throw new Error('SSH 未连接')
|
||||
@@ -150,7 +148,7 @@ class SSHClient {
|
||||
dirPath: string,
|
||||
config: {
|
||||
dirMode?: string
|
||||
} = {}
|
||||
} = {},
|
||||
): Promise<boolean> {
|
||||
if (!this._isConnected) {
|
||||
throw new Error('SSH 未连接')
|
||||
|
||||
@@ -21,5 +21,5 @@ export const picBedsCanbeDeleted = [
|
||||
'smms',
|
||||
'tcyun',
|
||||
'upyun',
|
||||
'webdavplist'
|
||||
'webdavplist',
|
||||
]
|
||||
|
||||
@@ -29,7 +29,7 @@ const getSyncConfig = () => {
|
||||
repo: '',
|
||||
branch: '',
|
||||
token: '',
|
||||
proxy: ''
|
||||
proxy: '',
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -41,7 +41,7 @@ const getProxyagent = (proxy: string | undefined) => {
|
||||
keepAliveMsecs: 1000,
|
||||
rejectUnauthorized: false,
|
||||
proxy: proxy.replace('127.0.0.1', 'localhost'),
|
||||
scheduling: 'lifo'
|
||||
scheduling: 'lifo',
|
||||
})
|
||||
: undefined
|
||||
}
|
||||
@@ -51,8 +51,8 @@ function getOctokit(syncConfig: ISyncConfig) {
|
||||
return new Octokit({
|
||||
auth: token,
|
||||
request: {
|
||||
agent: getProxyagent(proxy)
|
||||
}
|
||||
agent: getProxyagent(proxy),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ const isSyncConfigValidate = ({
|
||||
webdavPassword,
|
||||
webdavAuthType,
|
||||
webdavSslEnabled,
|
||||
webdavSavePath
|
||||
webdavSavePath,
|
||||
}: ISyncConfig) => {
|
||||
if (type === 'webdav') {
|
||||
return (
|
||||
@@ -92,7 +92,7 @@ async function uploadLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
const defaultConfig = {
|
||||
content: readFileAsBase64(localFilePath),
|
||||
message: uploadOrUpdateMsg(fileName, false),
|
||||
branch
|
||||
branch,
|
||||
}
|
||||
try {
|
||||
switch (type) {
|
||||
@@ -100,7 +100,7 @@ async function uploadLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
const url = `https://gitee.com/api/v5/repos/${username}/${repo}/contents/${fileName}`
|
||||
const res = await axios.post(url, {
|
||||
...defaultConfig,
|
||||
access_token: token
|
||||
access_token: token,
|
||||
})
|
||||
return isHttpResSuccess(res)
|
||||
}
|
||||
@@ -110,7 +110,7 @@ async function uploadLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
...defaultConfig,
|
||||
owner: username,
|
||||
repo,
|
||||
path: fileName
|
||||
path: fileName,
|
||||
})
|
||||
return isHttpResSuccess(res)
|
||||
}
|
||||
@@ -118,7 +118,7 @@ async function uploadLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
const { endpoint = '' } = syncConfig
|
||||
const apiUrl = `${endpoint}/api/v1/repos/${username}/${repo}/contents/${fileName}`
|
||||
const headers = {
|
||||
Authorization: `token ${token}`
|
||||
Authorization: `token ${token}`,
|
||||
}
|
||||
const res = await axios.post(apiUrl, defaultConfig, { headers })
|
||||
return isHttpResSuccess(res)
|
||||
@@ -130,12 +130,12 @@ async function uploadLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
webdavPassword,
|
||||
webdavAuthType = 'basic',
|
||||
webdavSslEnabled = true,
|
||||
webdavSavePath = ''
|
||||
webdavSavePath = '',
|
||||
} = syncConfig
|
||||
const webdavEndpointF = formatEndpoint(webdavEndpoint, webdavSslEnabled)
|
||||
const options: WebDAVClientOptions = {
|
||||
username: webdavUsername,
|
||||
password: webdavPassword
|
||||
password: webdavPassword,
|
||||
}
|
||||
if (webdavAuthType === 'digest') {
|
||||
options.authType = AuthType.Digest
|
||||
@@ -170,7 +170,7 @@ async function updateLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
const defaultConfig = {
|
||||
branch,
|
||||
message: uploadOrUpdateMsg(fileName),
|
||||
content: readFileAsBase64(localFilePath)
|
||||
content: readFileAsBase64(localFilePath),
|
||||
}
|
||||
switch (type) {
|
||||
case 'gitee': {
|
||||
@@ -178,8 +178,8 @@ async function updateLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
const shaRes = await axios.get(url, {
|
||||
params: {
|
||||
access_token: token,
|
||||
ref: branch
|
||||
}
|
||||
ref: branch,
|
||||
},
|
||||
})
|
||||
if (!isHttpResSuccess(shaRes)) {
|
||||
return false
|
||||
@@ -191,7 +191,7 @@ async function updateLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
repo,
|
||||
path: fileName,
|
||||
sha,
|
||||
access_token: token
|
||||
access_token: token,
|
||||
})
|
||||
return isHttpResSuccess(res)
|
||||
}
|
||||
@@ -201,7 +201,7 @@ async function updateLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
owner: username,
|
||||
repo,
|
||||
path: fileName,
|
||||
ref: branch
|
||||
ref: branch,
|
||||
})
|
||||
if (shaRes.status !== 200) {
|
||||
throw new Error('get sha failed')
|
||||
@@ -213,7 +213,7 @@ async function updateLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
owner: username,
|
||||
repo,
|
||||
path: fileName,
|
||||
sha
|
||||
sha,
|
||||
})
|
||||
return res.status === 200
|
||||
}
|
||||
@@ -221,10 +221,10 @@ async function updateLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
const { endpoint = '' } = syncConfig
|
||||
const apiUrl = `${endpoint}/api/v1/repos/${username}/${repo}/contents/${fileName}`
|
||||
const headers = {
|
||||
Authorization: `token ${token}`
|
||||
Authorization: `token ${token}`,
|
||||
}
|
||||
const shaRes = await axios.get(apiUrl, {
|
||||
headers
|
||||
headers,
|
||||
})
|
||||
if (!isHttpResSuccess(shaRes)) {
|
||||
throw new Error('get sha failed')
|
||||
@@ -235,11 +235,11 @@ async function updateLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
apiUrl,
|
||||
{
|
||||
...defaultConfig,
|
||||
sha
|
||||
sha,
|
||||
},
|
||||
{
|
||||
headers
|
||||
}
|
||||
headers,
|
||||
},
|
||||
)
|
||||
return isHttpResSuccess(res)
|
||||
}
|
||||
@@ -250,12 +250,12 @@ async function updateLocalToRemote(syncConfig: ISyncConfig, fileName: string) {
|
||||
webdavPassword,
|
||||
webdavAuthType = 'basic',
|
||||
webdavSslEnabled = true,
|
||||
webdavSavePath = ''
|
||||
webdavSavePath = '',
|
||||
} = syncConfig
|
||||
const webdavEndpointF = formatEndpoint(webdavEndpoint, webdavSslEnabled)
|
||||
const options: WebDAVClientOptions = {
|
||||
username: webdavUsername,
|
||||
password: webdavPassword
|
||||
password: webdavPassword,
|
||||
}
|
||||
if (webdavAuthType === 'digest') {
|
||||
options.authType = AuthType.Digest
|
||||
@@ -287,7 +287,7 @@ async function uploadFile(fileName: string[]): Promise<number> {
|
||||
let result = false
|
||||
try {
|
||||
result = await updateLocalToRemote(syncConfig, file)
|
||||
} catch (error: any) {
|
||||
} catch (_e: any) {
|
||||
result = await uploadLocalToRemote(syncConfig, file)
|
||||
}
|
||||
logger.info(`upload ${file} ${result ? 'success' : 'failed'}`)
|
||||
@@ -307,7 +307,7 @@ async function downloadAndWriteFile(url: string, localFilePath: string, config:
|
||||
if (isHttpResSuccess(res)) {
|
||||
await fs.writeFile(
|
||||
localFilePath,
|
||||
isWriteJson ? JSON.stringify(res.data, null, 2) : Buffer.from(res.data.content, 'base64')
|
||||
isWriteJson ? JSON.stringify(res.data, null, 2) : Buffer.from(res.data.content, 'base64'),
|
||||
)
|
||||
return true
|
||||
}
|
||||
@@ -324,8 +324,8 @@ async function downloadRemoteToLocal(syncConfig: ISyncConfig, fileName: string)
|
||||
return downloadAndWriteFile(url, localFilePath, {
|
||||
params: {
|
||||
access_token: token,
|
||||
ref: branch
|
||||
}
|
||||
ref: branch,
|
||||
},
|
||||
})
|
||||
}
|
||||
case 'github': {
|
||||
@@ -334,7 +334,7 @@ async function downloadRemoteToLocal(syncConfig: ISyncConfig, fileName: string)
|
||||
owner: username,
|
||||
repo,
|
||||
path: fileName,
|
||||
ref: branch
|
||||
ref: branch,
|
||||
})
|
||||
if (res.status === 200) {
|
||||
const data = res.data as any
|
||||
@@ -343,9 +343,9 @@ async function downloadRemoteToLocal(syncConfig: ISyncConfig, fileName: string)
|
||||
downloadUrl,
|
||||
localFilePath,
|
||||
{
|
||||
httpsAgent: getProxyagent(proxy)
|
||||
httpsAgent: getProxyagent(proxy),
|
||||
},
|
||||
true
|
||||
true,
|
||||
)
|
||||
}
|
||||
return false
|
||||
@@ -355,11 +355,11 @@ async function downloadRemoteToLocal(syncConfig: ISyncConfig, fileName: string)
|
||||
const apiUrl = `${endpoint}/api/v1/repos/${username}/${repo}/contents/${fileName}`
|
||||
return downloadAndWriteFile(apiUrl, localFilePath, {
|
||||
headers: {
|
||||
Authorization: `token ${token}`
|
||||
Authorization: `token ${token}`,
|
||||
},
|
||||
params: {
|
||||
ref: branch
|
||||
}
|
||||
ref: branch,
|
||||
},
|
||||
})
|
||||
}
|
||||
case 'webdav': {
|
||||
@@ -369,12 +369,12 @@ async function downloadRemoteToLocal(syncConfig: ISyncConfig, fileName: string)
|
||||
webdavPassword,
|
||||
webdavAuthType = 'basic',
|
||||
webdavSslEnabled = true,
|
||||
webdavSavePath = ''
|
||||
webdavSavePath = '',
|
||||
} = syncConfig
|
||||
const webdavEndpointF = formatEndpoint(webdavEndpoint, webdavSslEnabled)
|
||||
const options: WebDAVClientOptions = {
|
||||
username: webdavUsername,
|
||||
password: webdavPassword
|
||||
password: webdavPassword,
|
||||
}
|
||||
if (webdavAuthType === 'digest') {
|
||||
options.authType = AuthType.Digest
|
||||
|
||||
@@ -12,7 +12,7 @@ const updateChecker = async () => {
|
||||
if (showTip) {
|
||||
try {
|
||||
await updater.autoUpdater.checkForUpdatesAndNotify()
|
||||
} catch (err) {}
|
||||
} catch (_err) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export function openMiniWindow(hideSettingWindow: boolean = true) {
|
||||
miniWindow.setPosition(width - miniWindow.getSize()[0], height - miniWindow.getSize()[1])
|
||||
db.set(configPaths.settings.miniWindowPosition, [
|
||||
width - miniWindow.getSize()[0],
|
||||
height - miniWindow.getSize()[1]
|
||||
height - miniWindow.getSize()[1],
|
||||
])
|
||||
} else {
|
||||
miniWindow.setPosition(lastPosition[0], lastPosition[1])
|
||||
|
||||
@@ -43,7 +43,7 @@ try {
|
||||
webFrame.setVisualZoomLevelLimits(min, max)
|
||||
},
|
||||
clipboard: {
|
||||
writeText: clipboard.writeText
|
||||
writeText: clipboard.writeText,
|
||||
},
|
||||
platform: process.platform,
|
||||
sendRpcSync,
|
||||
@@ -65,7 +65,7 @@ try {
|
||||
},
|
||||
showFilePath(file: File) {
|
||||
return webUtils.getPathForFile(file)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
contextBridge.exposeInMainWorld('node', {
|
||||
@@ -77,27 +77,27 @@ try {
|
||||
extname: path.extname,
|
||||
sep: path.sep,
|
||||
posix: {
|
||||
sep: path.posix.sep
|
||||
}
|
||||
sep: path.posix.sep,
|
||||
},
|
||||
},
|
||||
fs: {
|
||||
remove: fs.remove,
|
||||
readFile: fs.readFile,
|
||||
statSync: fs.statSync
|
||||
statSync: fs.statSync,
|
||||
},
|
||||
crypto: {
|
||||
randomBytes: crypto.randomBytes,
|
||||
createHash: crypto.createHash
|
||||
createHash: crypto.createHash,
|
||||
},
|
||||
yaml: {
|
||||
load: yaml.load
|
||||
load: yaml.load,
|
||||
},
|
||||
mime: {
|
||||
lookup: mime.getType
|
||||
lookup: mime.getType,
|
||||
},
|
||||
buffer: {
|
||||
from: Buffer.from
|
||||
}
|
||||
from: Buffer.from,
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
||||
@@ -40,7 +40,7 @@ onMounted(async () => {
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'PicGoApp'
|
||||
name: 'PicGoApp',
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -63,36 +63,36 @@ onBeforeMount(async () => {
|
||||
|
||||
<style scoped>
|
||||
.image-container {
|
||||
height: 100px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.image {
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.loading-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border: 2px solid #e4e7ed;
|
||||
border-top: 2px solid #409eff;
|
||||
border-radius: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ onBeforeMount(async () => {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ async function getUrl() {
|
||||
preSignedUrl.value = await window.electron.triggerRPC<any>(
|
||||
IRPCActionType.MANAGE_GET_PRE_SIGNED_URL,
|
||||
props.alias,
|
||||
props.config
|
||||
props.config,
|
||||
)
|
||||
isLoading.value = false
|
||||
} catch (error) {
|
||||
@@ -79,36 +79,36 @@ onMounted(getUrl)
|
||||
|
||||
<style scoped>
|
||||
.image-container {
|
||||
height: 100px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.image {
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.loading-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border: 2px solid #e4e7ed;
|
||||
border-top: 2px solid #409eff;
|
||||
border-radius: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ onMounted(getUrl)
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@
|
||||
input-type="radio"
|
||||
:radio-options="[
|
||||
{ value: 'text', label: $t('pages.imageProcess.watermark.text') },
|
||||
{ value: 'image', label: $t('pages.imageProcess.watermark.image') }
|
||||
{ value: 'image', label: $t('pages.imageProcess.watermark.image') },
|
||||
]"
|
||||
@map-change="
|
||||
(picbedType, value) => safeSetMapValue(waterMarkForm, 'watermarkType', picbedType, value, 'text')
|
||||
@@ -455,7 +455,7 @@
|
||||
:select-options="
|
||||
Array.from(waterMarkPositionMap.entries()).map(([key, label]) => ({
|
||||
value: key,
|
||||
label
|
||||
label,
|
||||
}))
|
||||
"
|
||||
@map-change="
|
||||
@@ -718,18 +718,18 @@ const tabs = computed(() => [
|
||||
{
|
||||
id: 'general',
|
||||
label: t('pages.imageProcess.generalSettings'),
|
||||
icon: Settings
|
||||
icon: Settings,
|
||||
},
|
||||
{
|
||||
id: 'watermark',
|
||||
label: t('pages.imageProcess.watermarkSettings'),
|
||||
icon: Image
|
||||
icon: Image,
|
||||
},
|
||||
{
|
||||
id: 'transform',
|
||||
label: t('pages.imageProcess.transformSettings'),
|
||||
icon: RotateCw
|
||||
}
|
||||
icon: RotateCw,
|
||||
},
|
||||
])
|
||||
|
||||
const waterMarkPositionMap = new Map([
|
||||
@@ -741,7 +741,7 @@ const waterMarkPositionMap = new Map([
|
||||
['northwest', t('pages.imageProcess.watermark.positionOptions.topLeft')],
|
||||
['west', t('pages.imageProcess.watermark.positionOptions.left')],
|
||||
['east', t('pages.imageProcess.watermark.positionOptions.right')],
|
||||
['centre', t('pages.imageProcess.watermark.positionOptions.center')]
|
||||
['centre', t('pages.imageProcess.watermark.positionOptions.center')],
|
||||
])
|
||||
|
||||
const imageExtList = ['jpg', 'jpeg', 'png', 'webp', 'bmp', 'tiff', 'tif', 'svg', 'ico', 'avif', 'heif', 'heic']
|
||||
@@ -766,7 +766,7 @@ const availableFormat = [
|
||||
'tiff',
|
||||
'tif',
|
||||
'v',
|
||||
'webp'
|
||||
'webp',
|
||||
]
|
||||
|
||||
const waterMarkForm = reactive<IBuildInWaterMarkOptions>({
|
||||
@@ -791,7 +791,7 @@ const waterMarkForm = reactive<IBuildInWaterMarkOptions>({
|
||||
watermarkPosition: 'southeast',
|
||||
watermarkPositionMap: {},
|
||||
watermarkImageOpacity: 255,
|
||||
watermarkImageOpacityMap: {}
|
||||
watermarkImageOpacityMap: {},
|
||||
})
|
||||
|
||||
const compressForm = reactive<IBuildInCompressOptions>({
|
||||
@@ -824,12 +824,12 @@ const compressForm = reactive<IBuildInCompressOptions>({
|
||||
isFlop: false,
|
||||
isFlopMap: {},
|
||||
formatConvertObj: {},
|
||||
formatConvertObjMap: {}
|
||||
formatConvertObjMap: {},
|
||||
})
|
||||
const formatConvertObj = ref('{}')
|
||||
|
||||
const skipProcessForm = reactive({
|
||||
skipProcessExtList: 'zip,rar,7z,tar,gz,tar.gz,tar.bz2,tar.xz'
|
||||
skipProcessExtList: 'zip,rar,7z,tar,gz,tar.gz,tar.bz2,tar.xz',
|
||||
})
|
||||
|
||||
// State for showing map settings for each field (now unused - kept for future reference)
|
||||
@@ -851,7 +851,7 @@ function handleSaveConfig() {
|
||||
let iformatConvertObj = {}
|
||||
try {
|
||||
iformatConvertObj = JSON.parse(formatConvertObj.value)
|
||||
} catch (error) {}
|
||||
} catch (_error) {}
|
||||
const formatConvertObjEntries = Object.entries(iformatConvertObj)
|
||||
const formatConvertObjEntriesFilter = formatConvertObjEntries.filter((item: any) => {
|
||||
return imageExtList.includes(item[0]) && availableFormat.includes(item[1])
|
||||
@@ -872,7 +872,7 @@ function handleSaveConfig() {
|
||||
if (Object.keys(filteredObj).length > 0) {
|
||||
processedFormatConvertObjMap[picbedType] = filteredObj
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
// Skip invalid JSON strings
|
||||
}
|
||||
})
|
||||
@@ -898,7 +898,7 @@ async function initData() {
|
||||
} else {
|
||||
formatConvertObj.value = compress.formatConvertObj ?? '{}'
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
formatConvertObj.value = '{}'
|
||||
}
|
||||
}
|
||||
@@ -946,11 +946,11 @@ onBeforeMount(async () => {
|
||||
|
||||
<style scoped>
|
||||
.image-process-settings {
|
||||
overflow-y: auto;
|
||||
padding: 1.5rem;
|
||||
min-height: 100vh;
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text-primary);
|
||||
overflow-y: auto;
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
/* Header */
|
||||
@@ -958,12 +958,12 @@ onBeforeMount(async () => {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: var(--color-surface);
|
||||
margin-bottom: 1.5rem;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 12px;
|
||||
padding: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
border: 1px solid var(--color-border);
|
||||
background: var(--color-surface);
|
||||
box-shadow: 0 2px 8px rgb(0 0 0 / 10%);
|
||||
}
|
||||
|
||||
.header-content {
|
||||
@@ -985,8 +985,8 @@ onBeforeMount(async () => {
|
||||
|
||||
.settings-header p {
|
||||
margin: 0;
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
@@ -997,29 +997,29 @@ onBeforeMount(async () => {
|
||||
/* Tab Navigation */
|
||||
.tab-navigation {
|
||||
display: flex;
|
||||
background: var(--color-background-primary);
|
||||
margin-bottom: 1.5rem;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 12px;
|
||||
padding: 0.25rem;
|
||||
margin-bottom: 1.5rem;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
border: 1px solid var(--color-border);
|
||||
background: var(--color-background-primary);
|
||||
box-shadow: 0 2px 8px rgb(0 0 0 / 10%);
|
||||
}
|
||||
|
||||
.tab-button {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
color: var(--color-text-secondary);
|
||||
padding: 0.75rem 1rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
color: var(--color-text-secondary);
|
||||
background: transparent;
|
||||
transition: all 0.2s ease;
|
||||
gap: 0.5rem;
|
||||
cursor: pointer;
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.tab-button:hover {
|
||||
@@ -1028,9 +1028,9 @@ onBeforeMount(async () => {
|
||||
}
|
||||
|
||||
.tab-button.active {
|
||||
background: #409eff;
|
||||
color: white;
|
||||
box-shadow: 0 2px 4px rgba(64, 158, 255, 0.3);
|
||||
background: #409eff;
|
||||
box-shadow: 0 2px 4px rgb(64 158 255 / 30%);
|
||||
}
|
||||
|
||||
/* Settings Content */
|
||||
@@ -1046,24 +1046,24 @@ onBeforeMount(async () => {
|
||||
}
|
||||
|
||||
.settings-section {
|
||||
background: var(--color-background-primary);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 12px;
|
||||
padding: 1.5rem;
|
||||
background: var(--color-background-primary);
|
||||
box-shadow: 0 2px 8px var(--color-border);
|
||||
border: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.settings-section h2 {
|
||||
margin: 0 0 0.5rem 0;
|
||||
margin: 0 0 0.5rem;
|
||||
font-size: 1.125rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
.settings-section p {
|
||||
margin: 0 0 1.5rem 0;
|
||||
color: var(--color-text-secondary);
|
||||
margin: 0 0 1.5rem;
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
/* Form Elements */
|
||||
@@ -1075,7 +1075,7 @@ onBeforeMount(async () => {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.form-group > label:not(.switch-label):not(.radio-option) {
|
||||
.form-group > label:not(.switch-label, .radio-option) {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
@@ -1085,89 +1085,87 @@ onBeforeMount(async () => {
|
||||
|
||||
.form-input,
|
||||
.form-textarea {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
background: var(--color-background-primary);
|
||||
color: var(--color-text-primary);
|
||||
padding: 0.75rem;
|
||||
width: 100%;
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-text-primary);
|
||||
background: var(--color-background-primary);
|
||||
transition: all 0.2s ease;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-input:focus,
|
||||
.form-textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-blue-common);
|
||||
box-shadow: 0 0 0 2px var(--el-color-primary-light-9, rgba(64, 158, 255, 0.2));
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px var(--el-color-primary-light-9, rgb(64 158 255 / 20%));
|
||||
}
|
||||
|
||||
.form-textarea {
|
||||
resize: vertical;
|
||||
min-height: 80px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.form-range {
|
||||
margin-bottom: 0.5rem;
|
||||
border-radius: 3px;
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
border-radius: 3px;
|
||||
background: #e4e7ed;
|
||||
outline: none;
|
||||
margin-bottom: 0.5rem;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.form-range::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
border: 2px solid #ffffff;
|
||||
border-radius: 50%;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-blue-common);
|
||||
box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
border: 2px solid #ffffff;
|
||||
}
|
||||
|
||||
.form-range::-moz-range-thumb {
|
||||
border: 2px solid #ffffff;
|
||||
border-radius: 50%;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-blue-common);
|
||||
box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
|
||||
cursor: pointer;
|
||||
border: 2px solid #ffffff;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.range-value {
|
||||
display: inline-block;
|
||||
padding: 0.25rem 0.5rem;
|
||||
background: var(--color-blue-common);
|
||||
color: white;
|
||||
margin-bottom: 0.5rem;
|
||||
border-radius: 4px;
|
||||
padding: 0.25rem 0.5rem;
|
||||
min-width: 3rem;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
margin-bottom: 0.5rem;
|
||||
min-width: 3rem;
|
||||
text-align: center;
|
||||
color: white;
|
||||
background: var(--color-blue-common);
|
||||
}
|
||||
|
||||
.form-color {
|
||||
width: 60px;
|
||||
height: 40px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 6px;
|
||||
padding: 0;
|
||||
width: 60px;
|
||||
height: 40px;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.form-color:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-blue-common);
|
||||
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px rgb(64 158 255 / 20%);
|
||||
}
|
||||
|
||||
.color-input-group {
|
||||
@@ -1191,13 +1189,13 @@ onBeforeMount(async () => {
|
||||
.switch-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
cursor: pointer;
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s ease;
|
||||
padding: 1rem;
|
||||
background: var(--color-background-primary);
|
||||
transition: all 0.2s ease;
|
||||
gap: 1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.switch-label:hover {
|
||||
@@ -1211,25 +1209,25 @@ onBeforeMount(async () => {
|
||||
|
||||
.switch-slider {
|
||||
position: relative;
|
||||
border-radius: 12px;
|
||||
width: 44px;
|
||||
height: 24px;
|
||||
background: var(--color-border-darker);
|
||||
border-radius: 12px;
|
||||
transition: all 0.3s ease;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.switch-slider::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
border-radius: 50%;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: #ffffff;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
content: '';
|
||||
}
|
||||
|
||||
.switch-input:checked + .switch-slider {
|
||||
@@ -1270,18 +1268,18 @@ onBeforeMount(async () => {
|
||||
.radio-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
cursor: pointer;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 6px;
|
||||
transition: all 0.2s ease;
|
||||
padding: 0.5rem 0.75rem;
|
||||
background: var(--color-background-primary);
|
||||
transition: all 0.2s ease;
|
||||
gap: 0.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.radio-option:hover {
|
||||
border-color: var(--color-blue-common);
|
||||
background: rgba(64, 158, 255, 0.1);
|
||||
background: rgb(64 158 255 / 10%);
|
||||
}
|
||||
|
||||
.radio-input {
|
||||
@@ -1289,13 +1287,13 @@ onBeforeMount(async () => {
|
||||
}
|
||||
|
||||
.radio-indicator {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
position: relative;
|
||||
border: 2px solid var(--color-border);
|
||||
border-radius: 50%;
|
||||
transition: all 0.2s ease;
|
||||
position: relative;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: var(--color-background-primary);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.radio-input:checked + .radio-indicator {
|
||||
@@ -1304,21 +1302,21 @@ onBeforeMount(async () => {
|
||||
}
|
||||
|
||||
.radio-input:checked + .radio-indicator::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
border-radius: 50%;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: var(--color-blue-common);
|
||||
border-radius: 50%;
|
||||
content: '';
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.radio-label {
|
||||
font-size: 0.875rem;
|
||||
color: var(--color-text-primary);
|
||||
font-weight: 500;
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
/* Position Grid */
|
||||
@@ -1330,74 +1328,74 @@ onBeforeMount(async () => {
|
||||
}
|
||||
|
||||
.position-button {
|
||||
padding: 0.75rem;
|
||||
background: var(--color-background-primary);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 6px;
|
||||
color: var(--color-text-secondary);
|
||||
padding: 0.75rem;
|
||||
font-size: 0.75rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
text-align: center;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
color: var(--color-text-secondary);
|
||||
background: var(--color-background-primary);
|
||||
transition: all 0.2s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.position-button:hover {
|
||||
border-color: var(--color-blue-common);
|
||||
color: var(--color-text-primary);
|
||||
background: rgba(64, 158, 255, 0.1);
|
||||
background: rgb(64 158 255 / 10%);
|
||||
}
|
||||
|
||||
.position-button.active {
|
||||
background: var(--color-blue-common);
|
||||
border-color: var(--color-blue-common);
|
||||
color: white;
|
||||
box-shadow: 0 2px 4px rgba(64, 158, 255, 0.3);
|
||||
background: var(--color-blue-common);
|
||||
box-shadow: 0 2px 4px rgb(64 158 255 / 30%);
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 6px;
|
||||
background: var(--color-background-primary);
|
||||
color: var(--color-text-primary);
|
||||
padding: 0.75rem 1rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
text-decoration: none;
|
||||
color: var(--color-text-primary);
|
||||
background: var(--color-background-primary);
|
||||
transition: all 0.2s ease;
|
||||
gap: 0.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: var(--color-background-secondary);
|
||||
border-color: var(--color-blue-common);
|
||||
background: var(--color-background-secondary);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--color-blue-common);
|
||||
border-color: var(--color-blue-common);
|
||||
color: white;
|
||||
background: var(--color-blue-common);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: var(--color-primary);
|
||||
border-color: var(--color-primary);
|
||||
background: var(--color-primary);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: var(--color-background-primary);
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-text-secondary);
|
||||
background: var(--color-background-primary);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: var(--color-background-secondary);
|
||||
border-color: var(--color-border-secondary);
|
||||
color: var(--color-text-primary);
|
||||
background: var(--color-background-secondary);
|
||||
}
|
||||
|
||||
/* Small text */
|
||||
@@ -1413,12 +1411,12 @@ small {
|
||||
.watermark-settings,
|
||||
.resize-settings {
|
||||
margin-top: 1rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid var(--color-border-secondary);
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
/* Responsive Design */
|
||||
@media (max-width: 768px) {
|
||||
@media (width <= 768px) {
|
||||
.image-process-settings {
|
||||
padding: 1rem;
|
||||
}
|
||||
@@ -1468,17 +1466,17 @@ small {
|
||||
:root.auto.dark .settings-header,
|
||||
:root.auto.dark .tab-navigation,
|
||||
:root.auto.dark .settings-section {
|
||||
background: var(--color-background-tertiary);
|
||||
border-color: var(--color-border);
|
||||
background: var(--color-background-tertiary);
|
||||
}
|
||||
|
||||
:root.dark .form-input,
|
||||
:root.dark .form-textarea,
|
||||
:root.auto.dark .form-input,
|
||||
:root.auto.dark .form-textarea {
|
||||
background: var(--color-surface);
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-text-primary);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
:root.dark .switch-slider::before,
|
||||
@@ -1488,24 +1486,25 @@ small {
|
||||
|
||||
:root.dark .btn-secondary,
|
||||
:root.auto.dark .btn-secondary {
|
||||
background: var(--color-surface);
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-text-secondary);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
:root.dark .btn-secondary:hover,
|
||||
:root.auto.dark .btn-secondary:hover {
|
||||
background: var(--color-background-tertiary);
|
||||
border-color: var(--color-border-hover);
|
||||
color: var(--color-text-primary);
|
||||
background: var(--color-background-tertiary);
|
||||
}
|
||||
|
||||
:root.dark .switch-label,
|
||||
:root.auto.dark .switch-label {
|
||||
background: var(--color-surface);
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-text-secondary);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
:root.dark .switch-title,
|
||||
:root.auto.dark .switch-title {
|
||||
color: var(--color-text-primary);
|
||||
@@ -1518,9 +1517,9 @@ small {
|
||||
|
||||
:root.dark .position-button,
|
||||
:root.auto.dark .position-button {
|
||||
background: var(--color-surface);
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-text-secondary);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
:root.dark .position-button:hover,
|
||||
@@ -1532,15 +1531,15 @@ small {
|
||||
|
||||
:root.dark .position-button.active,
|
||||
:root.auto.dark .position-button.active {
|
||||
background: var(--color-primary);
|
||||
border-color: var(--color-primary);
|
||||
color: var(--color-text-inverse);
|
||||
background: var(--color-primary);
|
||||
}
|
||||
|
||||
:root.dark .radio-group,
|
||||
:root.auto.dark .radio-group {
|
||||
background: var(--color-background-tertiary);
|
||||
border-color: var(--color-border);
|
||||
color: var(--color-text-secondary);
|
||||
background: var(--color-background-tertiary);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -54,15 +54,15 @@ async function getWebdavHeader(key: string) {
|
||||
formatEndpoint(props.config.endpoint, props.config.sslEnabled || false),
|
||||
`/${key.replace(/^\//, '')}`,
|
||||
props.config.username,
|
||||
props.config.password
|
||||
props.config.password,
|
||||
)
|
||||
headers = {
|
||||
Authorization: authHeader
|
||||
Authorization: authHeader,
|
||||
}
|
||||
} else {
|
||||
headers = {
|
||||
Authorization:
|
||||
'Basic ' + window.node.buffer.from(`${props.config.username}:${props.config.password}`).toString('base64')
|
||||
'Basic ' + window.node.buffer.from(`${props.config.username}:${props.config.password}`).toString('base64'),
|
||||
}
|
||||
}
|
||||
return headers
|
||||
@@ -107,36 +107,36 @@ onMounted(fetchImage)
|
||||
|
||||
<style scoped>
|
||||
.image-container {
|
||||
height: 100px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.image {
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.loading-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border: 2px solid #e4e7ed;
|
||||
border-top: 2px solid #409eff;
|
||||
border-radius: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ onMounted(fetchImage)
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ const showInputBoxVisible = ref(false)
|
||||
const inputBoxOptions = reactive({
|
||||
title: '',
|
||||
placeholder: '',
|
||||
multiLine: false
|
||||
multiLine: false,
|
||||
})
|
||||
|
||||
let removeInputBoxListenerCallback: () => void = () => {}
|
||||
@@ -101,54 +101,51 @@ onBeforeUnmount(() => {
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'InputBoxDialog'
|
||||
name: 'InputBoxDialog',
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.inputbox-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
inset: 0;
|
||||
z-index: 2000;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: rgb(0 0 0 / 50%);
|
||||
}
|
||||
|
||||
.inputbox-container {
|
||||
background: white;
|
||||
border-radius: 0.75rem;
|
||||
box-shadow:
|
||||
0 20px 25px -5px rgba(0, 0, 0, 0.1),
|
||||
0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
||||
max-width: 32rem;
|
||||
width: 90%;
|
||||
max-height: 80vh;
|
||||
overflow: hidden;
|
||||
border-radius: 0.75rem;
|
||||
width: 90%;
|
||||
max-width: 32rem;
|
||||
max-height: 80vh;
|
||||
background: white;
|
||||
box-shadow:
|
||||
0 20px 25px -5px rgb(0 0 0 / 10%),
|
||||
0 10px 10px -5px rgb(0 0 0 / 4%);
|
||||
}
|
||||
|
||||
:root.dark .inputbox-container,
|
||||
:root.auto.dark .inputbox-container {
|
||||
background: rgb(31 41 55);
|
||||
border: 1px solid rgb(55 65 81);
|
||||
background: rgb(31 41 55);
|
||||
}
|
||||
|
||||
.inputbox-header {
|
||||
padding: 1.5rem 1.5rem 0 1.5rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1.5rem 1.5rem 0;
|
||||
}
|
||||
|
||||
.inputbox-title {
|
||||
margin: 0;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: rgb(17 24 39);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:root.dark .inputbox-title,
|
||||
@@ -157,22 +154,22 @@ export default {
|
||||
}
|
||||
|
||||
.inputbox-close {
|
||||
background: none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border: none;
|
||||
color: rgb(107 114 128);
|
||||
cursor: pointer;
|
||||
border-radius: 0.25rem;
|
||||
padding: 0.25rem;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 0.25rem;
|
||||
color: rgb(107 114 128);
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.inputbox-close:hover {
|
||||
background: rgb(243 244 246);
|
||||
color: rgb(17 24 39);
|
||||
background: rgb(243 244 246);
|
||||
}
|
||||
|
||||
:root.dark .inputbox-close,
|
||||
@@ -182,8 +179,8 @@ export default {
|
||||
|
||||
:root.dark .inputbox-close:hover,
|
||||
:root.auto.dark .inputbox-close:hover {
|
||||
background: rgb(55 65 81);
|
||||
color: rgb(243 244 246);
|
||||
background: rgb(55 65 81);
|
||||
}
|
||||
|
||||
.inputbox-content {
|
||||
@@ -191,21 +188,21 @@ export default {
|
||||
}
|
||||
|
||||
.inputbox-input {
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid rgb(209 213 219);
|
||||
border-radius: 0.5rem;
|
||||
background: white;
|
||||
color: rgb(17 24 39);
|
||||
padding: 0.75rem 1rem;
|
||||
width: 100%;
|
||||
font-size: 0.875rem;
|
||||
font-family: inherit;
|
||||
transition: all 0.2s ease;
|
||||
color: rgb(17 24 39);
|
||||
background: white;
|
||||
outline: none;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.inputbox-input:focus {
|
||||
border-color: rgb(59 130 246);
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
||||
box-shadow: 0 0 0 3px rgb(59 130 246 / 10%);
|
||||
}
|
||||
|
||||
.inputbox-input::placeholder {
|
||||
@@ -213,23 +210,23 @@ export default {
|
||||
}
|
||||
|
||||
.inputbox-textarea {
|
||||
width: 100%;
|
||||
border: 1px solid rgb(209 213 219);
|
||||
border-radius: 0.375rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
background: white;
|
||||
color: rgb(17 24 39);
|
||||
width: 100%;
|
||||
min-height: 4rem;
|
||||
font-size: 0.875rem;
|
||||
font-family: inherit;
|
||||
transition: all 0.2s ease;
|
||||
color: rgb(17 24 39);
|
||||
background: white;
|
||||
outline: none;
|
||||
resize: vertical;
|
||||
min-height: 4rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.inputbox-textarea:focus {
|
||||
border-color: rgb(59 130 246);
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
||||
box-shadow: 0 0 0 3px rgb(59 130 246 / 10%);
|
||||
}
|
||||
|
||||
.inputbox-textarea::placeholder {
|
||||
@@ -238,15 +235,15 @@ export default {
|
||||
|
||||
:root.dark .inputbox-input,
|
||||
:root.auto.dark .inputbox-input {
|
||||
background: rgb(55 65 81);
|
||||
border-color: rgb(75 85 99);
|
||||
color: rgb(243 244 246);
|
||||
background: rgb(55 65 81);
|
||||
}
|
||||
|
||||
:root.dark .inputbox-input:focus,
|
||||
:root.auto.dark .inputbox-input:focus {
|
||||
border-color: rgb(59 130 246);
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
||||
box-shadow: 0 0 0 3px rgb(59 130 246 / 10%);
|
||||
}
|
||||
|
||||
:root.dark .inputbox-input::placeholder,
|
||||
@@ -256,15 +253,15 @@ export default {
|
||||
|
||||
:root.dark .inputbox-textarea,
|
||||
:root.auto.dark .inputbox-textarea {
|
||||
background: rgb(55 65 81);
|
||||
border-color: rgb(75 85 99);
|
||||
color: rgb(243 244 246);
|
||||
background: rgb(55 65 81);
|
||||
}
|
||||
|
||||
:root.dark .inputbox-textarea:focus,
|
||||
:root.auto.dark .inputbox-textarea:focus {
|
||||
border-color: rgb(59 130 246);
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
||||
box-shadow: 0 0 0 3px rgb(59 130 246 / 10%);
|
||||
}
|
||||
|
||||
:root.dark .inputbox-textarea::placeholder,
|
||||
@@ -274,25 +271,25 @@ export default {
|
||||
|
||||
.inputbox-actions {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
padding: 0 1.5rem 1.5rem 1.5rem;
|
||||
justify-content: flex-end;
|
||||
padding: 0 1.5rem 1.5rem;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.inputbox-btn {
|
||||
padding: 0.5rem 1rem;
|
||||
border: none;
|
||||
border-radius: 0.375rem;
|
||||
padding: 0.5rem 1rem;
|
||||
min-width: 4rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
min-width: 4rem;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
background: rgb(243 244 246);
|
||||
color: rgb(75 85 99);
|
||||
border: 1px solid rgb(209 213 219);
|
||||
color: rgb(75 85 99);
|
||||
background: rgb(243 244 246);
|
||||
}
|
||||
|
||||
.cancel-btn:hover {
|
||||
@@ -301,9 +298,9 @@ export default {
|
||||
|
||||
:root.dark .cancel-btn,
|
||||
:root.auto.dark .cancel-btn {
|
||||
background: rgb(55 65 81);
|
||||
color: rgb(209 213 219);
|
||||
border-color: rgb(75 85 99);
|
||||
color: rgb(209 213 219);
|
||||
background: rgb(55 65 81);
|
||||
}
|
||||
|
||||
:root.dark .cancel-btn:hover,
|
||||
@@ -312,8 +309,8 @@ export default {
|
||||
}
|
||||
|
||||
.confirm-btn.primary {
|
||||
background: rgb(59 130 246);
|
||||
color: white;
|
||||
background: rgb(59 130 246);
|
||||
}
|
||||
|
||||
.confirm-btn.primary:hover {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user