mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-03-13 08:28:13 -04:00
parent
c4aadfbd66
commit
8962a46e85
@ -25,6 +25,7 @@ NO_MORE_NOTICE: No More Notice
|
|||||||
SHOW_DEVTOOLS: Show Devtools
|
SHOW_DEVTOOLS: Show Devtools
|
||||||
FEEDBACK: Feedback
|
FEEDBACK: Feedback
|
||||||
CURRENT_PICBED: Current Picbed
|
CURRENT_PICBED: Current Picbed
|
||||||
|
CURRENT_SECOND_PICBED: Current Second Picbed
|
||||||
START_WATCH_CLIPBOARD: Start Watch Clipboard
|
START_WATCH_CLIPBOARD: Start Watch Clipboard
|
||||||
STOP_WATCH_CLIPBOARD: Stop Watch Clipboard
|
STOP_WATCH_CLIPBOARD: Stop Watch Clipboard
|
||||||
OPEN_TOOLBOX: Open Toolbox
|
OPEN_TOOLBOX: Open Toolbox
|
||||||
@ -183,6 +184,8 @@ SETTINGS_TIMESTAMP_RENAME: Timestamp Rename
|
|||||||
SETTINGS_ADVANCED_RENAME: Advanced Rename
|
SETTINGS_ADVANCED_RENAME: Advanced Rename
|
||||||
SETTINGS_ADVANCED_RENAME_ENABLE: Enable Advanced Rename
|
SETTINGS_ADVANCED_RENAME_ENABLE: Enable Advanced Rename
|
||||||
SETTINGS_ADVANCED_RENAME_FORMAT: Advanced Rename Format
|
SETTINGS_ADVANCED_RENAME_FORMAT: Advanced Rename Format
|
||||||
|
SETTINGS_ENABLE_SECOND_PICBED: Enable Second Picbed
|
||||||
|
SETTINGS_SET_SECOND_PICBED: Set Second Picbed
|
||||||
SETTINGS_OPEN_UPLOAD_TIPS: Open Upload Tips
|
SETTINGS_OPEN_UPLOAD_TIPS: Open Upload Tips
|
||||||
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: Open Upload Result Tips
|
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: Open Upload Result Tips
|
||||||
SETTINGS_MINI_WINDOW_ON_TOP: Mini Window On Top
|
SETTINGS_MINI_WINDOW_ON_TOP: Mini Window On Top
|
||||||
|
@ -25,6 +25,7 @@ NO_MORE_NOTICE: 以后不再提醒
|
|||||||
SHOW_DEVTOOLS: 打开开发者工具
|
SHOW_DEVTOOLS: 打开开发者工具
|
||||||
FEEDBACK: 反馈问题
|
FEEDBACK: 反馈问题
|
||||||
CURRENT_PICBED: 当前图床
|
CURRENT_PICBED: 当前图床
|
||||||
|
CURRENT_SECOND_PICBED: 当前第二图床
|
||||||
START_WATCH_CLIPBOARD: 开始监听剪贴板
|
START_WATCH_CLIPBOARD: 开始监听剪贴板
|
||||||
STOP_WATCH_CLIPBOARD: 停止监听剪贴板
|
STOP_WATCH_CLIPBOARD: 停止监听剪贴板
|
||||||
OPEN_TOOLBOX: 打开修复工具箱
|
OPEN_TOOLBOX: 打开修复工具箱
|
||||||
@ -185,6 +186,8 @@ SETTINGS_TIMESTAMP_RENAME: 时间戳重命名
|
|||||||
SETTINGS_ADVANCED_RENAME: 高级重命名
|
SETTINGS_ADVANCED_RENAME: 高级重命名
|
||||||
SETTINGS_ADVANCED_RENAME_ENABLE: 开启高级重命名
|
SETTINGS_ADVANCED_RENAME_ENABLE: 开启高级重命名
|
||||||
SETTINGS_ADVANCED_RENAME_FORMAT: 重命名格式
|
SETTINGS_ADVANCED_RENAME_FORMAT: 重命名格式
|
||||||
|
SETTINGS_ENABLE_SECOND_PICBED: 启用第二图床同步上传
|
||||||
|
SETTINGS_SET_SECOND_PICBED: 设置第二图床
|
||||||
SETTINGS_OPEN_UPLOAD_TIPS: 开启上传进度提示
|
SETTINGS_OPEN_UPLOAD_TIPS: 开启上传进度提示
|
||||||
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: 开启上传结果提示
|
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: 开启上传结果提示
|
||||||
SETTINGS_MINI_WINDOW_ON_TOP: Mini窗口置顶
|
SETTINGS_MINI_WINDOW_ON_TOP: Mini窗口置顶
|
||||||
|
@ -25,6 +25,7 @@ NO_MORE_NOTICE: 以後不再提醒
|
|||||||
SHOW_DEVTOOLS: 開啟開發者工具
|
SHOW_DEVTOOLS: 開啟開發者工具
|
||||||
FEEDBACK: 問題反饋
|
FEEDBACK: 問題反饋
|
||||||
CURRENT_PICBED: 當前圖床
|
CURRENT_PICBED: 當前圖床
|
||||||
|
CURRENT_SECOND_PICBED: 當前第二圖床
|
||||||
START_WATCH_CLIPBOARD: 開始監聽剪貼簿
|
START_WATCH_CLIPBOARD: 開始監聽剪貼簿
|
||||||
STOP_WATCH_CLIPBOARD: 停止監聽剪貼簿
|
STOP_WATCH_CLIPBOARD: 停止監聽剪貼簿
|
||||||
OPEN_TOOLBOX: 開啟修復工具箱
|
OPEN_TOOLBOX: 開啟修復工具箱
|
||||||
@ -183,6 +184,8 @@ SETTINGS_TIMESTAMP_RENAME: 以時間戳命名
|
|||||||
SETTINGS_ADVANCED_RENAME: 高級命名
|
SETTINGS_ADVANCED_RENAME: 高級命名
|
||||||
SETTINGS_ADVANCED_RENAME_ENABLE: 啟用高級命名
|
SETTINGS_ADVANCED_RENAME_ENABLE: 啟用高級命名
|
||||||
SETTINGS_ADVANCED_RENAME_FORMAT: 高級命名格式
|
SETTINGS_ADVANCED_RENAME_FORMAT: 高級命名格式
|
||||||
|
SETTINGS_ENABLE_SECOND_PICBED: 啟用第二圖床同步上傳
|
||||||
|
SETTINGS_SET_SECOND_PICBED: 設定第二圖床
|
||||||
SETTINGS_OPEN_UPLOAD_TIPS: 開啟上傳提示
|
SETTINGS_OPEN_UPLOAD_TIPS: 開啟上傳提示
|
||||||
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: 開啟上傳結果提示
|
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: 開啟上傳結果提示
|
||||||
SETTINGS_MINI_WINDOW_ON_TOP: Mini視窗置頂
|
SETTINGS_MINI_WINDOW_ON_TOP: Mini視窗置頂
|
||||||
|
@ -16,7 +16,7 @@ import db, { GalleryDB } from '@core/datastore'
|
|||||||
import picgo from '@core/picgo'
|
import picgo from '@core/picgo'
|
||||||
|
|
||||||
import uploader from 'apis/app/uploader'
|
import uploader from 'apis/app/uploader'
|
||||||
import { uploadClipboardFiles } from 'apis/app/uploader/apis'
|
import { handleSecondaryUpload, uploadClipboardFiles } from 'apis/app/uploader/apis'
|
||||||
import windowManager from 'apis/app/window/windowManager'
|
import windowManager from 'apis/app/window/windowManager'
|
||||||
|
|
||||||
import { buildPicBedListMenu } from '~/events/remotes/menu'
|
import { buildPicBedListMenu } from '~/events/remotes/menu'
|
||||||
@ -309,6 +309,7 @@ export function createTray(tooltip: string) {
|
|||||||
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
|
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
|
||||||
const rawInput = cloneDeep(files)
|
const rawInput = cloneDeep(files)
|
||||||
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
|
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
|
||||||
|
await handleSecondaryUpload(trayWindow.webContents, files, 'tray')
|
||||||
const imgs = await uploader.setWebContents(trayWindow.webContents).upload(files)
|
const imgs = await uploader.setWebContents(trayWindow.webContents).upload(files)
|
||||||
const deleteLocalFile = db.get(configPaths.settings.deleteLocalFile) || false
|
const deleteLocalFile = db.get(configPaths.settings.deleteLocalFile) || false
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
|
@ -14,6 +14,7 @@ import pasteTemplate from '~/utils/pasteTemplate'
|
|||||||
|
|
||||||
import { IPasteStyle, IWindowList } from '#/types/enum'
|
import { IPasteStyle, IWindowList } from '#/types/enum'
|
||||||
import { configPaths } from '#/utils/configPaths'
|
import { configPaths } from '#/utils/configPaths'
|
||||||
|
import { changeCurrentUploader } from '~/utils/handleUploaderConfig'
|
||||||
|
|
||||||
const handleClipboardUploading = async (): Promise<false | ImgInfo[]> => {
|
const handleClipboardUploading = async (): Promise<false | ImgInfo[]> => {
|
||||||
const useBuiltinClipboard =
|
const useBuiltinClipboard =
|
||||||
@ -28,6 +29,7 @@ const handleClipboardUploading = async (): Promise<false | ImgInfo[]> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
||||||
|
await handleSecondaryUpload(undefined, undefined, 'clipboard')
|
||||||
const img = await handleClipboardUploading()
|
const img = await handleClipboardUploading()
|
||||||
if (img !== false) {
|
if (img !== false) {
|
||||||
if (img.length > 0) {
|
if (img.length > 0) {
|
||||||
@ -84,6 +86,7 @@ export const uploadChoosedFiles = async (
|
|||||||
): Promise<IStringKeyMap[]> => {
|
): Promise<IStringKeyMap[]> => {
|
||||||
const input = files.map(item => item.path)
|
const input = files.map(item => item.path)
|
||||||
const rawInput = cloneDeep(input)
|
const rawInput = cloneDeep(input)
|
||||||
|
await handleSecondaryUpload(webContents, input)
|
||||||
const imgs = await uploader.setWebContents(webContents).upload(input)
|
const imgs = await uploader.setWebContents(webContents).upload(input)
|
||||||
const result = []
|
const result = []
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
@ -132,3 +135,65 @@ export const uploadChoosedFiles = async (
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const handleSecondaryUpload = async (
|
||||||
|
webContents?: WebContents,
|
||||||
|
input?: string[],
|
||||||
|
uploadType: 'clipboard' | 'file' | 'tray' = 'file'
|
||||||
|
): Promise<void> => {
|
||||||
|
const enableSecondUploader = db.get(configPaths.settings.enableSecondUploader) || false
|
||||||
|
let currentPicBedType = ''
|
||||||
|
let currentPicBedConfig = {} as IStringKeyMap
|
||||||
|
let currentPicBedConfigId = ''
|
||||||
|
let needRestore = false
|
||||||
|
if (enableSecondUploader) {
|
||||||
|
const secondUploader = db.get(configPaths.picBed.secondUploader)
|
||||||
|
const secondUploaderConfig = db.get(configPaths.picBed.secondUploaderConfig)
|
||||||
|
const secondUploaderId = db.get(configPaths.picBed.secondUploaderId)
|
||||||
|
const currentPicBed = db.get('picBed') || ({} as IStringKeyMap)
|
||||||
|
currentPicBedType = currentPicBed.uploader || currentPicBed.current || 'smms'
|
||||||
|
currentPicBedConfig = currentPicBed[currentPicBedType] || ({} as IStringKeyMap)
|
||||||
|
currentPicBedConfigId = currentPicBedConfig._id
|
||||||
|
if (
|
||||||
|
secondUploader === currentPicBedType &&
|
||||||
|
secondUploaderConfig._configName === currentPicBedConfig._configName &&
|
||||||
|
secondUploaderId === currentPicBedConfigId
|
||||||
|
) {
|
||||||
|
picgo.log.info('second uploader is the same as current uploader')
|
||||||
|
} else {
|
||||||
|
needRestore = true
|
||||||
|
let secondImgs: ImgInfo[] | false = false
|
||||||
|
changeCurrentUploader(secondUploader, secondUploaderConfig, secondUploaderId)
|
||||||
|
if (uploadType === 'clipboard') {
|
||||||
|
secondImgs = await handleClipboardUploading()
|
||||||
|
} else {
|
||||||
|
secondImgs = await uploader.setWebContents(webContents!).upload(input)
|
||||||
|
}
|
||||||
|
if (secondImgs !== false) {
|
||||||
|
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)
|
||||||
|
if (uploadType === 'clipboard') {
|
||||||
|
if (secondImgs.length > 0) {
|
||||||
|
await GalleryDB.getInstance().insert(secondImgs[0])
|
||||||
|
trayWindow?.webContents?.send('clipboardFiles', [])
|
||||||
|
trayWindow?.webContents?.send('uploadFiles', secondImgs)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < secondImgs.length; i++) {
|
||||||
|
await GalleryDB.getInstance().insert(secondImgs[i])
|
||||||
|
}
|
||||||
|
if (uploadType === 'tray') {
|
||||||
|
trayWindow?.webContents?.send('dragFiles', secondImgs)
|
||||||
|
} else {
|
||||||
|
trayWindow?.webContents?.send('uploadFiles', secondImgs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (windowManager.has(IWindowList.SETTING_WINDOW) && uploadType !== 'tray') {
|
||||||
|
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needRestore) {
|
||||||
|
changeCurrentUploader(currentPicBedType, currentPicBedConfig, currentPicBedConfigId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@ import pasteTemplate from '~/utils/pasteTemplate'
|
|||||||
import { SHOW_INPUT_BOX } from '#/events/constants'
|
import { SHOW_INPUT_BOX } from '#/events/constants'
|
||||||
import { IPasteStyle } from '#/types/enum'
|
import { IPasteStyle } from '#/types/enum'
|
||||||
import { configPaths } from '#/utils/configPaths'
|
import { configPaths } from '#/utils/configPaths'
|
||||||
|
import { handleSecondaryUpload } from '../app/uploader/apis'
|
||||||
|
|
||||||
// Cross-process support may be required in the future
|
// Cross-process support may be required in the future
|
||||||
class GuiApi implements IGuiApi {
|
class GuiApi implements IGuiApi {
|
||||||
@ -78,6 +79,7 @@ class GuiApi implements IGuiApi {
|
|||||||
this.windowId = await getWindowId()
|
this.windowId = await getWindowId()
|
||||||
const webContents = this.getWebcontentsByWindowId(this.windowId)
|
const webContents = this.getWebcontentsByWindowId(this.windowId)
|
||||||
const rawInput = cloneDeep(input)
|
const rawInput = cloneDeep(input)
|
||||||
|
await handleSecondaryUpload(webContents!, input)
|
||||||
const imgs = await uploader.setWebContents(webContents!).upload(input)
|
const imgs = await uploader.setWebContents(webContents!).upload(input)
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
|
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
|
||||||
|
@ -13,7 +13,7 @@ import { T } from '~/i18n'
|
|||||||
import clipboardPoll from '~/utils/clipboardPoll'
|
import clipboardPoll from '~/utils/clipboardPoll'
|
||||||
import { setTrayToolTip } from '~/utils/common'
|
import { setTrayToolTip } from '~/utils/common'
|
||||||
import getPicBeds from '~/utils/getPicBeds'
|
import getPicBeds from '~/utils/getPicBeds'
|
||||||
import { changeCurrentUploader } from '~/utils/handleUploaderConfig'
|
import { changeCurrentUploader, changeSecondUploader } from '~/utils/handleUploaderConfig'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
PICGO_CONFIG_PLUGIN,
|
PICGO_CONFIG_PLUGIN,
|
||||||
@ -139,6 +139,59 @@ const buildMainPageMenu = (win: BrowserWindow) => {
|
|||||||
return Menu.buildFromTemplate(template)
|
return Menu.buildFromTemplate(template)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const buildSecondPicBedMenu = () => {
|
||||||
|
const picBeds = getPicBeds()
|
||||||
|
const secondUploader = picgo.getConfig(configPaths.picBed.secondUploader)
|
||||||
|
const defaultSecondUploaderId = picgo.getConfig(configPaths.picBed.secondUploaderId)
|
||||||
|
const currentPicBedName = picBeds.find(item => item.type === secondUploader)?.name
|
||||||
|
const picBedConfigList = picgo.getConfig<IUploaderConfig>('uploader')
|
||||||
|
const currentPicBedMenuItem = [
|
||||||
|
{
|
||||||
|
label: `${T('CURRENT_SECOND_PICBED')} - ${currentPicBedName || 'None'}`,
|
||||||
|
enabled: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'separator'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
let submenu = picBeds
|
||||||
|
.filter(item => item.visible)
|
||||||
|
.map(item => {
|
||||||
|
const configList = picBedConfigList?.[item.type]?.configList
|
||||||
|
const hasSubmenu = !!configList
|
||||||
|
return {
|
||||||
|
label: item.name,
|
||||||
|
type: !hasSubmenu ? 'checkbox' : undefined,
|
||||||
|
checked: !hasSubmenu ? secondUploader === item.type : undefined,
|
||||||
|
submenu: hasSubmenu
|
||||||
|
? configList.map(config => {
|
||||||
|
return {
|
||||||
|
label: config._configName || 'Default',
|
||||||
|
// if only one config, use checkbox, or radio will checked as default
|
||||||
|
// see: https://github.com/electron/electron/issues/21292
|
||||||
|
type: 'checkbox',
|
||||||
|
checked: config._id === defaultSecondUploaderId && item.type === secondUploader,
|
||||||
|
click: function () {
|
||||||
|
changeSecondUploader(item.type, config, config._id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
: undefined,
|
||||||
|
click: !hasSubmenu
|
||||||
|
? function () {
|
||||||
|
picgo.saveConfig({
|
||||||
|
[configPaths.picBed.secondUploader]: item.type
|
||||||
|
})
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// @ts-expect-error submenu type
|
||||||
|
submenu = currentPicBedMenuItem.concat(submenu)
|
||||||
|
// @ts-expect-error submenu type
|
||||||
|
return Menu.buildFromTemplate(submenu)
|
||||||
|
}
|
||||||
|
|
||||||
const buildPicBedListMenu = () => {
|
const buildPicBedListMenu = () => {
|
||||||
const picBeds = getPicBeds()
|
const picBeds = getPicBeds()
|
||||||
const currentPicBed = picgo.getConfig(configPaths.picBed.uploader)
|
const currentPicBed = picgo.getConfig(configPaths.picBed.uploader)
|
||||||
@ -339,4 +392,4 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
|||||||
return Menu.buildFromTemplate(menu)
|
return Menu.buildFromTemplate(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
export { buildMiniPageMenu, buildMainPageMenu, buildPicBedListMenu, buildPluginPageMenu }
|
export { buildMiniPageMenu, buildMainPageMenu, buildPicBedListMenu, buildPluginPageMenu, buildSecondPicBedMenu }
|
||||||
|
@ -15,17 +15,12 @@ import { manageRouter } from '~/events/rpc/routes/manage'
|
|||||||
import { IRPCActionType, IRPCType } from '#/types/enum'
|
import { IRPCActionType, IRPCType } from '#/types/enum'
|
||||||
import { RPC_ACTIONS, RPC_ACTIONS_INVOKE } from '#/events/constants'
|
import { RPC_ACTIONS, RPC_ACTIONS_INVOKE } from '#/events/constants'
|
||||||
|
|
||||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
|
||||||
|
|
||||||
class RPCServer implements IRPCServer {
|
class RPCServer implements IRPCServer {
|
||||||
private routes: IRPCRoutes = new Map()
|
private routes: IRPCRoutes = new Map()
|
||||||
private routesWithResponse: IRPCRoutes = new Map()
|
private routesWithResponse: IRPCRoutes = new Map()
|
||||||
|
|
||||||
private rpcEventHandler = async (event: IpcMainEvent, action: IRPCActionType, args: any[]) => {
|
private rpcEventHandler = async (event: IpcMainEvent, action: IRPCActionType, args: any[]) => {
|
||||||
try {
|
try {
|
||||||
if (isDevelopment) {
|
|
||||||
console.log(`action: ${action} args: ${JSON.stringify(args)}`)
|
|
||||||
}
|
|
||||||
const route = this.routes.get(action)
|
const route = this.routes.get(action)
|
||||||
await route?.handler?.(event, args)
|
await route?.handler?.(event, args)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@ -35,9 +30,6 @@ class RPCServer implements IRPCServer {
|
|||||||
|
|
||||||
private rpcEventHandlerWithResponse = async (event: IpcMainInvokeEvent, action: IRPCActionType, args: any[]) => {
|
private rpcEventHandlerWithResponse = async (event: IpcMainInvokeEvent, action: IRPCActionType, args: any[]) => {
|
||||||
try {
|
try {
|
||||||
if (isDevelopment) {
|
|
||||||
console.log(`action: ${action} args: ${JSON.stringify(args)}`)
|
|
||||||
}
|
|
||||||
const route = this.routesWithResponse.get(action)
|
const route = this.routesWithResponse.get(action)
|
||||||
return await route?.handler?.(event, args)
|
return await route?.handler?.(event, args)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
@ -2,7 +2,13 @@ import { app, BrowserWindow } from 'electron'
|
|||||||
|
|
||||||
import windowManager from 'apis/app/window/windowManager'
|
import windowManager from 'apis/app/window/windowManager'
|
||||||
|
|
||||||
import { buildMainPageMenu, buildMiniPageMenu, buildPicBedListMenu, buildPluginPageMenu } from '~/events/remotes/menu'
|
import {
|
||||||
|
buildMainPageMenu,
|
||||||
|
buildMiniPageMenu,
|
||||||
|
buildPicBedListMenu,
|
||||||
|
buildPluginPageMenu,
|
||||||
|
buildSecondPicBedMenu
|
||||||
|
} from '~/events/remotes/menu'
|
||||||
import { openMiniWindow } from '~/utils/windowHelper'
|
import { openMiniWindow } from '~/utils/windowHelper'
|
||||||
|
|
||||||
import { IRPCActionType, IWindowList } from '#/types/enum'
|
import { IRPCActionType, IWindowList } from '#/types/enum'
|
||||||
@ -83,6 +89,16 @@ export default [
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
action: IRPCActionType.SHOW_SECOND_UPLOADER_MENU,
|
||||||
|
handler: async () => {
|
||||||
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
|
const menu = buildSecondPicBedMenu()
|
||||||
|
menu.popup({
|
||||||
|
window
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SHOW_PLUGIN_PAGE_MENU,
|
action: IRPCActionType.SHOW_PLUGIN_PAGE_MENU,
|
||||||
handler: async (_: IIPCEvent, args: [plugin: IPicGoPlugin]) => {
|
handler: async (_: IIPCEvent, args: [plugin: IPicGoPlugin]) => {
|
||||||
|
@ -56,6 +56,25 @@ export const getPicBedConfig = (type: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const changeSecondUploader = (type: string, config?: IStringKeyMap, id?: string) => {
|
||||||
|
if (!type) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (id) {
|
||||||
|
picgo.saveConfig({
|
||||||
|
[configPaths.picBed.secondUploaderId]: id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (config) {
|
||||||
|
picgo.saveConfig({
|
||||||
|
[configPaths.picBed.secondUploaderConfig]: config
|
||||||
|
})
|
||||||
|
}
|
||||||
|
picgo.saveConfig({
|
||||||
|
[configPaths.picBed.secondUploader]: type
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const changeCurrentUploader = (type: string, config?: IStringKeyMap, id?: string) => {
|
export const changeCurrentUploader = (type: string, config?: IStringKeyMap, id?: string) => {
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return
|
return
|
||||||
|
@ -215,6 +215,18 @@
|
|||||||
<el-option v-for="item in picBedGlobal" :key="item.type" :label="item.name" :value="item.type" />
|
<el-option v-for="item in picBedGlobal" :key="item.type" :label="item.name" :value="item.type" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item :label="$T('SETTINGS_ENABLE_SECOND_PICBED')">
|
||||||
|
<el-switch
|
||||||
|
v-model="formOfSetting.enableSecondUploader"
|
||||||
|
:active-text="$T('SETTINGS_OPEN')"
|
||||||
|
:inactive-text="$T('SETTINGS_CLOSE')"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$T('SETTINGS_SET_SECOND_PICBED')">
|
||||||
|
<el-button type="primary" round size="small" @click="handleChangeSecondPicBed">
|
||||||
|
{{ $T('SETTINGS_CLICK_TO_SET') }}
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="$T('SETTINGS_SYNC_DELETE_CLOUD')">
|
<el-form-item :label="$T('SETTINGS_SYNC_DELETE_CLOUD')">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="formOfSetting.deleteCloudFile"
|
v-model="formOfSetting.deleteCloudFile"
|
||||||
@ -1048,7 +1060,8 @@ const formOfSetting = ref<ISettingForm>({
|
|||||||
registry: '',
|
registry: '',
|
||||||
proxy: '',
|
proxy: '',
|
||||||
mainWindowWidth: 1200,
|
mainWindowWidth: 1200,
|
||||||
mainWindowHeight: 800
|
mainWindowHeight: 800,
|
||||||
|
enableSecondUploader: false
|
||||||
})
|
})
|
||||||
|
|
||||||
const proxy = ref('')
|
const proxy = ref('')
|
||||||
@ -1080,7 +1093,8 @@ const autoWatchKeys = [
|
|||||||
'proxy',
|
'proxy',
|
||||||
'autoCopy',
|
'autoCopy',
|
||||||
'encodeOutputURL',
|
'encodeOutputURL',
|
||||||
'useShortUrl'
|
'useShortUrl',
|
||||||
|
'enableSecondUploader'
|
||||||
]
|
]
|
||||||
|
|
||||||
const addWatch = () => {
|
const addWatch = () => {
|
||||||
@ -1259,6 +1273,10 @@ function initArray(arrayT: string | string[], defaultValue: string[]) {
|
|||||||
return arrayT
|
return arrayT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleChangeSecondPicBed() {
|
||||||
|
sendRPC(IRPCActionType.SHOW_SECOND_UPLOADER_MENU)
|
||||||
|
}
|
||||||
|
|
||||||
function openFile(file: string) {
|
function openFile(file: string) {
|
||||||
sendRPC(IRPCActionType.PICLIST_OPEN_FILE, file)
|
sendRPC(IRPCActionType.PICLIST_OPEN_FILE, file)
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@ export enum IRPCActionType {
|
|||||||
SHOW_MINI_PAGE_MENU = 'SHOW_MINI_PAGE_MENU',
|
SHOW_MINI_PAGE_MENU = 'SHOW_MINI_PAGE_MENU',
|
||||||
SHOW_MAIN_PAGE_MENU = 'SHOW_MAIN_PAGE_MENU',
|
SHOW_MAIN_PAGE_MENU = 'SHOW_MAIN_PAGE_MENU',
|
||||||
SHOW_UPLOAD_PAGE_MENU = 'SHOW_UPLOAD_PAGE_MENU',
|
SHOW_UPLOAD_PAGE_MENU = 'SHOW_UPLOAD_PAGE_MENU',
|
||||||
|
SHOW_SECOND_UPLOADER_MENU = 'SHOW_SECOND_UPLOADER_MENU',
|
||||||
SHOW_PLUGIN_PAGE_MENU = 'SHOW_PLUGIN_PAGE_MENU',
|
SHOW_PLUGIN_PAGE_MENU = 'SHOW_PLUGIN_PAGE_MENU',
|
||||||
SET_MINI_WINDOW_POS = 'SET_MINI_WINDOW_POS',
|
SET_MINI_WINDOW_POS = 'SET_MINI_WINDOW_POS',
|
||||||
MINI_WINDOW_ON_TOP = 'MINI_WINDOW_ON_TOP',
|
MINI_WINDOW_ON_TOP = 'MINI_WINDOW_ON_TOP',
|
||||||
|
3
src/universal/types/i18n.d.ts
vendored
3
src/universal/types/i18n.d.ts
vendored
@ -26,6 +26,7 @@ interface ILocales {
|
|||||||
SHOW_DEVTOOLS: string
|
SHOW_DEVTOOLS: string
|
||||||
FEEDBACK: string
|
FEEDBACK: string
|
||||||
CURRENT_PICBED: string
|
CURRENT_PICBED: string
|
||||||
|
CURRENT_SECOND_PICBED: string
|
||||||
START_WATCH_CLIPBOARD: string
|
START_WATCH_CLIPBOARD: string
|
||||||
STOP_WATCH_CLIPBOARD: string
|
STOP_WATCH_CLIPBOARD: string
|
||||||
OPEN_TOOLBOX: string
|
OPEN_TOOLBOX: string
|
||||||
@ -178,6 +179,8 @@ interface ILocales {
|
|||||||
SETTINGS_ADVANCED_RENAME: string
|
SETTINGS_ADVANCED_RENAME: string
|
||||||
SETTINGS_ADVANCED_RENAME_ENABLE: string
|
SETTINGS_ADVANCED_RENAME_ENABLE: string
|
||||||
SETTINGS_ADVANCED_RENAME_FORMAT: string
|
SETTINGS_ADVANCED_RENAME_FORMAT: string
|
||||||
|
SETTINGS_ENABLE_SECOND_PICBED: string
|
||||||
|
SETTINGS_SET_SECOND_PICBED: string
|
||||||
SETTINGS_OPEN_UPLOAD_TIPS: string
|
SETTINGS_OPEN_UPLOAD_TIPS: string
|
||||||
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: string
|
SETTINGS_OPEN_UPLOAD_RESULT_TIPS: string
|
||||||
SETTINGS_MINI_WINDOW_ON_TOP: string
|
SETTINGS_MINI_WINDOW_ON_TOP: string
|
||||||
|
1
src/universal/types/view.d.ts
vendored
1
src/universal/types/view.d.ts
vendored
@ -37,6 +37,7 @@ interface ISettingForm {
|
|||||||
proxy: string
|
proxy: string
|
||||||
mainWindowWidth: number
|
mainWindowWidth: number
|
||||||
mainWindowHeight: number
|
mainWindowHeight: number
|
||||||
|
enableSecondUploader: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IShortKeyMap {
|
interface IShortKeyMap {
|
||||||
|
@ -107,6 +107,9 @@ export const configPaths = {
|
|||||||
picBed: {
|
picBed: {
|
||||||
current: 'picBed.current',
|
current: 'picBed.current',
|
||||||
uploader: 'picBed.uploader',
|
uploader: 'picBed.uploader',
|
||||||
|
secondUploader: 'picBed.secondUploader',
|
||||||
|
secondUploaderId: 'picBed.secondUploaderId',
|
||||||
|
secondUploaderConfig: 'picBed.secondUploaderConfig',
|
||||||
proxy: 'picBed.proxy',
|
proxy: 'picBed.proxy',
|
||||||
transformer: 'picBed.transformer',
|
transformer: 'picBed.transformer',
|
||||||
list: 'picBed.list'
|
list: 'picBed.list'
|
||||||
@ -165,7 +168,8 @@ export const configPaths = {
|
|||||||
useBuiltinClipboard: 'settings.useBuiltinClipboard',
|
useBuiltinClipboard: 'settings.useBuiltinClipboard',
|
||||||
autoStart: 'settings.autoStart',
|
autoStart: 'settings.autoStart',
|
||||||
autoImport: 'settings.autoImport',
|
autoImport: 'settings.autoImport',
|
||||||
autoImportPicBed: 'settings.autoImportPicBed'
|
autoImportPicBed: 'settings.autoImportPicBed',
|
||||||
|
enableSecondUploader: 'settings.enableSecondUploader'
|
||||||
},
|
},
|
||||||
needReload: 'needReload',
|
needReload: 'needReload',
|
||||||
picgoPlugins: 'picgoPlugins',
|
picgoPlugins: 'picgoPlugins',
|
||||||
|
Loading…
Reference in New Issue
Block a user