Skip to content

Commit

Permalink
一个展示段位详情的表格组件
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanxven committed Sep 16, 2024
1 parent 7b9d5f0 commit 997cd4c
Show file tree
Hide file tree
Showing 10 changed files with 372 additions and 386 deletions.
6 changes: 0 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@

- 添加了一个设置项,位于 `应用` -> `其他` -> `禁用硬件加速`,可选择是否禁用硬件加速。适用于界面渲染模糊的情况,但也会显著降低性能。

- [TODO] 观战功能在短屏幕下也要支持。

- [UNTESTED] 遇到过 - UI 补全

- [TODO] hover 排位信息补全

- [TODO] 排查:对局分析多余的加载。

- [TODO] 补全对局分析的刷新按钮和队列筛选按钮。

## 调整
Expand Down
13 changes: 6 additions & 7 deletions src/main/modules/core-functionality/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class CoreFunctionalitySettings {
this.playerAnalysisFetchConcurrency = limit
}


setUseSgpApi(value: boolean) {
this.useSgpApi = value
}
Expand Down Expand Up @@ -408,12 +407,12 @@ export class CoreFunctionalityState {

if (
lcu.gameflow.session &&
(lcu.gameflow.phase === 'GameStart' ||
lcu.gameflow.phase === 'InProgress' ||
lcu.gameflow.phase === 'WaitingForStats' ||
lcu.gameflow.phase === 'PreEndOfGame' ||
lcu.gameflow.phase === 'EndOfGame' ||
lcu.gameflow.phase === 'Reconnect')
(lcu.gameflow.session.phase === 'GameStart' ||
lcu.gameflow.session.phase === 'InProgress' ||
lcu.gameflow.session.phase === 'WaitingForStats' ||
lcu.gameflow.session.phase === 'PreEndOfGame' ||
lcu.gameflow.session.phase === 'EndOfGame' ||
lcu.gameflow.session.phase === 'Reconnect')
) {
return {
phase: 'in-game',
Expand Down
214 changes: 214 additions & 0 deletions src/renderer/src-main-window/components/RankedTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<template>
<table class="ranked-stats-table">
<colgroup></colgroup>
<thead>
<tr>
<th>队列</th>
<th>当前段位</th>
<th>胜点</th>
<th>胜局</th>
<th>负局</th>
<th>上赛季末段位</th>
<th>上赛季最高段位</th>
<th>历史最高段位</th>
</tr>
</thead>
<tbody>
<tr v-for="r of sortedQueues" :key="r.queueType">
<td>{{ formatQueueName(r.queueType) }}</td>
<td>
<div class="tier">
<img
v-if="RANKED_MEDAL_MAP[r.tier]"
:src="RANKED_MEDAL_MAP[r.tier]"
alt="tier"
class="tier-img"
/>
{{ formatTierDivision(r, 'current') }}
</div>
</td>
<td>{{ formatPoints(r) }}</td>
<td>{{ formatWins(r) }}</td>
<td>{{ formatLosses(r.losses) }}</td>
<td>
<div class="tier">
<img
v-if="RANKED_MEDAL_MAP[r.previousSeasonEndTier]"
:src="RANKED_MEDAL_MAP[r.previousSeasonEndTier]"
alt="tier"
class="tier-img"
/>
{{ formatTierDivision(r, 'previousSeasonEnd') }}
</div>
</td>
<td>
<div class="tier">
<img
v-if="RANKED_MEDAL_MAP[r.previousSeasonHighestTier]"
:src="RANKED_MEDAL_MAP[r.previousSeasonHighestTier]"
alt="tier"
class="tier-img"
/>
{{ formatTierDivision(r, 'previousSeasonHighest') }}
</div>
</td>
<td>
<div class="tier">
<img
v-if="RANKED_MEDAL_MAP[r.highestTier]"
:src="RANKED_MEDAL_MAP[r.highestTier]"
alt="tier"
class="tier-img"
/>
{{ formatTierDivision(r, 'highest') }}
</div>
</td>
</tr>
</tbody>
</table>
</template>

<script lang="ts" setup>
import { RankedEntry, RankedStats } from '@shared/types/lcu/ranked'
import { QUEUE_TYPE_TEXT, TIER_TEXT } from '@shared/utils/ranked'
import BronzeMedal from '@main-window/assets/ranked-icons/bronze.png'
import ChallengerMedal from '@main-window/assets/ranked-icons/challenger.png'
import DiamondMedal from '@main-window/assets/ranked-icons/diamond.png'
import EmeraldMedal from '@main-window/assets/ranked-icons/emerald.png'
import GoldMedal from '@main-window/assets/ranked-icons/gold.png'
import GrandmasterMedal from '@main-window/assets/ranked-icons/grandmaster.png'
import IronMedal from '@main-window/assets/ranked-icons/iron.png'
import MasterMedal from '@main-window/assets/ranked-icons/master.png'
import PlatinumMedal from '@main-window/assets/ranked-icons/platinum.png'
import SilverMedal from '@main-window/assets/ranked-icons/silver.png'
const { rankedStats } = defineProps<{
rankedStats: RankedStats
}>()
const RANKED_MEDAL_MAP: Record<string, string> = {
IRON: IronMedal,
BRONZE: BronzeMedal,
SILVER: SilverMedal,
GOLD: GoldMedal,
PLATINUM: PlatinumMedal,
EMERALD: EmeraldMedal,
DIAMOND: DiamondMedal,
MASTER: MasterMedal,
GRANDMASTER: GrandmasterMedal,
CHALLENGER: ChallengerMedal
}
const QUEUE_TYPE_ORDER: Record<string, number> = {
RANKED_SOLO_5x5: 1,
RANKED_FLEX_SR: 2,
CHERRY: 3,
RANKED_TFT: 4,
RANKED_TFT_TURBO: 5,
RANKED_TFT_DOUBLE_UP: 6
}
const formatQueueName = (queueType: string) => {
return QUEUE_TYPE_TEXT[queueType] || queueType
}
const formatWins = (entry: RankedEntry) => {
if (entry.queueType === 'CHERRY') {
return entry.ratedTier === 'NONE' ? '' : entry.wins
}
if (!entry.tier || entry.tier === 'NA') {
return ''
}
return entry.wins
}
const formatPoints = (entry: RankedEntry) => {
if (entry.queueType === 'CHERRY') {
return entry.ratedTier === 'NONE' ? '' : entry.ratedRating
}
if (!entry.tier || entry.tier === 'NA') {
return ''
}
return entry.leaguePoints
}
const sortedQueues = rankedStats.queues.sort((a, b) => {
return QUEUE_TYPE_ORDER[a.queueType] - QUEUE_TYPE_ORDER[b.queueType]
})
const formatTierDivision = (entry: RankedEntry, type: string) => {
let tier: string
let division: string
switch (type) {
case 'current':
tier = entry.tier
division = entry.division
break
case 'previousSeasonEnd':
tier = entry.previousSeasonEndTier
division = entry.previousSeasonEndDivision
break
case 'previousSeasonHighest':
tier = entry.previousSeasonHighestTier
division = entry.previousSeasonHighestDivision
break
case 'highest':
tier = entry.highestTier
division = entry.highestDivision
break
default:
tier = ''
division = ''
}
if (!tier || tier === 'NA') {
return ''
}
if (!division || division === 'NA') {
return TIER_TEXT[tier] || tier
}
return `${TIER_TEXT[tier] || tier} ${division}`
}
const formatLosses = (losses: number) => {
return losses || ''
}
</script>

<style lang="less" scoped>
// 轻度边框
.ranked-stats-table {
border-collapse: collapse;
border-spacing: 0;
border: 1px solid #ffffff40;
font-size: 12px;
color: #d4d4d4;
th,
td {
border: 1px solid #ffffff40;
padding: 0 4px;
text-align: center;
}
.tier {
display: flex;
gap: 4px;
align-items: center;
justify-content: center;
.tier-img {
width: 16px;
height: 16px;
vertical-align: middle;
}
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
/>
<NModal v-model:show="isShowingRankedModal">
<div class="ranked-modal">
<RankedDisplay
v-for="r of tab.rankedStats?.queueMap"
:key="r.queueType"
class="ranked"
:ranked-entry="r"
/>
<div class="blocks">
<RankedDisplay
v-for="r of tab.rankedStats?.queueMap"
:key="r.queueType"
class="ranked"
:ranked-entry="r"
/>
</div>
<RankedTable v-if="tab.rankedStats" :ranked-stats="tab.rankedStats" />
</div>
</NModal>
<Transition name="fade">
Expand Down Expand Up @@ -477,7 +480,7 @@ import {
NavigateBeforeOutlined as NavigateBeforeOutlinedIcon,
NavigateNextOutlined as NavigateNextOutlinedIcon
} from '@vicons/material'
import { useIntervalFn, useMediaQuery } from '@vueuse/core'
import { useIntervalFn, useMediaQuery, useScroll } from '@vueuse/core'
import {
NButton,
NIcon,
Expand All @@ -492,6 +495,7 @@ import {
import { computed, nextTick, ref, shallowRef, useTemplateRef, watch } from 'vue'
import PlayerTagEditModal from '@main-window/components/PlayerTagEditModal.vue'
import RankedTable from '@main-window/components/RankedTable.vue'
import { matchHistoryTabsRendererModule as mhm } from '@main-window/modules/match-history-tabs'
import { TabState, useMatchHistoryTabsStore } from '@main-window/modules/match-history-tabs/store'
Expand Down Expand Up @@ -543,7 +547,7 @@ const analysis = computed(() => {
const eds = useExternalDataSourceStore()
const scrollRef = useTemplateRef('scroll')
const scrollEl = useTemplateRef('scroll')
const rightEl = useTemplateRef('right')
const mh = useMatchHistoryTabsStore()
Expand All @@ -568,7 +572,7 @@ const isSomethingLoading = computed(() => {
const scrollToRightElTop = () => {
const top = rightEl.value?.offsetTop
if (top && top < mainContentScrollTop.value) {
scrollRef.value?.scrollTo({ top: top })
scrollEl.value?.scrollTo({ top: top })
}
}
Expand Down Expand Up @@ -851,15 +855,18 @@ watch(
watch(
() => mh.currentTab?.id,
() => {
if (mh.currentTab?.id === tab.puuid) {
if (mh.currentTab?.id === tab.id) {
nextTick(() => {
scrollRef.value?.scrollTo({ top: mainContentScrollTop.value })
scrollEl.value?.scrollTo({ top: mainContentScrollTop.value })
})
}
}
},
{ immediate: true }
)
defineExpose({
id: tab.id,
sgpServerId: tab.sgpServerId,
puuid: tab.puuid,
refresh: handleRefresh
})
Expand All @@ -874,13 +881,20 @@ defineExpose({
}
.ranked-modal {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
display: flex;
align-items: center;
flex-direction: column;
border-radius: 4px;
background-color: #202020;
padding: 16px;
.blocks {
margin-bottom: 16px;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
}
.ranked {
background-color: #f4f4f40e;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div v-if="rankedEntry" class="ranked-wrapper" :class="{ small: small }">
<div class="ranked-type">
{{ queueTypeTextMap[rankedEntry.queueType] || rankedEntry.queueType }}
{{ QUEUE_TYPE_TEXT[rankedEntry.queueType] || rankedEntry.queueType }}
</div>
<div class="ranked-display">
<img
Expand Down Expand Up @@ -46,7 +46,7 @@

<script lang="ts" setup>
import { RankedEntry } from '@shared/types/lcu/ranked'
import { queueTypeTextMap, tierTextMap } from '@shared/utils/ranked'
import { QUEUE_TYPE_TEXT, TIER_TEXT } from '@shared/utils/ranked'
import { computed } from 'vue'
import RankedBronze from '@main-window/assets/ranked-icons-large/bronze.png'
Expand Down Expand Up @@ -108,7 +108,7 @@ const formatTier = computed(() => {
return ''
}
const tier = tierTextMap[props.rankedEntry.tier] || props.rankedEntry.tier
const tier = TIER_TEXT[props.rankedEntry.tier] || props.rankedEntry.tier
if (tier === '' || tier === 'NA') {
return '未定级'
Expand All @@ -129,7 +129,7 @@ const formatPreviousTier = computed(() => {
}
const tier =
tierTextMap[props.rankedEntry.previousSeasonHighestTier] ||
TIER_TEXT[props.rankedEntry.previousSeasonHighestTier] ||
props.rankedEntry.previousSeasonHighestTier
if (tier === '' || tier === 'NA') {
Expand Down
Loading

0 comments on commit 997cd4c

Please sign in to comment.