parent
f10d522a79
commit
78124a009f
|
@ -50,6 +50,10 @@ git:[@github/justice2001/halo-plugin-vditor]
|
|||
|
||||
---
|
||||
|
||||
git:[@gitee/blossom-editor/blossom]
|
||||
|
||||
---
|
||||
|
||||
drive:baidu
|
||||
name: 网站资源集合
|
||||
link: https://www.baidu.com/
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import {getGitHubInfo} from "./github-utils";
|
||||
import {HALO_RENDER_CACHE_VERSION, LANGUAGE_COLOR, RENDER_CLASS} from "../../constant";
|
||||
import {getGiteeInfo} from "./gitee-utils";
|
||||
|
||||
export const cache: {[key: string]: RepoInfo|-1} = {}
|
||||
|
||||
export const utils: {[key: string]: (args: IGitArgs) => Promise<RepoInfo>} = {
|
||||
"github": getGitHubInfo
|
||||
"github": getGitHubInfo,
|
||||
"gitee": getGiteeInfo
|
||||
}
|
||||
|
||||
export const icons: {[key: string]: string} = {
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
import {IGitArgs, RepoInfo} from "./git-processor";
|
||||
|
||||
export async function getGiteeInfo(args: IGitArgs): Promise<RepoInfo> {
|
||||
const info = await fetch(`https://gitee.com/api/v5/repos/${args.owner}/${args.repo}`)
|
||||
const json = await info.json()
|
||||
console.log(info)
|
||||
if (info.status !== 200) return new Promise((resolve, reject) => {
|
||||
reject({
|
||||
code: info.status,
|
||||
msg: json['message']
|
||||
})
|
||||
})
|
||||
const topics: Array<string> = []
|
||||
json["project_labels"].forEach((label: {
|
||||
id: number;
|
||||
name: string;
|
||||
ident: string
|
||||
}) => {
|
||||
topics.push(label.name)
|
||||
})
|
||||
return {
|
||||
platform: "gitee",
|
||||
url: json["html_url"],
|
||||
owner: json["owner"]["login"],
|
||||
name: json["name"],
|
||||
stars: json["stargazers_count"],
|
||||
watchers: json["watchers_count"],
|
||||
language: json["language"],
|
||||
description: json["description"],
|
||||
openIssues: json["open_issues_count"],
|
||||
lastPush: json["pushed_at"],
|
||||
forks: json["forks_count"],
|
||||
topic: topics
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue