diff --git a/src/main/events/ipcList.ts b/src/main/events/ipcList.ts index 85b7b92..baa28b4 100644 --- a/src/main/events/ipcList.ts +++ b/src/main/events/ipcList.ts @@ -26,7 +26,8 @@ import { OPEN_USER_STORE_FILE, OPEN_URL, RELOAD_APP, - SHOW_PLUGIN_PAGE_MENU + SHOW_PLUGIN_PAGE_MENU, + SET_MINI_WINDOW_POS } from '#/events/constants' import { uploadClipboardFiles, @@ -212,6 +213,10 @@ export default { app.relaunch() app.exit(0) }) + ipcMain.on(SET_MINI_WINDOW_POS, (evt: IpcMainEvent, pos: IMiniWindowPos) => { + const window = BrowserWindow.getFocusedWindow() + window?.setBounds(pos) + }) }, dispose () {} } diff --git a/src/renderer/pages/MiniPage.vue b/src/renderer/pages/MiniPage.vue index 189f508..711f97b 100644 --- a/src/renderer/pages/MiniPage.vue +++ b/src/renderer/pages/MiniPage.vue @@ -22,7 +22,7 @@ import { ipcRenderer, IpcRendererEvent } from 'electron' -import { SHOW_MINI_PAGE_MENU } from '~/universal/events/constants' +import { SHOW_MINI_PAGE_MENU, SET_MINI_WINDOW_POS } from '~/universal/events/constants' @Component({ name: 'mini-page', mixins: [mixin] @@ -118,9 +118,14 @@ export default class extends Vue { e.preventDefault() e.stopPropagation() if (this.dragging) { - // const xLoc = e.screenX - this.wX - // const yLoc = e.screenY - this.wY - // FIXME: drag + const xLoc = e.screenX - this.wX + const yLoc = e.screenY - this.wY + ipcRenderer.send(SET_MINI_WINDOW_POS, { + x: xLoc, + y: yLoc, + width: 64, + height: 64 + }) // remote.BrowserWindow.getFocusedWindow()!.setBounds({ // x: xLoc, // y: yLoc, diff --git a/src/universal/events/constants.ts b/src/universal/events/constants.ts index 7f93a4e..7d3ff17 100644 --- a/src/universal/events/constants.ts +++ b/src/universal/events/constants.ts @@ -27,3 +27,4 @@ export const PICGO_CONFIG_PLUGIN = 'PICGO_CONFIG_PLUGIN' export const PICGO_HANDLE_PLUGIN_ING = 'PICGO_HANDLE_PLUGIN_ING' export const PICGO_TOGGLE_PLUGIN = 'PICGO_TOGGLE_PLUGIN' export const PASTE_TEXT = 'PASTE_TEXT' +export const SET_MINI_WINDOW_POS = 'SET_MINI_WINDOW_POS' diff --git a/src/universal/types/types.d.ts b/src/universal/types/types.d.ts index 93991d3..4cec3b7 100644 --- a/src/universal/types/types.d.ts +++ b/src/universal/types/types.d.ts @@ -326,3 +326,10 @@ interface IStringKeyMap { type ILogArgvType = string | number type ILogArgvTypeWithError = ILogArgvType | Error + +interface IMiniWindowPos { + x: number, + y: number, + height: number, + width: number +}