|
34 | 34 | <!-- Name history -->
|
35 | 35 | <div class="mt-5">
|
36 | 36 | <h2 class="font-medium text-cool-gray-600 uppercase tracking-wide px-3 pb-2">{{ t('nyaa.player_name_history.section_title') }}</h2>
|
37 |
| - <ul class="bg-white rounded-md shadow"> |
38 |
| - <li |
39 |
| - v-for="({name, changedToAt}, idx) of player.data.names" |
40 |
| - :key="idx" |
41 |
| - class="p-3 border-t first:border-t-0 border-gray-300 flex items-center" |
42 |
| - > |
43 |
| - <strong class="font-normal mr-3">{{ name }}</strong> |
44 |
| - <span class="ml-auto text-gray-500 font-tnum">{{ formatDate(changedToAt) || t('nyaa.player_name_history.first_name') }}</span> |
45 |
| - </li> |
46 |
| - <li v-if="isLoadingNameHistory" class="p-3 border-t first:border-t-0 border-gray-300 text-gray-500 flex items-center">{{ t('nyaa.general.loading_hint') }}</li> |
47 |
| - </ul> |
| 37 | + <PlayerNameHistory :player="player" class="rounded-md shadow" /> |
48 | 38 | </div>
|
49 | 39 | <!-- Ore mining graph -->
|
50 | 40 | <div class="mt-5">
|
|
65 | 55 | </template>
|
66 | 56 |
|
67 | 57 | <script>
|
68 |
| - import axios from 'axios' |
69 | 58 | import {add, formatDistanceStrict} from 'date-fns'
|
70 | 59 | import {zhCN} from 'date-fns/locale'
|
71 | 60 |
|
72 | 61 | import advancementData from '@/assets/advancement-data.json'
|
| 62 | + import PlayerNameHistory from '@/components/PlayerNameHistory.vue' |
73 | 63 | import PlayerOreGraph from '@/components/PlayerOreGraph.vue'
|
74 | 64 | import PlayerAdvancementPanel from '@/components/PlayerAdvancementPanel.vue'
|
75 | 65 | import PlayerStatisticPanel from '@/components/PlayerStatisticPanel.vue'
|
|
82 | 72 | name: 'PlayerView',
|
83 | 73 |
|
84 | 74 | components: {
|
| 75 | + PlayerNameHistory, |
85 | 76 | PlayerOreGraph,
|
86 | 77 | PlayerAdvancementPanel,
|
87 | 78 | PlayerStatisticPanel,
|
|
91 | 82 | return {
|
92 | 83 | player: null,
|
93 | 84 |
|
94 |
| - isLoadingNameHistory: true, |
95 |
| -
|
96 | 85 | goRandom,
|
97 | 86 | }
|
98 | 87 | },
|
|
110 | 99 |
|
111 | 100 | membership () {
|
112 | 101 | const output = [
|
113 |
| - { |
114 |
| - label: this.t('nyaa.player_info.first_login'), |
115 |
| - value: this.formatDate(this.player?.data.time_start), |
116 |
| - }, |
117 | 102 | {
|
118 | 103 | label: this.t('nyaa.player_info.last_active'),
|
119 | 104 | value: this.formatDate(this.player?.data.time_last),
|
120 | 105 | },
|
| 106 | + { |
| 107 | + label: this.t('nyaa.player_info.first_login'), |
| 108 | + value: this.formatDate(this.player?.data.time_start), |
| 109 | + }, |
121 | 110 | {
|
122 | 111 | label: this.t('nyaa.player_info.total_online'),
|
123 | 112 | value: null,
|
|
138 | 127 | uuid () {
|
139 | 128 | this.fetchData()
|
140 | 129 | },
|
141 |
| -
|
142 |
| - player (val) { |
143 |
| - if (val) { |
144 |
| - this.loadNameHistory() |
145 |
| - } |
146 |
| - }, |
147 | 130 | },
|
148 | 131 |
|
149 | 132 | created () {
|
|
158 | 141 | this.$store.commit('setFooterUpdateTime', this.player.data.lastUpdate)
|
159 | 142 | },
|
160 | 143 |
|
161 |
| - async loadNameHistory () { |
162 |
| - if (!this.player) { |
163 |
| - console.error('Attempt to load name history while player data is not ready.') |
164 |
| - return |
165 |
| - } |
166 |
| -
|
167 |
| - if (this.player.data.names.slice(-1)[0].changedToAt) { |
168 |
| - const {data} = await axios( |
169 |
| - process.env.NODE_ENV === 'development' |
170 |
| - ? `/mojang-api/user/profiles/${this.uuid}/names` |
171 |
| - : `https://mojang-api.silent.land/${location.host}/user/profiles/${this.uuid}/names` |
172 |
| - ) |
173 |
| - this.$set(this.player.data, 'names', data.reverse()) |
174 |
| - } |
175 |
| -
|
176 |
| - this.isLoadingNameHistory = false |
177 |
| - }, |
178 |
| -
|
179 | 144 | formatDate (val) {
|
180 | 145 | return val && normalizeDate(val, 'short')
|
181 | 146 | },
|
|
0 commit comments