实现基本功能

This commit is contained in:
2021-07-26 17:26:58 +08:00
commit 78addb6d96
22 changed files with 8717 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
/**
* 仓库搜索结果单条记录
*/
export interface RepositorySearchResultItem {
id: number,
node_id: string,
name: string,
full_name: string,
private: boolean,
stargazers_count: number,
watchers_count: number,
forks_count:number
}
/**
* 仓库搜索结果
*/
export interface RepositorySearchResultList {
total_count:number,
incomplete_results:boolean,
items:RepositorySearchResultItem[]
}
+11
View File
@@ -0,0 +1,11 @@
import { RepositorySearchResultList } from './api'
export async function search (keyword:string, page:number) {
const url = new URL('https://api.github.com/search/repositories')
url.searchParams.append('q', keyword)
url.searchParams.append('page', page.toString())
const response = await fetch(url.toString(), { method: 'get' })
const result = await response.json()
return result as RepositorySearchResultList
}