File tree Expand file tree Collapse file tree 4 files changed +6
-35
lines changed Expand file tree Collapse file tree 4 files changed +6
-35
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ render:
25
25
26
26
api :
27
27
ratelimit : 2 # set to 1 request per sec as per mojang api rate limit
28
- max-name-history : 3 # Maximum history will be recorded
29
28
30
29
# Set advancements progresses
31
30
# Details: http://minecraft.gamepedia.com/Advancements
Original file line number Diff line number Diff line change @@ -183,21 +183,16 @@ export default class Utils {
183
183
184
184
async getNameHistory ( uuid ) {
185
185
const apiNameHistory = `https://api.mojang.com/user/profiles/${ uuid } /names` ;
186
- const history = [ ] ;
187
- let res ;
186
+ let history ;
188
187
try {
189
- res = await this . getMojangAPI ( apiNameHistory ) ;
188
+ history = await this . getMojangAPI ( apiNameHistory ) ;
190
189
} catch ( err ) {
191
190
return null ;
192
191
}
193
- if ( ! res ) return null ;
194
- let limit = this . config . api [ 'max-name-history' ] ;
195
- if ( res . length < this . config . api [ 'max-name-history' ] ) {
196
- limit = res . length ;
197
- }
198
- for ( let i = 1 ; i <= limit ; i += 1 ) {
199
- history . push ( res [ res . length - i ] ) ;
200
- }
192
+ if ( ! history ) return null ;
193
+ // The order of the response data from Mojang API is uncertain,
194
+ // so manually sort it (to descending order) for making sure.
195
+ history . sort ( ( a , b ) => ( b . changedToAt || 0 ) - ( a . changedToAt || 0 ) )
201
196
return history ;
202
197
}
203
198
Original file line number Diff line number Diff line change 386
386
"nyaa.general.search_placeholder" : " Search player by name / UUID" ,
387
387
"nyaa.general.go_random_player" : " Feel lucky" ,
388
388
"nyaa.general.go_random_player_again" : " One more luck" ,
389
- "nyaa.general.loading_hint" : " Loading..." ,
390
389
"nyaa.app_menu.section_title.others" : " Others" ,
391
390
"nyaa.home.explore_link_label" : " Explore" ,
392
391
"nyaa.home.starring_number.uptime" : " Uptime" ,
782
781
"nyaa.general.search_placeholder" : " 按名称 / UUID 搜索玩家" ,
783
782
"nyaa.general.go_random_player" : " 随机查看" ,
784
783
"nyaa.general.go_random_player_again" : " 再随机一次" ,
785
- "nyaa.general.loading_hint" : " 加载中…" ,
786
784
"nyaa.app_menu.section_title.others" : " 其他" ,
787
785
"nyaa.home.explore_link_label" : " 去看看" ,
788
786
"nyaa.home.starring_number.uptime" : " 世界历时" ,
Original file line number Diff line number Diff line change 9
9
<strong class =" font-normal mr-3" >{{ name }}</strong >
10
10
<span class =" ml-auto text-gray-500 font-tnum" >{{ formatDate(changedToAt) || t('nyaa.player_name_history.first_name') }}</span >
11
11
</li >
12
- <li v-if =" isLoadingNameHistory" class =" p-3 border-t first:border-t-0 border-gray-300 bg-gray-100 text-gray-500 flex items-center" >{{ t('nyaa.general.loading_hint') }}</li >
13
12
</ul >
14
13
</PlayerAsidePanel >
15
14
</template >
16
15
17
16
<script >
18
- import axios from ' axios'
19
-
20
17
import PlayerAsidePanel from ' @/components/PlayerAsidePanel.vue'
21
18
import {normalizeDate } from ' @/common/utils'
22
19
37
34
data () {
38
35
return {
39
36
names: this .player .data .names ,
40
- isLoadingNameHistory: true ,
41
37
}
42
38
},
43
39
53
49
},
54
50
},
55
51
56
- created () {
57
- this .loadNameHistory ()
58
- },
59
-
60
52
methods: {
61
- async loadNameHistory () {
62
- if (this .names .slice (- 1 )[0 ].changedToAt ) {
63
- const {data } = await axios (
64
- process .env .NODE_ENV === ' development'
65
- ? ` /mojang-api/user/profiles/${ this .player .data .uuid_short } /names`
66
- : ` https://mojang-api.silent.land/${ location .host } /user/profiles/${ this .player .data .uuid_short } /names`
67
- )
68
- this .names = data .reverse ()
69
- }
70
-
71
- this .isLoadingNameHistory = false
72
- },
73
-
74
53
formatDate (val ) {
75
54
return val && normalizeDate (val, ' short' )
76
55
},
You can’t perform that action at this time.
0 commit comments