Skip to content

Commit

Permalink
support division leaderboard
Browse files Browse the repository at this point in the history
Signed-off-by: frank-zsy <syzhao1988@126.com>
  • Loading branch information
frank-zsy committed Dec 1, 2024
1 parent ad90e89 commit 7925082
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
12 changes: 12 additions & 0 deletions i18n/en/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,17 @@
},
"leaderboards.companies.country": {
"message": "Country"
},
"leaderboards.provinces.title": {
"message": "2024 Global Administrative Divisions OpenRank Top 100"
},
"leaderboards.provinces.name": {
"message": "Division Name"
},
"leaderboards.provinces.developers": {
"message": "Developers Count (10k)"
},
"leaderboards.provinces.country": {
"message": "Country"
}
}
12 changes: 12 additions & 0 deletions i18n/zh/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,17 @@
},
"leaderboards.companies.country": {
"message": "所在国家"
},
"leaderboards.provinces.title": {
"message": "2024 全球各国行政区 OpenRank 排行榜 Top 100"
},
"leaderboards.provinces.name": {
"message": "行政区名称"
},
"leaderboards.provinces.developers": {
"message": "开发者规模(万)"
},
"leaderboards.provinces.country": {
"message": "所属国家"
}
}
19 changes: 18 additions & 1 deletion src/pages/leaderboards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
import Layout from '@theme/Layout';
import SimpleTable from '../../components/SimpleTable';
import { translate } from '@docusaurus/Translate';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import axios from 'axios';
import styles from './styles.module.css';

Expand All @@ -10,6 +11,7 @@ function OpenLeaderboard() {
const [title, setTitle] = useState('Ranking List Title');
const [data, setData] = useState([]);
const [options, setOptions] = useState([]);
const { i18n } = useDocusaurusContext();

useEffect(() => {
const search = new URLSearchParams(window.location.search);
Expand Down Expand Up @@ -44,7 +46,22 @@ function OpenLeaderboard() {
{ name: 'OpenRank', type: 'String', fields: ['openrank'], width: 200 },
{ name: translate({ id: 'leaderboards.companies.repos' }), type: 'String', fields: ['repoCount'], width: 200 },
{ name: translate({ id: 'leaderboards.companies.developers' }), type: 'String', fields: ['developerCount'], width: 200 },
{ name: translate({ id: 'leaderboards.companies.country' }), type: 'String', fields: ['country'], width: 200 },
{ name: translate({ id: 'leaderboards.companies.country' }), type: 'String', fields: [i18n.currentLocale === 'zh' ? 'country_zh' : 'country'], width: 200 },
]);
}).catch(e => {
console.log(e);
});
} else if (type === 'divisions') {
axios.get(`https://oss.open-digger.cn/leaderboards/${type}.json`).then(resp => {
const data = resp.data;
setTitle(translate({ id: 'leaderboards.provinces.title' }));
setData(data.data);
setOptions([
{ name: '#', type: 'String', fields: ['rank'], width: 80 },
{ name: translate({ id: 'leaderboards.provinces.name' }), type: 'String', fields: [i18n.currentLocale === 'zh' ? 'province_zh' : 'province'], width: 300 },
{ name: 'OpenRank', type: 'String', fields: ['openrank'], width: 300 },
{ name: translate({ id: 'leaderboards.provinces.developers' }), type: 'String', fields: ['developerCount'], width: 300 },
{ name: translate({ id: 'leaderboards.provinces.country' }), type: 'String', fields: [i18n.currentLocale === 'zh' ? 'country_zh' : 'country'], width: 300 },
]);
}).catch(e => {
console.log(e);
Expand Down

0 comments on commit 7925082

Please sign in to comment.