Skip to content

Commit

Permalink
feat: optimized display (#115)
Browse files Browse the repository at this point in the history
* doc: project clone description

* feat: Optimize table unknowns、Numbers are converted to thousands

---------

Co-authored-by: 刘少林 <18819270610@163.com>
  • Loading branch information
372798735 and 372798735 authored Apr 17, 2024
1 parent e494cd2 commit a0f47c1
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 7 deletions.
18 changes: 17 additions & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,23 @@ Github 全球/中国用户排名,全球仓库 Star 最多排名,通过 Githu

更新时间:<!--GAMFC-->2022-11-05 09:15:32<!--GAMFC-END-->

## 使用
## 克隆项目

```bash
git clone https://github.com/372798735/github-rank-fork.git
```
```bash
cd github-rank-fork

npm install
```
run
```bash
npm run start
```


## 插件使用

```bash
npm install @wcj/github-rank --save-dev
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,22 @@ Now it can be updated automatically every day, using [GitHub Actions Workflows](

Update date: <!--GAMFC-->2024-04-17 17:59:31<!--GAMFC-END-->

## Usage
## 克隆项目

```bash
git clone https://github.com/372798735/github-rank-fork.git
```
```bash
cd github-rank-fork

npm install
```
run
```bash
npm run start
```

## Plug-in Usage

```bash
npm install @wcj/github-rank --save-dev
Expand Down
2 changes: 1 addition & 1 deletion src/getUserInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import { type UsersData } from './common/props.js';
import { updateUsersData } from './utils/saveUsersData.js';

;(async () => {
; (async () => {
try {
// 获取【全球】用户数据排行榜
const users: UsersData[] = await updateUsersData('./dist/users.json', './.cache/users.json', '');
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function getTrendingData(type: string = 'daily') {
const enc = new TextDecoder("utf-8");
const html = enc.decode(buf);
const $ = cheerio.load(html)
$('.Box-row').each(function(idx, item) {
$('.Box-row').each(function (idx, item) {
// 不需要头像,避免被和谐
const fullName = $(item).find('h2 a').text().replace(/(\n|\s)/g, '');
const href = $(item).find('h2 a').attr('href')?.replace(/(\n|\s)/g, '');
Expand Down
2 changes: 1 addition & 1 deletion template/_partial/trending_list.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<svg aria-label="star" viewBox="0 0 14 16" version="1.1" width="14" height="16" role="img">
<path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z"></path>
</svg>
<span><%=repo.stargazers_count%></span>
<span><%=repo.stargazers_count/1000%>k</span>
</span>
<span class="star" title="Repo Forked">
<svg aria-label="repo-forked" height="16" viewBox="0 0 10 16" version="1.1" width="10" role="img">
Expand Down
20 changes: 19 additions & 1 deletion template/_partial/users_list.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<header>
<style>
.td-unknow{
color:#999;
}
</style>
</header>
<tr>
<tr title="<%=user.bio%>">
<td>
<a href="<%=user.html_url%>" target="_blank">
Expand All @@ -23,11 +31,21 @@
</div>
<span><%=user.login%></span>
</td>
<% if(user.location) { %>
<td><%=user.location%></td>
<% } %>
<% if(!user.location) { %>
<td class="td-unknow">未知</td>
<% } %>
<% if(user.company) { %>
<td><%=user.company%></td>
<% } %>
<% if(!user.company) { %>
<td class="td-unknow">未知</td>
<% } %>
<td>
<a href="<%=user.html_url%>?tab=followers" target="_blank">
<%=user.followers%>
<%=user.followers/1000%>k
</a>
</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion template/repos.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<svg aria-label="star" viewBox="0 0 14 16" version="1.1" width="14" height="16" role="img">
<path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z"></path>
</svg>
<span><%=repo.stargazers_count%></span>
<span><%=repo.stargazers_count/1000%>k</span>
</span>
</div>
<div class="details">
Expand Down

0 comments on commit a0f47c1

Please sign in to comment.