diff --git a/electron-builder.yml b/electron-builder.yml
index c0dfc87..a465508 100644
--- a/electron-builder.yml
+++ b/electron-builder.yml
@@ -12,6 +12,7 @@ asarUnpack:
- resources/**
win:
executableName: lol-assistant
+ requestedExecutionLevel: requireAdministrator
nsis:
artifactName: ${name}-${version}-setup.${ext}
shortcutName: ${productName}
diff --git a/package.json b/package.json
index f975591..c47cfca 100644
--- a/package.json
+++ b/package.json
@@ -9,13 +9,18 @@
"format": "prettier --write .",
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
"start": "electron-vite preview",
- "dev": "electron-vite dev",
+ "dev": "powershell -Command \"Start-Process cmd -ArgumentList '/k', 'cd %cd% && npm run dev:base' -Verb RunAs\"",
+ "dev:base": "electron-vite dev",
"build": "electron-vite build",
"postinstall": "electron-builder install-app-deps",
- "build:unpack": "npm run build && electron-builder --dir",
- "build:win": "npm run build && electron-builder --win",
- "build:mac": "npm run build && electron-builder --mac",
- "build:linux": "npm run build && electron-builder --linux"
+ "build:unpack:base": "npm run build && electron-builder --dir",
+ "build:win:base": "npm run build && electron-builder --win",
+ "build:mac:base": "npm run build && electron-builder --mac",
+ "build:linux:base": "npm run build && electron-builder --linux",
+ "build:unpack": "powershell -Command \"Start-Process cmd -ArgumentList '/k', 'cd %cd% && npm run build:unpack:base' -Verb RunAs\"",
+ "build:win": "powershell -Command \"Start-Process cmd -ArgumentList '/k', 'cd %cd% && npm run build:win:base' -Verb RunAs\"",
+ "build:mac": "powershell -Command \"Start-Process cmd -ArgumentList '/k', 'cd %cd% && npm run build:mac:base' -Verb RunAs\"",
+ "build:linux": "powershell -Command \"Start-Process cmd -ArgumentList '/k', 'cd %cd% && npm run build:linux:base' -Verb RunAs\""
},
"dependencies": {
"@electron-toolkit/preload": "^3.0.1",
diff --git a/src/main/index.js b/src/main/index.js
index da9e3d0..10b5cda 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -2,6 +2,47 @@ import { app, shell, BrowserWindow, ipcMain } from 'electron'
import { join } from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset'
+import { exec } from 'child_process'
+
+const getBaseConfig = () => {
+ return new Promise((resolve) =>
+ exec(
+ "chcp 936 && WMIC PROCESS WHERE name='LeagueClientUx.exe' GET commandline",
+ (error, stdout, stderr) => {
+ if (error) {
+ resolve({
+ Auth: '',
+ BASE_URL: ''
+ })
+ return
+ }
+ if (stderr) {
+ resolve({
+ Auth: '',
+ BASE_URL: ''
+ })
+ return
+ }
+ 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.
@@ -42,6 +83,7 @@ app.whenReady().then(() => {
// Set app user model id for windows
electronApp.setAppUserModelId('com.electron')
+ ipcMain.handle('getBaseConfig', getBaseConfig)
// 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
@@ -49,9 +91,6 @@ app.whenReady().then(() => {
optimizer.watchWindowShortcuts(window)
})
- // IPC test
- ipcMain.on('ping', () => console.log('pong'))
-
createWindow()
app.on('activate', function () {
diff --git a/src/preload/index.js b/src/preload/index.js
index 8d62cb9..7b4aca7 100644
--- a/src/preload/index.js
+++ b/src/preload/index.js
@@ -1,4 +1,4 @@
-import { contextBridge } from 'electron'
+import { contextBridge, ipcRenderer } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
// Custom APIs for renderer
@@ -11,10 +11,16 @@ if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('electron', electronAPI)
contextBridge.exposeInMainWorld('api', api)
+ contextBridge.exposeInMainWorld('electronAPI', {
+ getBaseConfig: () => ipcRenderer.invoke('getBaseConfig')
+ })
} catch (error) {
console.error(error)
}
} else {
window.electron = electronAPI
window.api = api
+ window.electronAPI = {
+ getBaseConfig: () => ipcRenderer.invoke('getBaseConfig')
+ }
}
diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue
index 3988215..c9e1da6 100644
--- a/src/renderer/src/App.vue
+++ b/src/renderer/src/App.vue
@@ -1,7 +1,24 @@