Skip to content

Commit b17fa67

Browse files
committed
【examples】优化ncp地图title
1 parent b5d491b commit b17fa67

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

examples/component/components_ncp_china_vue.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@
332332
$.get(
333333
'https://ncpviz.oss-cn-beijing.aliyuncs.com/ncpviz/ui.json?time=' + new Date().getTime(),
334334
function(response) {
335-
document.title = response[utils.getLanguage()].title;
335+
document.title = getTitle(response);
336336
}
337337
);
338338
},
@@ -533,6 +533,18 @@
533533
}
534534
return name;
535535
}
536+
function getTitle(response) {
537+
var titles = response[utils.getLanguage()];
538+
if (titles) {
539+
if (titles.firstPriorityTitle) {
540+
return titles.firstPriorityTitle;
541+
}
542+
if (titles.title && titles.title.indexOf('{') < 0) {
543+
return titles.title;
544+
}
545+
}
546+
return resources.text_ncp_china;
547+
}
536548
</script>
537549
</body>
538550
</html>

examples/component/components_ncp_world_vue.html

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,9 @@
257257
background: 'rgba(0, 0, 0,0)',
258258
colorGroup: ['rgb(225, 2, 0)']
259259
});
260-
$.get(
261-
'https://ncpviz.oss-cn-beijing.aliyuncs.com/ncpviz/ui.json?time=' + new Date().getTime(),
262-
function(response) {
263-
document.title = response[utils.getLanguage()].title;
264-
}
265-
);
260+
$.get('https://ncpviz.oss-cn-beijing.aliyuncs.com/ncpviz/ui.json?time=' + new Date().getTime(), function(response) {
261+
document.title = getTitle(response);
262+
});
266263
},
267264
computed: {
268265
num() {
@@ -318,7 +315,8 @@
318315
mapLoaded(e) {
319316
this.map = e.map;
320317
$.get(
321-
'https://ncpviz.oss-cn-beijing.aliyuncs.com/ncpviz/worldNcp.json?time=' + new Date().getTime(),
318+
'https://ncpviz.oss-cn-beijing.aliyuncs.com/ncpviz/worldNcp.json?time=' +
319+
new Date().getTime(),
322320
function(response) {
323321
this.time = resources.text_ncp_time.replace('{time}', response.time);
324322
var latestProvinceData = this.getLatestWorldData(response);
@@ -629,6 +627,18 @@
629627
}
630628
return name;
631629
}
630+
function getTitle(response) {
631+
var titles = response[utils.getLanguage()];
632+
if (titles) {
633+
if (titles.firstPriorityTitle) {
634+
return titles.firstPriorityTitle;
635+
}
636+
if (titles.title && titles.title.indexOf('{') < 0) {
637+
return titles.title;
638+
}
639+
}
640+
return resources.text_ncp_world;
641+
}
632642
</script>
633643
</body>
634644
</html>

examples/locales/en-US/resources.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,9 @@ window.examplesResources = {
13941394
'text_ncp_confirmed_tooltip':"{name}: Cumulative Confirmed {confirmed}",
13951395
'text_ncp_confirmed':"Cumulative Confirmed",
13961396
'text_ncpworld_incidence_title':"Reported incidence by World (per 100,000)",
1397+
'text_ncp_world':"Global NCP",
1398+
'text_ncp_china':"China NCP",
1399+
13971400

13981401
"btn_previous":"Previous",
13991402
"btn_next":"Next",

examples/locales/zh-CN/resources.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,8 @@ window.examplesResources = {
13401340
'text_ncp_confirmed_tooltip':"{name}:累计确诊 {confirmed}",
13411341
'text_ncp_confirmed':"累计确诊",
13421342
'text_ncpworld_incidence_title':"全球报告发病率(每10万人)",
1343+
'text_ncp_world':"世界疫情",
1344+
'text_ncp_china':"中国疫情",
13431345

13441346

13451347
"btn_previous":"上一步",

0 commit comments

Comments
 (0)