From 06cc806834d18881e9c7baf4b916414520c798f3 Mon Sep 17 00:00:00 2001 From: lisonge Date: Tue, 15 Oct 2024 15:48:00 +0800 Subject: [PATCH] feat: ApkTable --- .../components/ApkDownloadButton.vue | 84 ------------------ docs/.vitepress/components/ApkTable.vue | 34 +++++++ docs/.vitepress/components/DownloadText.vue | 88 +++++++++++++++++++ docs/.vitepress/components/index.ts | 8 +- docs/.vitepress/data/apk.data.ts | 39 ++++++++ docs/.vitepress/data/mirror.data.ts | 12 +++ docs/.vitepress/env.d.ts | 2 - docs/.vitepress/utils/img.ts | 8 +- docs/guide/index.md | 5 +- docs/vite.config.ts | 12 +-- 10 files changed, 183 insertions(+), 109 deletions(-) delete mode 100644 docs/.vitepress/components/ApkDownloadButton.vue create mode 100644 docs/.vitepress/components/ApkTable.vue create mode 100644 docs/.vitepress/components/DownloadText.vue create mode 100644 docs/.vitepress/data/apk.data.ts create mode 100644 docs/.vitepress/data/mirror.data.ts diff --git a/docs/.vitepress/components/ApkDownloadButton.vue b/docs/.vitepress/components/ApkDownloadButton.vue deleted file mode 100644 index 9b2bc98..0000000 --- a/docs/.vitepress/components/ApkDownloadButton.vue +++ /dev/null @@ -1,84 +0,0 @@ - - diff --git a/docs/.vitepress/components/ApkTable.vue b/docs/.vitepress/components/ApkTable.vue new file mode 100644 index 0000000..f081b15 --- /dev/null +++ b/docs/.vitepress/components/ApkTable.vue @@ -0,0 +1,34 @@ + + diff --git a/docs/.vitepress/components/DownloadText.vue b/docs/.vitepress/components/DownloadText.vue new file mode 100644 index 0000000..5553b20 --- /dev/null +++ b/docs/.vitepress/components/DownloadText.vue @@ -0,0 +1,88 @@ + + diff --git a/docs/.vitepress/components/index.ts b/docs/.vitepress/components/index.ts index 8c6b56f..8751099 100644 --- a/docs/.vitepress/components/index.ts +++ b/docs/.vitepress/components/index.ts @@ -1,13 +1,13 @@ -import naiveComponents from './naive'; +import ApkTable from './ApkTable.vue'; import GImg from './GImg'; -import ImageTable from './ImageTable.vue'; import IdentifierField from './IdentifierField.vue'; -import ApkDownloadButton from './ApkDownloadButton.vue'; +import ImageTable from './ImageTable.vue'; +import naiveComponents from './naive'; export default { ...naiveComponents, GImg, ImageTable, IdentifierField, - ApkDownloadButton + ApkTable, }; diff --git a/docs/.vitepress/data/apk.data.ts b/docs/.vitepress/data/apk.data.ts new file mode 100644 index 0000000..4725170 --- /dev/null +++ b/docs/.vitepress/data/apk.data.ts @@ -0,0 +1,39 @@ +export interface VersionInfo { + name: string; + date: string; + href: string; + filename: string; +} +export interface ApkData { + stable: VersionInfo; + beta: VersionInfo; +} + +const getVersionInfo = async (url: string): Promise => { + const r = await fetch(url).then((r) => r.json()); + return { + name: r.versionName, + href: new URL(r.downloadUrl, url).href, + date: String(r.date || '').substring(0, 10), + filename: 'gkd-v' + r.versionName + '.apk', + }; +}; + +const stableRelease = await getVersionInfo( + 'https://registry.npmmirror.com/@gkd-kit/app/latest/files/index.json', +); +const betaRelease = await getVersionInfo( + 'https://registry.npmmirror.com/@gkd-kit/app-beta/latest/files/index.json', +); + +const load = async (): Promise => { + return { + stable: stableRelease, + beta: betaRelease, + }; +}; + +export default { + load, +}; +export declare const data: ApkData; diff --git a/docs/.vitepress/data/mirror.data.ts b/docs/.vitepress/data/mirror.data.ts new file mode 100644 index 0000000..e1788cd --- /dev/null +++ b/docs/.vitepress/data/mirror.data.ts @@ -0,0 +1,12 @@ +const load = async (): Promise => { + const version = await fetch( + 'https://registry.npmmirror.com/@gkd-kit/assets/latest/files/package.json', + ).then((r) => r.json().then((j) => j.version as string)); + + return `https://registry.npmmirror.com/@gkd-kit/assets/${version}/files/assets/`; +}; + +export default { + load, +}; +export declare const data: string; diff --git a/docs/.vitepress/env.d.ts b/docs/.vitepress/env.d.ts index 1e71a9e..5892d7d 100644 --- a/docs/.vitepress/env.d.ts +++ b/docs/.vitepress/env.d.ts @@ -1,3 +1 @@ /// - -declare const ASSETS_VERSION: string diff --git a/docs/.vitepress/utils/img.ts b/docs/.vitepress/utils/img.ts index edbf353..14505a1 100644 --- a/docs/.vitepress/utils/img.ts +++ b/docs/.vitepress/utils/img.ts @@ -1,14 +1,12 @@ -const mirrorHost = () => { - return `https://registry.npmmirror.com/@gkd-kit/assets/${ASSETS_VERSION}/files/assets/`; -}; +import { data as mirrorHost } from '../data/mirror.data'; const imgHost = 'https://a.gkd.li/'; export const convertSrc = (name: string): string => { if (name && name.startsWith('https:')) { if (name.startsWith(imgHost)) { - return mirrorHost() + name.slice(imgHost.length); + return mirrorHost + name.slice(imgHost.length); } return name; } - return mirrorHost() + name; + return mirrorHost + name; }; diff --git a/docs/guide/index.md b/docs/guide/index.md index 6aaa071..e1f10c3 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -2,10 +2,7 @@ ## 安装 {#install} -| 版本 | 下载链接 | 更新日期 | 备注 | -| ------ | -------------------------- | ---------- | ------------ | -| 正式版 | | 2024-08-27 | 稳定版 | -| 测试版 | | 2024-10-03 | 更新快不稳定 | + 或前往 [Github Releases](https://github.com/gkd-kit/gkd/releases/latest) 下载 diff --git a/docs/vite.config.ts b/docs/vite.config.ts index 8ca98fe..d5d4522 100644 --- a/docs/vite.config.ts +++ b/docs/vite.config.ts @@ -1,17 +1,9 @@ -import { defineConfig } from 'vite'; import unocss from 'unocss/vite'; +import { defineConfig } from 'vite'; import { mirror } from './.vitepress/plugins'; -const ASSETS_VERSION = await fetch( - 'https://registry.npmmirror.com/@gkd-kit/assets/latest/files/package.json', -).then((r) => r.json().then((j) => j.version as string)); - export default defineConfig({ - define: { ASSETS_VERSION: JSON.stringify(ASSETS_VERSION) }, - plugins: [ - unocss(), - mirror(), - ], + plugins: [unocss(), mirror()], server: { host: '127.0.0.1', port: 8633,