diff --git a/src/main.ts b/src/main.ts
index d9d0fe9..b560ffc 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,6 +2,7 @@ import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './styles/index.css'
+import '@/utils/openinstall'
const app = createApp(App)
diff --git a/src/pages/Help/index.vue b/src/pages/Help/index.vue
index 502cda4..195cbdd 100644
--- a/src/pages/Help/index.vue
+++ b/src/pages/Help/index.vue
@@ -71,9 +71,12 @@
登录海外 Apple ID 后再点击下方下载按钮
@@ -103,12 +106,15 @@
其他客户端下载
@@ -131,63 +137,43 @@ import DownloadMethodList from './DownloadMethodList/DownloadMethodList.vue'
import FAQAccordion from './FAQAccordion/index.vue'
import { Button } from '@/components/ui/button'
-const ic = getAllQueryString('ic') || sessionStorage.getItem('ic')
-const ADJ_GO_LINK =
- ic && typeof ic === 'string'
- ? `https://hifastvpn.go.link?adj_t=1xf6e7ru&inviteCode=${ic}`
- : 'https://hifastvpn.go.link/?adj_t=1xf6e7ru'
+const handleDownload = async (key: string) => {
+ const platformMap: Record = {
+ window: 'windows',
+ mac: 'mac',
+ android: 'android',
+ ios: 'ios',
+ }
+ const platform = platformMap[key] || 'windows'
+ const ic = getAllQueryString('ic') || sessionStorage.getItem('ic') || 'uSSfg1Y1vt'
-const getTrackedUrl = (url: string) => {
- if (!url) return ''
- return `${ADJ_GO_LINK}&adj_redirect=${encodeURIComponent(url)}`
+ if (platform === 'ios') {
+ if (window.OI_SDK && window.OI_SDK.OI) {
+ window.OI_SDK.OI.wakeupOrInstall({ data: { platform: 'download', inviteCode: ic } })
+ return
+ }
+ }
+
+ try {
+ const res: any = await request.get('/api/v1/common/client/download', {
+ invite_code: ic,
+ platform: platform,
+ })
+ if (res.url) {
+ window.open(res.url, '_blank')
+ }
+ } catch (error) {
+ console.error('Download fetch failed', error)
+ }
}
-const downLoadWin = ref(
- getTrackedUrl(
- 'https://api.hifast.biz/v1/common/client/download/file/Hi快VPN-windows-1.0.0.exe',
- ),
-)
-const downLoadMac = ref(ADJ_GO_LINK)
-const downLoadIos = ref(ADJ_GO_LINK)
-const downLoadAndroid = ref(
- ic && typeof ic === 'string'
- ? `https://hifastvpn.go.link?adj_t=1xf6e7ru&inviteCode=${ic}`
- : 'https://api.hifast.biz/v1/common/client/download/file/Hi%E5%BF%ABVPN-android-1.0.0.apk',
-)
-// request
-// .get('/api/v1/common/client/download', {
-// // invite_code: getAllQueryString('ic'),
-// platform: 'mac',
-// })
-// .then((res) => {
-// downLoadMac.value = res.url
-// })
-//
-// request
-// .get('/api/v1/common/client/download', {
-// // invite_code: getAllQueryString('ic'),
-// platform: 'windows',
-// })
-// .then((res) => {
-// downLoadWin.value = res.url
-// })
-//
-// request
-// .get('/api/v1/common/client/download', {
-// // invite_code: getAllQueryString('ic'),
-// platform: 'android',
-// })
-// .then((res) => {
-// downLoadAndroid.value = res.url
-// })
-
const activeIndex = ref(0)
const otherClients = computed(() => {
return [
- { icon: WindowsIcon, link: downLoadWin.value, type: 'window' },
- { icon: MacosIcon, link: downLoadMac.value, type: 'mac' },
- { icon: AndroidIcon, link: downLoadAndroid.value, type: 'android' },
+ { icon: WindowsIcon, type: 'window' },
+ { icon: MacosIcon, type: 'mac' },
+ { icon: AndroidIcon, type: 'android' },
]
})
diff --git a/src/pages/Home/components/DownloadButton.vue b/src/pages/Home/components/DownloadButton.vue
index 185bf88..237b76e 100644
--- a/src/pages/Home/components/DownloadButton.vue
+++ b/src/pages/Home/components/DownloadButton.vue
@@ -4,8 +4,18 @@
+
+
+
@@ -120,15 +132,31 @@ onMounted(() => {
// downLoadMac.value = res.url
// })
-const ic = getAllQueryString('ic') || sessionStorage.getItem('ic')
-const ADJ_GO_LINK =
- ic && typeof ic === 'string'
- ? `https://hifastvpn.go.link?adj_t=1xf6e7ru&inviteCode=${ic}`
- : 'https://hifastvpn.go.link/?adj_t=1xf6e7ru'
+const downLoadWin = ref('')
-const getTrackedUrl = (target: string) => {
- if (!target) return ''
- return `${ADJ_GO_LINK}&adj_redirect=${encodeURIComponent(target)}`
+const handleDownload = async (key: string) => {
+ const platformMap: Record = {
+ win: 'windows',
+ mac: 'mac',
+ android: 'android',
+ ios: 'ios',
+ }
+ const platform = platformMap[key] || 'windows'
+
+ try {
+ const res: any = await request.get('/api/v1/common/client/download', {
+ invite_code: getAllQueryString('ic') || sessionStorage.getItem('ic') || 'uSSfg1Y1vt',
+ 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)
+ }
}
const allDownloadOptions = computed(() => [
@@ -136,9 +164,7 @@ const allDownloadOptions = computed(() => [
key: 'win',
mainIcon: Icon1,
secondaryIcon: WinIcon,
- link: getTrackedUrl(
- 'https://api.hifast.biz/v1/common/client/download/file/Hi快VPN-windows-1.0.0.exe',
- ),
+ link: downLoadWin.value,
label: 'Windows',
id: 'downloadButton_win',
},
@@ -146,26 +172,20 @@ const allDownloadOptions = computed(() => [
key: 'mac',
mainIcon: Icon3,
secondaryIcon: MacIcon,
- link: ADJ_GO_LINK,
+ link: '/help',
label: 'macOS',
- id: 'downloadButton_mac',
},
{
key: 'ios',
mainIcon: Icon2,
secondaryIcon: AppleIcon,
- link: ADJ_GO_LINK,
+ link: '/help',
label: 'iOS',
- id: 'downloadButton_apple',
},
{
key: 'android',
mainIcon: Icon4,
secondaryIcon: AndroidIcon,
- link:
- ic && typeof ic === 'string'
- ? `https://hifastvpn.go.link?adj_t=1xf6e7ru&inviteCode=${ic}`
- : 'https://api.hifast.biz/v1/common/client/download/file/Hi%E5%BF%ABVPN-android-1.0.0.apk',
label: 'Android',
id: 'downloadButton_android',
},
@@ -173,20 +193,7 @@ const allDownloadOptions = computed(() => [
const mainButton = computed(() => {
const platform = currentPlatform.value
- const opt =
- allDownloadOptions.value.find((opt) => opt.key === platform) || allDownloadOptions.value[0]
-
- if (['mac', 'android', 'ios'].includes(platform)) {
- // Android 无邀请码时使用直传链接(即 opt.link)
- if (platform === 'android' && !(ic && typeof ic === 'string')) {
- return opt
- }
- return {
- ...opt,
- link: ADJ_GO_LINK,
- }
- }
- return opt
+ return allDownloadOptions.value.find((opt) => opt.key === platform) || allDownloadOptions.value[0]
})
const otherButtons = computed(() => {
diff --git a/src/utils/openinstall.ts b/src/utils/openinstall.ts
new file mode 100644
index 0000000..df5c01d
--- /dev/null
+++ b/src/utils/openinstall.ts
@@ -0,0 +1,87 @@
+import { getAllQueryString } from '@/utils/url-utils.ts'
+
+/**
+ * OpenInstall sdk 用于上报h5邀请参数
+ * 自动注册openinstall sdk 挂在到window对象上 通过window.OI_SDK访问
+ * sdk初始化时会自动检索url上的参数并作为拉起下载或唤醒app时的参数
+ */
+const script = document.createElement('script')
+script.type = 'text/javascript'
+script.charset = 'UTF-8'
+script.src = 'https://web.cdn.openinstall.io/openinstall.js'
+document.head.appendChild(script)
+
+script.addEventListener('load', () => {
+ window.OI_SDK = new OpenInstallSdk()
+})
+
+class OpenInstallSdk {
+ public urlQuery: any // openinstall.js中提供的api,解析当前网页url中的查询参数并对data进行赋值
+
+ public OI: Record // openinstall 实例
+
+ constructor() {
+ this.OI = {}
+ this.urlQuery = window.OpenInstall.parseUrlParams()
+ const id = getAllQueryString('id')
+ if (id) {
+ this.urlQuery = {
+ platform: 'merchant',
+ code: id,
+ }
+ }
+ this.init()
+ }
+
+ async init() {
+ try {
+ this.OI = new window.OpenInstall(
+ {
+ appKey: 'alf57p',
+ onready: function () {
+ // 初始化成功回调方法。当初始化完成后,会自动进入
+ this.schemeWakeup() // 尝试使用scheme打开App(主要用于Android以及iOS的QQ环境中)
+ const m = this
+ const button = document.getElementById('downloadButton_apple')
+ const button_mac = document.getElementById('downloadButton_mac')
+ const button1 = document.getElementById('downloadButton_android')
+ const ic = getAllQueryString('ic') || 'uSSfg1Y1vt'
+ if (button) {
+ button.onclick = function () {
+ if (ic) {
+ m.wakeupOrInstall({ data: { platform: 'download', inviteCode: ic } })
+ } else {
+ m.wakeupOrInstall() // 此方法为scheme、Universal Link唤醒以及引导下载的作用(必须调用且不可额外自行跳转下载)
+ }
+ return false
+ }
+ }
+ if (button_mac) {
+ button_mac.onclick = function () {
+ if (ic) {
+ m.wakeupOrInstall({ data: { platform: 'download', inviteCode: ic } })
+ } else {
+ m.wakeupOrInstall() // 此方法为scheme、Universal Link唤醒以及引导下载的作用(必须调用且不可额外自行跳转下载)
+ }
+ return false
+ }
+ }
+ if (button1) {
+ button1.onclick = function () {
+ if (ic) {
+ m.wakeupOrInstall({ data: { platform: 'download', inviteCode: ic } })
+ } else {
+ m.wakeupOrInstall() // 此方法为scheme、Universal Link唤醒以及引导下载的作用(必须调用且不可额外自行跳转下载)
+ }
+ return false
+ }
+ }
+ },
+ },
+ this.urlQuery,
+ ) // 初始化时传入data,作为一键拉起/App传参安装时候的参数
+ } catch (e) {
+ console.log(e, 'OpenInstall——sdk初始化失败')
+ }
+ }
+}