Skip to content

Commit 0fc8a97

Browse files
committed
show match history (99%)
1 parent 4d3c12d commit 0fc8a97

File tree

7 files changed

+117
-68
lines changed

7 files changed

+117
-68
lines changed

frankElectron/matchHistory.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,28 @@ export const createMatchHistoryWindow = async (userHeader) => {
3434
}
3535

3636
export const matchHistoryIpc = (userHeader) => {
37-
let matchHistoryWindow
3837
// 展示战力分析窗口
3938
ipcMain.on('showCharts',async (event,clientStatus) => {
40-
matchHistoryWindow = await createMatchHistoryWindow(userHeader)
39+
const matchHistoryWindow = await createMatchHistoryWindow(userHeader)
4140
if (clientStatus==='"InProgress"'){
4241
matchHistoryWindow.webContents.send('query-enemy-summoner')
4342
}
4443
})
4544
// 移动游戏历史窗口
4645
ipcMain.on('move-match-history-window', (event, pos) => {
47-
matchHistoryWindow.setBounds({ x: pos.x, y: pos.y, width: 1024, height: 576 })
46+
for (const currentWindow of BrowserWindow.getAllWindows()) {
47+
if (currentWindow.title === 'MatchHistory'){
48+
currentWindow.setBounds({ x: pos.x, y: pos.y, width: 1024, height: 576 })
49+
}
50+
}
4851
})
4952
// 最小化游戏历史窗口
5053
ipcMain.on('match-history-window-min', () => {
51-
matchHistoryWindow.minimize()
54+
for (const currentWindow of BrowserWindow.getAllWindows()) {
55+
if (currentWindow.title === 'MatchHistory'){
56+
currentWindow.minimize()
57+
}
58+
}
5259
})
5360
// 关闭游戏历史窗口
5461
ipcMain.on('close-match-history-window', () => {
@@ -68,20 +75,4 @@ export const creatMatchAfterStartGame = async (userHeader) => {
6875
}
6976
const matchWin = await createMatchHistoryWindow(userHeader)
7077
matchWin.webContents.send('query-enemy-summoner')
71-
// 移动游戏历史窗口
72-
ipcMain.on('move-match-history-window', (event, pos) => {
73-
matchWin.setBounds({ x: pos.x, y: pos.y, width: 1024, height: 576 })
74-
})
75-
// 最小化游戏历史窗口
76-
ipcMain.on('match-history-window-min', () => {
77-
matchWin.minimize()
78-
})
79-
// 关闭游戏历史窗口
80-
ipcMain.on('close-match-history-window', () => {
81-
for (const currentWindow of BrowserWindow.getAllWindows()) {
82-
if (currentWindow.title === 'MatchHistory'){
83-
currentWindow.close()
84-
}
85-
}
86-
})
8778
}

frankElectron/queryMatch.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const createQueryMatchWindow = async (userHeader) => {
1515
contextIsolation: false,
1616
enableRemoteModule: true,
1717
webSecurity: false,
18-
// devTools:false
1918
}
2019
})
2120
queryMatchWindow.on('ready-to-show', () => {
@@ -37,8 +36,8 @@ export const queryMatchIpc = async (mainWindow,userHeader) => {
3736
let queryMatchWindow
3837
// 展示查询战绩窗口
3938
ipcMain.on('show-query-match',async () => {
40-
queryMatchWindow = await createQueryMatchWindow(userHeader)
4139
mainWindow.hide()
40+
queryMatchWindow = await createQueryMatchWindow(userHeader)
4241
})
4342
// 移动游戏历史窗口
4443
ipcMain.on('move-query-match-window', (event, pos) => {

src/render/components/assist/assistWindow.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
2-
<n-tabs type="segment" :animated=true ref="tabsInstRef" :value="transValue">
2+
<n-tabs type="segment" :animated=true
3+
ref="tabsInstRef" :value="transValue">
34
<n-tab name="champRank" tab="英雄数据" @click="transValue='champRank'"></n-tab>
45
<n-tab name="match" tab="查看战绩" @click="showMatch"></n-tab>
56
<n-tab v-if="isSwitchBlacklist" name="blacklist" tab="排位笔记" @click="transValue='blacklist'"></n-tab>
@@ -115,7 +116,6 @@ const showMatch = async () => {
115116
method: "GET",
116117
url: `/lol-gameflow/v1/gameflow-phase/`,
117118
}, appConfig.get('credentials'))).json()
118-
// clientStatus == '"ChampSelect"' || clientStatus == '"GameStart"'
119119
if (clientStatus == '"ChampSelect"' || clientStatus == '"InProgress"'){
120120
ipcRenderer.send('showCharts',clientStatus)
121121
message.success('获取战绩成功 !')

src/render/components/matchHistory/leftCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const getEnemyInfo = async () => {
110110
enemySummonerInfo.value = await getSummonerNickName(credentials, enemyIdList)
111111
getEnemyChartsData(enemySummonerInfo.value)
112112
}
113-
getEnemyInfo()
113+
// getEnemyInfo()
114114
115115
const getEnemyChartsData = (res) => {
116116
enemyEchartsData.value = {name: [], data: [], kdaHistory: [], horse: [], summonerId: []}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<template>
2+
<div>
3+
<i></i>
4+
<i></i>
5+
</div>
6+
</template>
7+
8+
<script>
9+
export default {
10+
name: "loadingAnime"
11+
}
12+
</script>
13+
14+
<style scoped>
15+
i {
16+
position: absolute;
17+
top: 50%;
18+
left: 50%;
19+
width: 40vmin;
20+
height: 40vmin;
21+
border-radius: 50%;
22+
transform: translate(-50%, -50%);
23+
animation: move 10s forwards infinite;
24+
background: linear-gradient(15deg,#42d392 25%,#647eff);
25+
}
26+
27+
i:nth-child(2) {
28+
animation-delay: -2s;
29+
background: rgba(255,255,255,.3);
30+
box-shadow: 0 0 1rem rgba(255,255,255,.7),
31+
0 0 0 1px rgba(255,255,255,.1);
32+
backdrop-filter: blur(30px);
33+
}
34+
35+
@keyframes move {
36+
0%, 100% {
37+
transform: translate(-50%, -50%) rotate(0) translateY(-30%);
38+
}
39+
25% {
40+
transform: translate(-50%, -50%) rotate(-90deg) translateY(-30%);
41+
}
42+
50% {
43+
transform: translate(-50%, -50%) rotate(180deg) translateY(-30%);
44+
}
45+
}
46+
</style>

src/render/components/matchHistory/recentGame.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
3-
<n-card class="boxShadow mainCard" content-style="padding:20px 10px 20px 10px">
4-
<n-grid x-gap="20" :cols="5" style="margin-top: 15px">
3+
<n-card class="boxShadow mainCard" content-style="padding:20px 10px 20px 10px" >
4+
<n-grid x-gap="20" :cols="5" style="margin-top: 15px" v-if="summonerInfo.length!==0">
55
<n-gi v-for="summoner in (currentTeam === 1 ? summonerInfo:enemySummonerInfo)">
66
<n-space vertical :size="[10,4]" class="alignCenter">
77
<n-avatar
@@ -39,9 +39,8 @@
3939
</div>
4040
</n-space>
4141
</n-gi>
42-
4342
</n-grid>
44-
43+
<loading-anime v-else></loading-anime>
4544
<div class="suspension">
4645
<n-space>
4746
<n-button
@@ -82,8 +81,8 @@
8281
</n-popover>
8382
</n-space>
8483
</div>
85-
8684
</n-card>
85+
8786
</div>
8887
</template>
8988

@@ -102,6 +101,7 @@ import {matchStore} from "@/render/store";
102101
import {storeToRefs} from "pinia/dist/pinia";
103102
import {ChevronsDownLeft, CircleX, Ballon,PictureInPictureTop} from '@vicons/tabler'
104103
import {ipcRenderer} from "electron";
104+
import LoadingAnime from "@/render/components/matchHistory/loadingAnime";
105105
106106
const emits = defineEmits(['changePage','summonerId','toGameDetailsPage'])
107107
const store = matchStore()

src/utils/main/gameScore.js

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,26 @@ const queryCurrentGameMode = async (credentials) => {
1818
}
1919

2020
// 获取最近的比赛记录
21-
const getRencentMatchHistoty = async (credentials,session,summonerId) => {
21+
const getRencentMatchHistoty = async (credentials, session, summonerId) => {
2222
const matchList = (await createHttp2Request({
2323
method: "GET",
24-
url: `/lol-match-history/v3/matchlist/account/${summonerId}`,
24+
url: `/lol-match-history/v3/matchlist/account/${summonerId}?begIndex=0&endIndex=10`,
2525
}, session, credentials)).json()['games']['games'].reverse()
26-
return matchList.slice(0,10)
26+
return matchList
2727
}
2828

29-
// 查询比赛记录 (最近5场排位)
30-
const queryMatchHistory = async (credentials,session,summonerId) => {
29+
// 查询比赛记录 (最近10场排位)
30+
const queryMatchHistory = async (credentials, session, summonerId) => {
3131
const currentGameMode = await queryCurrentGameMode(credentials)
3232
console.log('当前游戏模式:', currentGameMode)
33-
if (currentGameMode === null){
34-
return await getRencentMatchHistoty(credentials,session,summonerId)
33+
if (currentGameMode === null) {
34+
return await getRencentMatchHistoty(credentials, session, summonerId)
3535
}
3636

3737
let classicMode = []
3838
let matchCount = 0
3939
for (let i = 0; i < 100; i += 20) {
40+
console.log(123)
4041
const matchList = (await createHttp2Request({
4142
method: "GET",
4243
url: `/lol-match-history/v3/matchlist/account/${summonerId}?begIndex=${i}&endIndex=${i + 20}`,
@@ -46,29 +47,33 @@ const queryMatchHistory = async (credentials,session,summonerId) => {
4647
if (matchListElement.queueId == currentGameMode && matchCount < 10) {
4748
matchCount += 1
4849
classicMode.push(matchListElement)
50+
} else if (matchCount === 10) {
51+
return classicMode
4952
}
5053
}
51-
if (matchCount === 10) {
52-
break
53-
}
5454
}
5555
return classicMode
5656
}
5757

5858
// 获取召唤师游戏评分分数
59-
export const getGameScore = async (credentials, summonerId,session) => {
60-
let classicModeGames = await queryMatchHistory(credentials,session, summonerId)
59+
export const getGameScore = async (credentials, summonerId, session) => {
60+
let classicModeGames = await queryMatchHistory(credentials, session, summonerId)
6161
const simpleMatchHistory = getSimpleMatchHistory(classicModeGames)
6262
let gameScore = 0
63-
let gameCount = classicModeGames.length
63+
let gameCount = classicModeGames.slice(0,5).length
6464
let kdaHistory = ''
65-
for (const modeGame of classicModeGames) {
65+
for (const modeGame of classicModeGames.slice(0,5)) {
6666
gameScore += analyseSingleMatch(modeGame.participants[0].stats)
6767
let tempKad = `${modeGame.participants[0].stats.kills}/${modeGame.participants[0].stats.deaths}/${modeGame.participants[0].stats.assists} `
6868
kdaHistory += tempKad
6969
}
7070
gameScore = parseInt(gameScore / gameCount)
71-
return {score: gameScore, horse: jundgeHorse(gameScore), kdaHistory: kdaHistory,simpleMatchHistory:simpleMatchHistory}
71+
return {
72+
score: gameScore,
73+
horse: jundgeHorse(gameScore),
74+
kdaHistory: kdaHistory,
75+
simpleMatchHistory: simpleMatchHistory
76+
}
7277
}
7378

7479
// 获取简单的历史战绩信息
@@ -78,39 +83,42 @@ const getSimpleMatchHistory = (matchList) => {
7883
let simpleMatch = []
7984
for (const match of matchList) {
8085
simpleMatch.push({
81-
champImg:`https://game.gtimg.cn/images/lol/act/img/champion/${champDict[String(match.participants[0].championId)].alias}.png`,
82-
position:match.participants[0].timeline.lane,
83-
kill:match.participants[0].stats.kills,
84-
deaths:match.participants[0].stats.deaths,
85-
assists:match.participants[0].stats.assists,
86-
isWin:match.participants[0].stats.win,
87-
gameId:match.gameId
86+
champImg: `https://game.gtimg.cn/images/lol/act/img/champion/${champDict[String(match.participants[0].championId)].alias}.png`,
87+
position: match.participants[0].timeline.lane,
88+
kill: match.participants[0].stats.kills,
89+
deaths: match.participants[0].stats.deaths,
90+
assists: match.participants[0].stats.assists,
91+
isWin: match.participants[0].stats.win,
92+
gameId: match.gameId
8893
})
8994
position.push(match.participants[0].timeline.lane)
9095
winOrLoss.push(match.participants[0].stats.win)
9196
}
9297
const winInfo = inferMatchWinRat(winOrLoss)
9398
const regularPostion = inferRegularPosition(position)
94-
return {winInfo,regularPostion,simpleMatch}
99+
return {winInfo, regularPostion, simpleMatch}
95100
}
96101

97102
// 判断最近战绩情况
98103
const inferMatchWinRat = (arr) => {
99104
const firstMatch = arr[0]
100105
let count = 0
101106
for (const arrElement of arr) {
102-
if (arrElement === firstMatch){
103-
count +=1
104-
}else {
107+
if (arrElement === firstMatch) {
108+
count += 1
109+
} else {
105110
break
106111
}
107112
}
108-
if (count ===1){
109-
return firstMatch === true ? {'info':'一胜一负',isWin:firstMatch} : {'info':'一负一胜',isWin:firstMatch}
110-
}else if(count ===0){
111-
return {'info':'暂无数据',isWin:firstMatch}
113+
if (count === 1) {
114+
return firstMatch === true ? {'info': '一胜一负', isWin: firstMatch} : {'info': '一负一胜', isWin: firstMatch}
115+
} else if (count === 0) {
116+
return {'info': '暂无数据', isWin: firstMatch}
112117
} else {
113-
return firstMatch === true ? {'info':`${count}连胜中`,isWin:firstMatch} :{'info':`${count}连败中`,isWin:firstMatch}
118+
return firstMatch === true ? {'info': `${count}连胜中`, isWin: firstMatch} : {
119+
'info': `${count}连败中`,
120+
isWin: firstMatch
121+
}
114122
}
115123
}
116124

@@ -121,10 +129,10 @@ const inferRegularPosition = (arr) => {
121129
let res = {}
122130
let maxNum = 0
123131
let maxValue = null
124-
for(let i = 0; i < arr.length;i++) {
132+
for (let i = 0; i < arr.length; i++) {
125133
let val = arr[i]
126134
res[val] === undefined ? res[val] = 1 : res[val]++
127-
if(res[val] > maxNum) {
135+
if (res[val] > maxNum) {
128136
maxNum = res[val]
129137
maxValue = val
130138
}
@@ -172,11 +180,16 @@ const jundgeHorse = (score) => {
172180
// 判断玩家位置
173181
const querySummonerPosition = (lane) => {
174182
switch (lane) {
175-
case 'MIDDLE' : return '中单';
176-
case 'JUNGLE' : return '打野';
177-
case 'BOTTOM' : return '下路';
178-
case 'TOP' : return '上单';
179-
case 'NONE': return '未知'
183+
case 'MIDDLE' :
184+
return '中单';
185+
case 'JUNGLE' :
186+
return '打野';
187+
case 'BOTTOM' :
188+
return '下路';
189+
case 'TOP' :
190+
return '上单';
191+
case 'NONE':
192+
return '未知'
180193
}
181194
return '未知'
182195
}

0 commit comments

Comments
 (0)