Compare commits
No commits in common. "gaze" and "master" have entirely different histories.
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,8 +3,7 @@ dist
|
|||||||
out
|
out
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.log*
|
*.log*
|
||||||
package-lock.json
|
|
||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
|
package-lock.json
|
||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
build
|
|
||||||
|
12
build/entitlements.mac.plist
Normal file
12
build/entitlements.mac.plist
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.security.cs.allow-jit</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
BIN
build/icon.icns
Normal file
BIN
build/icon.icns
Normal file
Binary file not shown.
BIN
build/icon.ico
Normal file
BIN
build/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 121 KiB |
BIN
build/icon.png
Normal file
BIN
build/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
@ -12,6 +12,13 @@ asarUnpack:
|
|||||||
- resources/**
|
- resources/**
|
||||||
win:
|
win:
|
||||||
executableName: lol-assistant
|
executableName: lol-assistant
|
||||||
|
requestedExecutionLevel: requireAdministrator
|
||||||
|
extraResources: [
|
||||||
|
{
|
||||||
|
"from": "./tool.exe",
|
||||||
|
"to": "./tool.exe",
|
||||||
|
},
|
||||||
|
]
|
||||||
nsis:
|
nsis:
|
||||||
artifactName: ${name}-${version}-setup.${ext}
|
artifactName: ${name}-${version}-setup.${ext}
|
||||||
shortcutName: ${productName}
|
shortcutName: ${productName}
|
||||||
|
15
package.json
15
package.json
@ -9,13 +9,18 @@
|
|||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
|
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
|
||||||
"start": "electron-vite preview",
|
"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",
|
"build": "electron-vite build",
|
||||||
"postinstall": "electron-builder install-app-deps",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
"build:unpack": "npm run build && electron-builder --dir",
|
"build:unpack:base": "npm run build && electron-builder --dir",
|
||||||
"build:win": "npm run build && electron-builder --win",
|
"build:win:base": "npm run build && electron-builder --win",
|
||||||
"build:mac": "npm run build && electron-builder --mac",
|
"build:mac:base": "npm run build && electron-builder --mac",
|
||||||
"build:linux": "npm run build && electron-builder --linux"
|
"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": {
|
"dependencies": {
|
||||||
"@electron-toolkit/preload": "^3.0.1",
|
"@electron-toolkit/preload": "^3.0.1",
|
||||||
|
BIN
resources/tool.exe
Normal file
BIN
resources/tool.exe
Normal file
Binary file not shown.
@ -2,6 +2,116 @@ import { app, shell, BrowserWindow, ipcMain } from 'electron'
|
|||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||||
import icon from '../../resources/icon.png?asset'
|
import icon from '../../resources/icon.png?asset'
|
||||||
|
import { exec } from 'child_process'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
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: ''
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
function createWindow() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
@ -42,6 +152,8 @@ app.whenReady().then(() => {
|
|||||||
// Set app user model id for windows
|
// Set app user model id for windows
|
||||||
electronApp.setAppUserModelId('com.electron')
|
electronApp.setAppUserModelId('com.electron')
|
||||||
|
|
||||||
|
ipcMain.handle('getBaseConfig', getBaseConfig)
|
||||||
|
ipcMain.handle('getLOLClientWindowInfo', getLOLClientWindowInfo)
|
||||||
// Default open or close DevTools by F12 in development
|
// Default open or close DevTools by F12 in development
|
||||||
// and ignore CommandOrControl + R in production.
|
// and ignore CommandOrControl + R in production.
|
||||||
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
|
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
|
||||||
@ -49,9 +161,6 @@ app.whenReady().then(() => {
|
|||||||
optimizer.watchWindowShortcuts(window)
|
optimizer.watchWindowShortcuts(window)
|
||||||
})
|
})
|
||||||
|
|
||||||
// IPC test
|
|
||||||
ipcMain.on('ping', () => console.log('pong'))
|
|
||||||
|
|
||||||
createWindow()
|
createWindow()
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { contextBridge } from 'electron'
|
import electron, { contextBridge, ipcRenderer } from 'electron'
|
||||||
import { electronAPI } from '@electron-toolkit/preload'
|
import { electronAPI } from '@electron-toolkit/preload'
|
||||||
|
|
||||||
// Custom APIs for renderer
|
// Custom APIs for renderer
|
||||||
@ -11,10 +11,22 @@ if (process.contextIsolated) {
|
|||||||
try {
|
try {
|
||||||
contextBridge.exposeInMainWorld('electron', electronAPI)
|
contextBridge.exposeInMainWorld('electron', electronAPI)
|
||||||
contextBridge.exposeInMainWorld('api', api)
|
contextBridge.exposeInMainWorld('api', api)
|
||||||
|
contextBridge.exposeInMainWorld('baseConfig', {
|
||||||
|
getBaseConfig: () => ipcRenderer.invoke('getBaseConfig')
|
||||||
|
})
|
||||||
|
contextBridge.exposeInMainWorld('client', {
|
||||||
|
getLOLClientWindowInfo: () => ipcRenderer.invoke('getLOLClientWindowInfo')
|
||||||
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window.electron = electronAPI
|
window.electron = electronAPI
|
||||||
window.api = api
|
window.api = api
|
||||||
|
window.electronAPI = {
|
||||||
|
getBaseConfig: () => ipcRenderer.invoke('getBaseConfig')
|
||||||
|
}
|
||||||
|
window.electronAPI = {
|
||||||
|
getLOLClientWindowInfo: () => ipcRenderer.invoke('getLOLClientWindowInfo')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,29 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import Versions from './components/Versions.vue'
|
import Versions from './components/Versions.vue'
|
||||||
|
|
||||||
const ipcHandle = () => window.electron.ipcRenderer.send('ping')
|
const getBaseConfig = async () => {
|
||||||
|
return await window.baseConfig.getBaseConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
const getLOLClientWindowInfo = async () => {
|
||||||
|
const LOLClientWindowInfo = await window.client.getLOLClientWindowInfo()
|
||||||
|
console.log(LOLClientWindowInfo)
|
||||||
|
return LOLClientWindowInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
const intervalId = setInterval(async () => {
|
||||||
|
const config = await getBaseConfig()
|
||||||
|
|
||||||
|
// 假设我们在某些条件下想停止定时器
|
||||||
|
if (config.Auth && config.Auth === 'Auth required') {
|
||||||
|
clearInterval(intervalId)
|
||||||
|
console.log('请以管理员权限启动')
|
||||||
|
} else if (config.Auth && config.Auth !== '') {
|
||||||
|
clearInterval(intervalId)
|
||||||
|
await getLOLClientWindowInfo()
|
||||||
|
console.log('检测到客户端运行')
|
||||||
|
}
|
||||||
|
}, 500)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -17,7 +39,7 @@ const ipcHandle = () => window.electron.ipcRenderer.send('ping')
|
|||||||
<a href="https://electron-vite.org/" target="_blank" rel="noreferrer">Documentation</a>
|
<a href="https://electron-vite.org/" target="_blank" rel="noreferrer">Documentation</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="action">
|
<div class="action">
|
||||||
<a target="_blank" rel="noreferrer" @click="ipcHandle">Send IPC</a>
|
<a target="_blank" rel="noreferrer" @click="getLOLClientWindowInfo">Send IPC</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Versions />
|
<Versions />
|
||||||
|
Reference in New Issue
Block a user