Skip to content

Commit ffa0ea9

Browse files
committed
feat(nuxt.config): support DATABASE_REPO
1 parent 0ad31dc commit ffa0ea9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

os-checks/nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default defineNuxtConfig({
2727
public: {
2828
debug: process.env.DEBUG ? true : false,
2929
docs_url: process.env.DOCS_URL,
30+
database_repo: process.env.DATABASE_REPO,
3031
}
3132
}
3233
})

os-checks/utils/github-fetch.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ type Github = {
44
path: string
55
}
66

7+
function defaultDatabaRepo(): string {
8+
const runtimeConfig = useRuntimeConfig();
9+
return runtimeConfig.public.database_repo || "os-checker/database";
10+
}
11+
712
// 当构建期间设置了 DEBUG 环境变量,则去 debug 分支而不是 main 分支拉取数据
813
function defaultBranch(): string {
914
const runtimeConfig = useRuntimeConfig();
@@ -12,9 +17,9 @@ function defaultBranch(): string {
1217

1318
// https://raw.githubusercontent.com/os-checker/os-checker.github.io/main/os-checks/public/test_raw_reports.json
1419
export default function <T>(github: Github): Promise<T> {
15-
const repo = github.repo || "database";
20+
const repo = github.repo || defaultDatabaRepo();
1621
const branch = github.branch || defaultBranch();
17-
const url = `https://raw.githubusercontent.com/os-checker/${repo}/${branch}/${github.path}`;
22+
const url = `https://raw.githubusercontent.com/${repo}/${branch}/${github.path}`;
1823
return $fetch(url, {
1924
// 构造简单请求来解决跨域问题(同时 github raw 资源支持所有源)
2025
"headers": { "content-type": "text/plain" },

0 commit comments

Comments
 (0)