Compare commits

..

No commits in common. "master" and "gaze" have entirely different histories.
master ... gaze

11 changed files with 13 additions and 179 deletions

3
.gitignore vendored
View File

@ -3,7 +3,8 @@ dist
out
.DS_Store
*.log*
pnpm-lock.yaml
package-lock.json
pnpm-lock.yaml
.vscode
.idea
build

View File

@ -1,12 +0,0 @@
<?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>

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View File

@ -12,13 +12,6 @@ asarUnpack:
- resources/**
win:
executableName: lol-assistant
requestedExecutionLevel: requireAdministrator
extraResources: [
{
"from": "./tool.exe",
"to": "./tool.exe",
},
]
nsis:
artifactName: ${name}-${version}-setup.${ext}
shortcutName: ${productName}

View File

@ -9,18 +9,13 @@
"format": "prettier --write .",
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
"start": "electron-vite preview",
"dev": "powershell -Command \"Start-Process cmd -ArgumentList '/k', 'cd %cd% && npm run dev:base' -Verb RunAs\"",
"dev:base": "electron-vite dev",
"dev": "electron-vite dev",
"build": "electron-vite build",
"postinstall": "electron-builder install-app-deps",
"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\""
"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"
},
"dependencies": {
"@electron-toolkit/preload": "^3.0.1",

Binary file not shown.

View File

@ -2,116 +2,6 @@ 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'
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() {
// Create the browser window.
@ -152,8 +42,6 @@ app.whenReady().then(() => {
// Set app user model id for windows
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
@ -161,6 +49,9 @@ app.whenReady().then(() => {
optimizer.watchWindowShortcuts(window)
})
// IPC test
ipcMain.on('ping', () => console.log('pong'))
createWindow()
app.on('activate', function () {

View File

@ -1,4 +1,4 @@
import electron, { contextBridge, ipcRenderer } from 'electron'
import { contextBridge } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
// Custom APIs for renderer
@ -11,22 +11,10 @@ if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('electron', electronAPI)
contextBridge.exposeInMainWorld('api', api)
contextBridge.exposeInMainWorld('baseConfig', {
getBaseConfig: () => ipcRenderer.invoke('getBaseConfig')
})
contextBridge.exposeInMainWorld('client', {
getLOLClientWindowInfo: () => ipcRenderer.invoke('getLOLClientWindowInfo')
})
} catch (error) {
console.error(error)
}
} else {
window.electron = electronAPI
window.api = api
window.electronAPI = {
getBaseConfig: () => ipcRenderer.invoke('getBaseConfig')
}
window.electronAPI = {
getLOLClientWindowInfo: () => ipcRenderer.invoke('getLOLClientWindowInfo')
}
}

View File

@ -1,29 +1,7 @@
<script setup>
import Versions from './components/Versions.vue'
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)
const ipcHandle = () => window.electron.ipcRenderer.send('ping')
</script>
<template>
@ -39,7 +17,7 @@ const intervalId = setInterval(async () => {
<a href="https://electron-vite.org/" target="_blank" rel="noreferrer">Documentation</a>
</div>
<div class="action">
<a target="_blank" rel="noreferrer" @click="getLOLClientWindowInfo">Send IPC</a>
<a target="_blank" rel="noreferrer" @click="ipcHandle">Send IPC</a>
</div>
</div>
<Versions />