diff --git a/dist/index.js b/dist/index.js index 432578a..81cd5b9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -35257,7 +35257,11 @@ async function fetchContributionsFromCalendar(username, limit) { * 否则回落到无需认证的 gh-calendar。 */ async function fetchContributions(username, options = {}) { - const token = options.token?.trim() || process.env.GITHUB_TOKEN?.trim(); + // web 播放器在浏览器里运行,没有 process,按无 token 处理 + const envToken = typeof process === 'undefined' + ? undefined + : process.env.GITHUB_TOKEN?.trim(); + const token = options.token?.trim() || envToken; if (token) { return fetchContributionsFromGraphql(username, token, options.limit); } diff --git a/package.json b/package.json index d2a2104..ed14720 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "github-gravity", "description": "Generate an animated SVG of your GitHub contribution graph falling under gravity, with custom text as collision obstacles", - "version": "3.4.0", + "version": "3.4.1", "author": "flycran", "type": "module", "private": true, diff --git a/src/utils/githubContributions.ts b/src/utils/githubContributions.ts index 8ac2271..9f83a74 100644 --- a/src/utils/githubContributions.ts +++ b/src/utils/githubContributions.ts @@ -233,7 +233,12 @@ export async function fetchContributions( username: string, options: FetchContributionsOptions = {} ): Promise { - const token = options.token?.trim() || process.env.GITHUB_TOKEN?.trim() + // web 播放器在浏览器里运行,没有 process,按无 token 处理 + const envToken = + typeof process === 'undefined' + ? undefined + : process.env.GITHUB_TOKEN?.trim() + const token = options.token?.trim() || envToken if (token) { return fetchContributionsFromGraphql(username, token, options.limit)