diff --git a/os-checks/nuxt.config.ts b/os-checks/nuxt.config.ts index 293f659..330d607 100644 --- a/os-checks/nuxt.config.ts +++ b/os-checks/nuxt.config.ts @@ -27,6 +27,7 @@ export default defineNuxtConfig({ public: { debug: process.env.DEBUG ? true : false, docs_url: process.env.DOCS_URL, + database_repo: process.env.DATABASE_REPO, } } }) diff --git a/os-checks/utils/github-fetch.ts b/os-checks/utils/github-fetch.ts index 886179e..75be354 100644 --- a/os-checks/utils/github-fetch.ts +++ b/os-checks/utils/github-fetch.ts @@ -4,6 +4,11 @@ type Github = { path: string } +function defaultDatabaRepo(): string { + const runtimeConfig = useRuntimeConfig(); + return runtimeConfig.public.database_repo || "os-checker/database"; +} + // 当构建期间设置了 DEBUG 环境变量,则去 debug 分支而不是 main 分支拉取数据 function defaultBranch(): string { const runtimeConfig = useRuntimeConfig(); @@ -12,9 +17,9 @@ function defaultBranch(): string { // https://raw.githubusercontent.com/os-checker/os-checker.github.io/main/os-checks/public/test_raw_reports.json export default function (github: Github): Promise { - const repo = github.repo || "database"; + const repo = github.repo || defaultDatabaRepo(); const branch = github.branch || defaultBranch(); - const url = `https://raw.githubusercontent.com/os-checker/${repo}/${branch}/${github.path}`; + const url = `https://raw.githubusercontent.com/${repo}/${branch}/${github.path}`; return $fetch(url, { // 构造简单请求来解决跨域问题(同时 github raw 资源支持所有源) "headers": { "content-type": "text/plain" },