处理为openinstall
All checks were successful
site-dist-deploy / build-and-deploy (push) Successful in 1m25s
All checks were successful
site-dist-deploy / build-and-deploy (push) Successful in 1m25s
This commit is contained in:
parent
5a0f82704d
commit
1e26abf1d8
@ -8,7 +8,6 @@
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
:aria-label="mainButton.label"
|
:aria-label="mainButton.label"
|
||||||
class="flex h-full w-full items-center justify-center transition-transform hover:brightness-110 active:scale-95"
|
class="flex h-full w-full items-center justify-center transition-transform hover:brightness-110 active:scale-95"
|
||||||
@click.prevent="handleDownload(mainButton)"
|
|
||||||
>
|
>
|
||||||
<component :is="mainButton.mainIcon" class="h-auto w-full text-black transition-transform" />
|
<component :is="mainButton.mainIcon" class="h-auto w-full text-black transition-transform" />
|
||||||
</a>
|
</a>
|
||||||
@ -16,8 +15,8 @@
|
|||||||
v-else
|
v-else
|
||||||
:id="mainButton?.id"
|
:id="mainButton?.id"
|
||||||
:aria-label="mainButton?.label"
|
:aria-label="mainButton?.label"
|
||||||
|
@click="handleDownload(mainButton.key)"
|
||||||
class="flex h-full w-full cursor-pointer items-center justify-center transition-transform hover:brightness-110 active:scale-95"
|
class="flex h-full w-full cursor-pointer items-center justify-center transition-transform hover:brightness-110 active:scale-95"
|
||||||
@click="handleDownload(mainButton)"
|
|
||||||
>
|
>
|
||||||
<component :is="mainButton?.mainIcon" class="h-auto w-full text-black transition-transform" />
|
<component :is="mainButton?.mainIcon" class="h-auto w-full text-black transition-transform" />
|
||||||
</div>
|
</div>
|
||||||
@ -37,7 +36,6 @@
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
:aria-label="item.label"
|
:aria-label="item.label"
|
||||||
class="transition-transform hover:brightness-110 active:scale-95"
|
class="transition-transform hover:brightness-110 active:scale-95"
|
||||||
@click.prevent="handleDownload(item)"
|
|
||||||
>
|
>
|
||||||
<component :is="item.secondaryIcon" class="h-[24px] md:h-[34px] text-white" />
|
<component :is="item.secondaryIcon" class="h-[24px] md:h-[34px] text-white" />
|
||||||
</a>
|
</a>
|
||||||
@ -45,8 +43,8 @@
|
|||||||
v-else
|
v-else
|
||||||
:id="item.id"
|
:id="item.id"
|
||||||
:aria-label="item.label"
|
:aria-label="item.label"
|
||||||
|
@click="handleDownload(item.key)"
|
||||||
class="cursor-pointer transition-transform hover:brightness-110 active:scale-95"
|
class="cursor-pointer transition-transform hover:brightness-110 active:scale-95"
|
||||||
@click="handleDownload(item)"
|
|
||||||
>
|
>
|
||||||
<component :is="item.secondaryIcon" class="h-[24px] md:h-[34px] text-white" />
|
<component :is="item.secondaryIcon" class="h-[24px] md:h-[34px] text-white" />
|
||||||
</div>
|
</div>
|
||||||
@ -68,9 +66,9 @@ import AndroidIcon from './AndroidIcon.svg?component'
|
|||||||
|
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
import {computed, ref, onMounted} from "vue";
|
import {computed, ref, onMounted} from "vue";
|
||||||
import {getAllQueryString} from "../../../utils/url-utils";
|
import {getAllQueryString} from "@/utils/url-utils.ts";
|
||||||
import AdjustUtil from "../../../utils/adjust";
|
|
||||||
|
|
||||||
|
const downLoadWin = ref('')
|
||||||
const currentPlatform = ref('win')
|
const currentPlatform = ref('win')
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -103,41 +101,44 @@ onMounted(() => {
|
|||||||
console.log('Detected Platform:', currentPlatform.value);
|
console.log('Detected Platform:', currentPlatform.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleDownload = (item: any) => {
|
// request.get('/api/v1/common/client/download', {
|
||||||
console.log('Downloading:', item.label, item.link);
|
// invite_code: getAllQueryString('ic'),
|
||||||
// 记录点击事件(通过 key 自动映射令牌)
|
// platform: 'windows',
|
||||||
AdjustUtil.trackEvent(item.key);
|
// }).then((res: any) => {
|
||||||
|
// downLoadWin.value = res.url
|
||||||
|
// })
|
||||||
|
|
||||||
if (item.key === 'win') {
|
const handleDownload = async (key: string) => {
|
||||||
// Windows 平台:点击时请求下载地址
|
const platformMap: Record<string, string> = {
|
||||||
request.get('/api/v1/common/client/download', {
|
win: 'windows',
|
||||||
invite_code: getAllQueryString('ic'),
|
mac: 'mac',
|
||||||
platform: 'windows',
|
android: 'android',
|
||||||
}).then((res: any) => {
|
ios: 'ios',
|
||||||
if (res.url) {
|
|
||||||
window.open(res.url, '_blank');
|
|
||||||
}
|
|
||||||
}).catch((err: any) => {
|
|
||||||
console.error('Failed to fetch windows download link:', err);
|
|
||||||
});
|
|
||||||
} else if (item.link) {
|
|
||||||
// 其他平台:直接打开链接
|
|
||||||
window.open(item.link, '_blank');
|
|
||||||
}
|
}
|
||||||
};
|
const platform = platformMap[key] || 'windows'
|
||||||
|
|
||||||
const allDownloadOptions = computed(() => {
|
try {
|
||||||
const androidLink = currentPlatform.value === 'android'
|
const res: any = await request.get('/api/v1/common/client/download', {
|
||||||
? AdjustUtil.getDecoratedLink()
|
invite_code: getAllQueryString('ic'),
|
||||||
: 'https://api.hifast.biz/v1/common/client/download/file/Hi%E5%BF%ABVPN-android-1.0.0.apk'
|
platform: platform,
|
||||||
|
})
|
||||||
|
if (res.url) {
|
||||||
|
if (key === 'win') {
|
||||||
|
downLoadWin.value = res.url
|
||||||
|
}
|
||||||
|
window.open(res.url, '_blank')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Download fetch failed', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
const allDownloadOptions = computed(() => [
|
||||||
{ key: 'win', mainIcon: Icon1, secondaryIcon: WinIcon, link: '', label: 'Windows', id: 'downloadButton_win' },
|
{ key: 'win', mainIcon: Icon1, secondaryIcon: WinIcon, link: downLoadWin.value, label: 'Windows', id: 'downloadButton_win' },
|
||||||
{ key: 'mac', mainIcon: Icon3, secondaryIcon: MacIcon, label: 'macOS', link: AdjustUtil.getDecoratedLink() },
|
{ key: 'mac', mainIcon: Icon3, secondaryIcon: MacIcon, label: 'macOS', id: 'downloadButton_mac' },
|
||||||
{ key: 'ios', mainIcon: Icon2, secondaryIcon: AppleIcon, label: 'iOS', link: AdjustUtil.getDecoratedLink() },
|
{ key: 'ios', mainIcon: Icon2, secondaryIcon: AppleIcon, label: 'iOS', id: 'downloadButton_apple' },
|
||||||
{ key: 'android', mainIcon: Icon4, secondaryIcon: AndroidIcon, label: 'Android', link: androidLink },
|
{ key: 'android', mainIcon: Icon4, secondaryIcon: AndroidIcon, label: 'Android', id: 'downloadButton_android' },
|
||||||
]
|
])
|
||||||
})
|
|
||||||
|
|
||||||
const mainButton = computed(() => {
|
const mainButton = computed(() => {
|
||||||
return allDownloadOptions.value.find(opt => opt.key === currentPlatform.value) || allDownloadOptions.value[0]
|
return allDownloadOptions.value.find(opt => opt.key === currentPlatform.value) || allDownloadOptions.value[0]
|
||||||
@ -147,3 +148,4 @@ const otherButtons = computed(() => {
|
|||||||
return allDownloadOptions.value.filter(opt => opt.key !== currentPlatform.value)
|
return allDownloadOptions.value.filter(opt => opt.key !== currentPlatform.value)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user