diff --git a/electron-builder.yml b/electron-builder.yml
index a465508..4ea5c5f 100644
--- a/electron-builder.yml
+++ b/electron-builder.yml
@@ -13,6 +13,12 @@ asarUnpack:
win:
executableName: lol-assistant
requestedExecutionLevel: requireAdministrator
+extraResources: [
+ {
+ "from": "./tool.exe",
+ "to": "./tool.exe",
+ },
+]
nsis:
artifactName: ${name}-${version}-setup.${ext}
shortcutName: ${productName}
diff --git a/resources/tool.exe b/resources/tool.exe
new file mode 100644
index 0000000..cd9b9ba
Binary files /dev/null and b/resources/tool.exe differ
diff --git a/src/main/index.js b/src/main/index.js
index 10b5cda..e0cf96a 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -3,6 +3,7 @@ import { join } from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset'
import { exec } from 'child_process'
+import path from 'path'
const getBaseConfig = () => {
return new Promise((resolve) =>
@@ -44,6 +45,74 @@ const getBaseConfig = () => {
)
}
+const getLOLClientWindowInfo = () => {
+ const command = path.join(process.cwd(), '/resources/tool.exe -f getLOLClientWindowPosition')
+ return new Promise((resolve) =>
+ exec(command, (error, stdout, stderr) => {
+ if (error) {
+ console.log('error', error)
+ resolve({
+ ok: true
+ })
+ return
+ }
+ if (stderr) {
+ console.log('stderr', stderr)
+ resolve({
+ ok: true
+ })
+ return
+ }
+ console.log('stdout', stdout)
+ try {
+ const lines = stdout.split('\n')
+ const windowItems = lines[0].split(' ').map(item => parseInt(item, 10));
+ const monitorItems = lines[1].split(' ').map(item => parseInt(item, 10));
+ resolve({
+ ok: true,
+ client: {
+ left: windowItems[0],
+ top: windowItems[1],
+ bottom: windowItems[2],
+ right: windowItems[3],
+ width: windowItems[4],
+ height: windowItems[5]
+ },
+ monitor: {
+ left: monitorItems[0],
+ top: monitorItems[1],
+ bottom: monitorItems[2],
+ right: monitorItems[3],
+ width: monitorItems[4],
+ height: monitorItems[5]
+ }
+ })
+ } catch (_) {
+ resolve({
+ ok: true
+ })
+ }
+
+ // const tokenMatch = stdout.match(/--remoting-auth-token=([^\s"]+)/)
+ // const portMatch = stdout.match(/--app-port=([^\s"]+)/)
+ // const token = tokenMatch?.[1] || ''
+ // const auth = Buffer.from(`riot:${token}`).toString('base64')
+ // const port = portMatch?.[1] || ''
+ // resolve(
+ // token !== ''
+ // ? {
+ // Auth: `Basic ${auth}`,
+ // BASE_URL: `https://127.0.0.1:${port}`
+ // }
+ // : {
+ // Auth: 'Auth required',
+ // BASE_URL: ''
+ // }
+ // )
+ })
+ )
+}
+
function createWindow() {
// Create the browser window.
const mainWindow = new BrowserWindow({
@@ -84,6 +153,7 @@ app.whenReady().then(() => {
electronApp.setAppUserModelId('com.electron')
ipcMain.handle('getBaseConfig', getBaseConfig)
+ ipcMain.handle('getLOLClientWindowInfo', getLOLClientWindowInfo)
// Default open or close DevTools by F12 in development
// and ignore CommandOrControl + R in production.
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
diff --git a/src/preload/index.js b/src/preload/index.js
index 7b4aca7..f7c5fb8 100644
--- a/src/preload/index.js
+++ b/src/preload/index.js
@@ -1,4 +1,4 @@
-import { contextBridge, ipcRenderer } from 'electron'
+import electron, { contextBridge, ipcRenderer } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
// Custom APIs for renderer
@@ -11,9 +11,12 @@ if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('electron', electronAPI)
contextBridge.exposeInMainWorld('api', api)
- contextBridge.exposeInMainWorld('electronAPI', {
+ contextBridge.exposeInMainWorld('baseConfig', {
getBaseConfig: () => ipcRenderer.invoke('getBaseConfig')
})
+ contextBridge.exposeInMainWorld('client', {
+ getLOLClientWindowInfo: () => ipcRenderer.invoke('getLOLClientWindowInfo')
+ })
} catch (error) {
console.error(error)
}
@@ -23,4 +26,7 @@ if (process.contextIsolated) {
window.electronAPI = {
getBaseConfig: () => ipcRenderer.invoke('getBaseConfig')
}
+ window.electronAPI = {
+ getLOLClientWindowInfo: () => ipcRenderer.invoke('getLOLClientWindowInfo')
+ }
}
diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue
index c9e1da6..2cae7f3 100644
--- a/src/renderer/src/App.vue
+++ b/src/renderer/src/App.vue
@@ -1,13 +1,18 @@
@@ -34,7 +39,7 @@ const intervalId = setInterval(async () => {
Documentation