mirror of
https://github.com/gkd-kit/docs.git
synced 2024-11-16 13:22:20 +08:00
feat: add beta download
This commit is contained in:
parent
45978e3e2e
commit
5521c18eac
|
@ -1,6 +1,12 @@
|
|||
<script setup lang="ts">
|
||||
import { computed, shallowRef, onMounted } from 'vue';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { computed, onMounted, shallowRef } from 'vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
beta?: boolean;
|
||||
}>(),
|
||||
{},
|
||||
);
|
||||
|
||||
const apkUrl = shallowRef('');
|
||||
const apkName = computed(() =>
|
||||
|
@ -11,27 +17,37 @@ const loading = shallowRef(false);
|
|||
const downloadApk = async () => {
|
||||
if (!apkUrl.value || loading.value) return;
|
||||
loading.value = true;
|
||||
const file = await fetch(apkUrl.value)
|
||||
.then((r) => r.arrayBuffer())
|
||||
.then(
|
||||
(b) =>
|
||||
new File([b], apkName.value, {
|
||||
type: 'application/vnd.android.package-archive',
|
||||
}),
|
||||
)
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
saveAs(file, apkName.value);
|
||||
try {
|
||||
const file = await fetch(apkUrl.value)
|
||||
.then((r) => r.arrayBuffer())
|
||||
.then(
|
||||
(b) =>
|
||||
new File([b], apkName.value, {
|
||||
type: 'application/vnd.android.package-archive',
|
||||
}),
|
||||
);
|
||||
const { saveAs } = await import('file-saver');
|
||||
saveAs(file, apkName.value);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// preload file-saver in browser
|
||||
if (globalThis.document) {
|
||||
import('file-saver');
|
||||
}
|
||||
|
||||
const pkg = computed(() => (props.beta ? 'app-beta' : 'app'));
|
||||
const key = computed(() => `apkUrl-${pkg.value}`);
|
||||
|
||||
onMounted(async () => {
|
||||
apkUrl.value = localStorage.getItem('apkUrl') || '';
|
||||
const versionUrl = 'https://registry.npmmirror.com/@gkd-kit/app/latest/files';
|
||||
apkUrl.value = localStorage.getItem(key.value) || '';
|
||||
const versionUrl = `https://registry.npmmirror.com/@gkd-kit/${pkg.value}/latest/files`;
|
||||
const r = await fetch(versionUrl);
|
||||
const data = await r.json();
|
||||
apkUrl.value = new URL(data.downloadUrl, r.url).href;
|
||||
localStorage.setItem('apkUrl', apkUrl.value);
|
||||
localStorage.setItem(key.value, apkUrl.value);
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
# 开始使用 {#title}
|
||||
|
||||
## 下载安装 {#install}
|
||||
## 安装 {#install}
|
||||
|
||||
- 镜像加速 <ClientOnly><ApkDownloadButton /></ClientOnly>
|
||||
| 版本 | 下载链接 | 备注 |
|
||||
| ------ | -------------------------- | -------------- |
|
||||
| 正式版 | <ApkDownloadButton /> | 稳定版 |
|
||||
| 测试版 | <ApkDownloadButton beta /> | 更新快不稳定 |
|
||||
|
||||
- Github [releases](https://github.com/gkd-kit/gkd/releases/latest)
|
||||
或前往 [Github Releases](https://github.com/gkd-kit/gkd/releases/latest) 下载
|
||||
|
||||
下载完毕后, 在您的 Android 手机上安装并打开
|
||||
|
||||
## 授权使用 {#usage}
|
||||
## 使用 {#usage}
|
||||
|
||||
打开后进入 GKD 的首页, 要想 GKD 正常工作需要授权无障碍权限
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user