diff --git a/app.config.ts b/app.config.ts new file mode 100644 index 0000000..d97b604 --- /dev/null +++ b/app.config.ts @@ -0,0 +1,18 @@ +export default defineAppConfig({ + latestNews: { + title: "🎉社区吉祥物「星小火」", + link: "https://tai3.cn", + }, + // 不设置 latestRelease 时,默认为构建时从 Gitee 获取的最新版本信息 + // latestRelease: { + // tag_name: "1.0.0", + // created_at: "2024-11-01T00:00:00Z", + // body: "Initial release of Spark Store.", + // assets: [ + // { + // name: "spark-store-1.0.0-amd64.deb", + // browser_download_url: "https://example.com/spark-store-1.0.0-amd64.deb", + // } + // ], + // }, +}); diff --git a/app.vue b/app.vue index 7a81bd2..8464cbc 100644 --- a/app.vue +++ b/app.vue @@ -2,6 +2,8 @@ import ScrollPanel from "primevue/scrollpanel"; import Button from "primevue/button"; +const appConfig = useAppConfig(); + const path = computed(() => { return useRoute().path; }); @@ -176,9 +178,21 @@ export interface Release { body: string; } -const { data: latestRelease }: { data: Ref } = await useFetch( - "https://gitee.com/api/v5/repos/spark-store-project/spark-store/releases/latest" -); +const latestRelease: Ref = ref({ + assets: [], + tag_name: "", + created_at: "", + body: "", +}); + +if (appConfig.latestRelease) { + latestRelease.value = appConfig.latestRelease as Release; +} else { + const { data: data }: { data: Ref } = await useFetch( + "https://gitee.com/api/v5/repos/spark-store-project/spark-store/releases/latest" + ); + latestRelease.value = data.value; +} provide("latestRelease", latestRelease); diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..6b35212 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,16 @@ +import type { Release } from "./app.vue"; + +declare module "nuxt/schema" { + interface AppConfigInput { + latestRelease?: Release; + latestNews: { + title: string; + link: string; + }; + } + + type AppConfig = AppConfigInput; +} + +// It is always important to ensure you import/export something when augmenting a type +export {}; diff --git a/pages/index.vue b/pages/index.vue index dbb8d45..f3c2241 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,6 +1,8 @@