From b3f39eadf51891170b743ed29c6848249cb71946 Mon Sep 17 00:00:00 2001 From: speakeloudest Date: Mon, 9 Feb 2026 10:53:03 +0200 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AEua=E5=A4=84=E7=90=86=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Home/components/DownloadButton.vue | 116 +++++++++++++------ vite.config.ts | 7 -- 2 files changed, 82 insertions(+), 41 deletions(-) diff --git a/src/pages/Home/components/DownloadButton.vue b/src/pages/Home/components/DownloadButton.vue index 95079e0..e72500f 100644 --- a/src/pages/Home/components/DownloadButton.vue +++ b/src/pages/Home/components/DownloadButton.vue @@ -1,28 +1,54 @@ @@ -31,36 +57,58 @@ import Icon1 from './Group 105.svg?component' import Icon2 from './Group 106.svg?component' import Icon3 from './Group 107.svg?component' import Icon4 from './Group 108.svg?component' -import request from '@/utils/request' -import {computed, ref} from "vue"; -import {getAllQueryString} from "@/utils/url-utils.ts"; -console.log(getAllQueryString('ic')); +import WinIcon from './WinIcon.svg?component' +import MacIcon from './MacIcon.svg?component' +import AppleIcon from './AppleIcon.svg?component' +import AndroidIcon from './AndroidIcon.svg?component' + +import request from '@/utils/request' +import {computed, ref, onMounted} from "vue"; +import {getAllQueryString} from "@/utils/url-utils.ts"; + +const downLoadWin = ref('') +const downLoadMac = ref('') +const currentPlatform = ref('win') + +onMounted(() => { + const ua = navigator.userAgent; + if (/Macintosh|Mac OS X/i.test(ua)) { + currentPlatform.value = 'mac' + } else if (/iPhone|iPad|iPod/i.test(ua)) { + currentPlatform.value = 'ios' + } else if (/Android/i.test(ua)) { + currentPlatform.value = 'android' + } else { + currentPlatform.value = 'win' + } +}) -const downLoadWin = ref('') -const downLoadMac = ref('') request.get('/api/v1/common/client/download', { invite_code: getAllQueryString('ic'), platform: 'mac', -}).then((res) => { +}).then((res: any) => { downLoadMac.value = res.url }) request.get('/api/v1/common/client/download', { invite_code: getAllQueryString('ic'), platform: 'windows', -}).then((res) => { +}).then((res: any) => { downLoadWin.value = res.url }) +const allDownloadOptions = computed(() => [ + { key: 'win', mainIcon: Icon1, secondaryIcon: WinIcon, link: downLoadWin.value, label: 'Windows', id: 'downloadButton_win' }, + { key: 'mac', mainIcon: Icon3, secondaryIcon: MacIcon, link: downLoadMac.value, label: 'macOS', id: 'downloadButton_mac' }, + { key: 'ios', mainIcon: Icon2, secondaryIcon: AppleIcon, label: 'iOS', id: 'downloadButton_apple' }, + { key: 'android', mainIcon: Icon4, secondaryIcon: AndroidIcon, label: 'Android', id: 'downloadButton_android' }, +]) -// 定义下载链接数据 -const downLoadIos = '' -const downloadLinks = computed(() => { - return [ - { icon: Icon2, id: 'downloadButton_apple', label: '下载 ios 版客户端' }, - { icon: Icon1, link: downLoadWin.value, label: '下载 Windows 版客户端' }, - { icon: Icon4, id: 'downloadButton_android', label: '下载 Android 版客户端' }, - { icon: Icon3, link: downLoadMac.value, label: '下载 macOS 版客户端' }, - ] +const mainButton = computed(() => { + return allDownloadOptions.value.find(opt => opt.key === currentPlatform.value) || allDownloadOptions.value[0] +}) + +const otherButtons = computed(() => { + return allDownloadOptions.value.filter(opt => opt.key !== currentPlatform.value) }) diff --git a/vite.config.ts b/vite.config.ts index b3fe030..27a91b6 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -22,13 +22,6 @@ export default defineConfig({ changeOrigin: true, // rewrite: (path) => path.replace(/^\/api/, ''), autoRewrite: true, - // 3. 关键:将路径重写,在前面补上 /api/v1 - // 验证请求是否进入代理,可以在终端看到打印 - configure: (proxy, _options) => { - proxy.on('proxyReq', (proxyReq, req, _res) => { - console.log('代理请求:', req.method, req.url, ' -> ', proxyReq.path) - }) - }, }, }, },