-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix add mobile links #9
Open
gabaldon
wants to merge
4
commits into
witnet:main
Choose a base branch
from
gabaldon:fix/add-mobile-links
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,60 @@ | ||
name: Pages | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
workflow_dispatch: | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
pages: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: github_pages | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Enable corepack | ||
run: corepack enable pnpm | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'pnpm' | ||
|
||
- name: Setup node env | ||
uses: actions/setup-node@v3 | ||
- name: Restore cache | ||
uses: actions/cache@v4 | ||
with: | ||
node-version: '16.20.0' | ||
path: | | ||
dist | ||
.nuxt | ||
key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuxt-build- | ||
|
||
- name: Install Dependencies | ||
run: yarn | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Generate | ||
run: yarn generate | ||
- name: Static HTML export with Nuxt | ||
run: pnpm run generate | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: .output/public | ||
cname: mywitwallet.com | ||
path: ./dist | ||
|
||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ dist | |
.DS_Store | ||
assets/.DS_Store | ||
assets/svg/.DS_Store | ||
docs/** */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Ignore build output directories | ||
.nuxt/ | ||
dist/ | ||
./docs/** */ | ||
./docs/_nuxt/** */ | ||
DEBUG=1/** */ | ||
|
||
# Ignore node modules | ||
node_modules/ | ||
|
||
# Ignore specific configuration files | ||
*.config.js | ||
|
||
# Ignore environment variables files | ||
.env | ||
.env.* | ||
|
||
# Ignore lock files | ||
yarn.lock | ||
package-lock.json | ||
|
||
# Ignore logs | ||
*.log | ||
|
||
# Ignore compiled files | ||
*.min.js | ||
*.min.css | ||
|
||
# Ignore specific file types | ||
*.png | ||
*.jpg | ||
*.jpeg | ||
*.gif | ||
*.svg | ||
|
||
# Ignore other generated files | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,66 @@ | ||
<template> | ||
<a | ||
v-if="release.platform" | ||
v-if="releaseContent && releaseContent.downloadName" | ||
class="link" | ||
:href="release.releaseUrl" | ||
:href="releaseContent.releaseUrl" | ||
target="_blank" | ||
:download="release.downloadName" | ||
:download="releaseContent.downloadName" | ||
> | ||
<ElButton class="btn" type="primary"> | ||
<i18n-t keypath="download" tag="span"> | ||
<button class="btn"> | ||
<i18n-t keypath="downloadLink" tag="span"> | ||
<template #platform> | ||
<span>{{ release.platform }}</span> | ||
<span>{{ releaseContent.platform }}</span> | ||
</template> | ||
</i18n-t> | ||
</ElButton> | ||
</button> | ||
</a> | ||
<a | ||
v-else | ||
class="link" | ||
href="https://github.com/witnet/my-wit-wallet/releases/latest" | ||
:href="releaseContent ? releaseContent.releaseUrl : GITHUB_RELEASE_URL" | ||
> | ||
<ElButton class="btn" type="primary">{{ $t('head.title') }}</ElButton> | ||
<button class="btn"> | ||
<i18n-t v-if="releaseContent" keypath="downloadLink" tag="span"> | ||
<template #platform> | ||
<span>{{ releaseContent?.platform }}</span> | ||
</template> | ||
</i18n-t> | ||
<span v-else>{{ t('githubLink') }}</span> | ||
</button> | ||
</a> | ||
</template> | ||
|
||
<script setup> | ||
import { getLatestRelease } from '../getLatestRelease' | ||
const release = await getLatestRelease(navigator) | ||
import { getLatestRelease, getStoreRelease } from '@/getLatestRelease' | ||
import { getBrowserOs } from '@/getBrowserOs' | ||
import { useI18n } from 'vue-i18n' | ||
import { GITHUB_RELEASE_URL } from '@/constants' | ||
import { onMounted, ref } from 'vue' | ||
const { t } = useI18n() | ||
|
||
const releaseContent = ref(null) | ||
|
||
onMounted(async () => { | ||
releaseContent.value = await release() | ||
}) | ||
|
||
async function release() { | ||
const os = getBrowserOs(navigator) | ||
const storeRelease = getStoreRelease({ os }) | ||
if (!os) { | ||
return null | ||
} | ||
if (storeRelease) { | ||
return storeRelease | ||
} | ||
return await getLatestRelease({ os }) | ||
} | ||
</script> | ||
|
||
<style></style> | ||
<style lang="scss"> | ||
.link { | ||
width: max-content; | ||
height: auto; | ||
display: flex; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import globals from 'globals' | ||
import pluginJs from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
import pluginVue from "eslint-plugin-vue"; | ||
import eslintConfigPrettier from "eslint-config-prettier"; | ||
// eslint.config.js | ||
export default [ | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
...pluginVue.configs["flat/essential"], | ||
eslintConfigPrettier, | ||
{ | ||
ignores: ['node_modules', 'dist', 'public', '.nuxt', 'docs/**/*', 'DEBUG=1/**/*'], | ||
}, | ||
{ | ||
files: ['pages/*.vue'], | ||
rules: { | ||
'vue/multi-word-component-names': 0, | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.vue', '**/*.ts'], | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
...globals.node | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
sourceType: 'module', | ||
}, | ||
}, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
import { DEFAULT_OS } from './constants' | ||
export function getBrowserOs(navigator: Navigator) { | ||
return navigator.userAgentData?.platform | ||
? detectPlatformWithUserAgentData(navigator) | ||
: detectPlatform(navigator) | ||
} | ||
|
||
const detectPlatformWithUserAgentData = (navigator: Navigator) => { | ||
const userAgentData: NavigatorUAData | undefined = navigator.userAgentData | ||
return userAgentData?.platform.toLowerCase() | ||
} | ||
|
||
export function getBrowserOs(navigator: any) { | ||
const supportedOs = ['Win', 'Mac', 'Linux', 'MacIntel'] | ||
const platform = navigator.platform | ||
return supportedOs.find((os) => platform.includes(os)) || DEFAULT_OS | ||
const detectPlatform = (navigator: Navigator): string | undefined => { | ||
const ua = navigator.userAgent.toLowerCase().replace(/^mozilla\/\d\.\d\W/, '') | ||
const mobiles: Record<string, RegExp> = { | ||
iphone: /iphone/, | ||
ipad: /ipad|macintosh/, | ||
android: /android/, | ||
} | ||
const desktops: Record<string, RegExp> = { | ||
windows: /win/, | ||
macos: /macintosh/, | ||
linux: /linux/, | ||
} | ||
// Determine the operating system | ||
const mobileOS = Object.keys(mobiles).find( | ||
(os) => mobiles[os].test(ua) && navigator.maxTouchPoints >= 1, | ||
) | ||
const desktopOS = Object.keys(desktops).find((os) => desktops[os].test(ua)) | ||
const os = mobileOS || desktopOS | ||
return os | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,78 @@ | ||
import axios from 'axios' | ||
import { URL_RELEASE_BASE } from './constants' | ||
import { getBrowserOs } from '@/getBrowserOs' | ||
import { GITHUB_RELEASE_URL, URL_RELEASE_BASE } from './constants' | ||
|
||
type Release = { | ||
platform: String | ||
releaseUrl: String | ||
downloadName: String | ||
platform: string | ||
releaseUrl: string | ||
downloadName: string | null | ||
} | ||
|
||
export async function getLatestRelease(navigator: any): Promise<Release> { | ||
return await axios.get(URL_RELEASE_BASE).then(async (result: any) => { | ||
const os = await getBrowserOs(navigator).toLowerCase() | ||
const macRelease = await result.data.assets.find((asset: any) => { | ||
return asset.browser_download_url.includes('myWitWallet.dmg') | ||
}) | ||
const linuxRelease = await result.data.assets.find((asset: any) => | ||
asset.browser_download_url.includes('linux.tar.gz') | ||
) | ||
type LatestReleaseResponse = { | ||
assets: [] | ||
} | ||
|
||
type ReleaseAsset = { | ||
browser_download_url: string | ||
name: string | null | ||
} | ||
|
||
export function getStoreRelease({ os }: { os: string }): Release | undefined { | ||
const iosLink = { | ||
platform: 'iOS', | ||
releaseUrl: 'https://apps.apple.com/cl/app/mywitwallet/id6449979271', | ||
downloadName: null, | ||
} | ||
const storeReleases: Record<string, Release> = { | ||
iphone: iosLink, | ||
ipad: iosLink, | ||
android: { | ||
platform: 'Android', | ||
releaseUrl: | ||
'https://play.google.com/store/apps/details?id=io.witnet.myWitWallet&hl=es_419&pli=1', | ||
downloadName: null, | ||
}, | ||
windows: { | ||
platform: 'Windows', | ||
releaseUrl: 'https://apps.microsoft.com/detail/9PN09DKWPL57', | ||
downloadName: null, | ||
}, | ||
} | ||
if (storeReleases[os]) { | ||
return storeReleases[os] | ||
} | ||
} | ||
|
||
const { data }: { data: Ref<LatestReleaseResponse | undefined> } = | ||
await useAsyncData('release', () => $fetch(URL_RELEASE_BASE)) | ||
|
||
export async function getLatestRelease({ | ||
os, | ||
}: { | ||
os: string | ||
}): Promise<Release | null> { | ||
if (data.value) { | ||
const macRelease: ReleaseAsset = data.value.assets.find( | ||
(asset: ReleaseAsset) => { | ||
return asset.browser_download_url.includes('myWitWallet.dmg') | ||
}, | ||
) ?? { browser_download_url: GITHUB_RELEASE_URL, name: null } | ||
const linuxRelease: ReleaseAsset = data.value.assets.find( | ||
(asset: ReleaseAsset) => | ||
asset.browser_download_url.includes('linux.tar.gz'), | ||
) ?? { browser_download_url: GITHUB_RELEASE_URL, name: null } | ||
|
||
const release: Record<string, Release> = { | ||
linux: { | ||
platform: 'GNU / Linux', | ||
releaseUrl: linuxRelease.browser_download_url, | ||
downloadName: linuxRelease.name, | ||
}, | ||
win: { | ||
platform: 'Windows', | ||
releaseUrl: 'https://apps.microsoft.com/detail/9PN09DKWPL57', | ||
downloadName: 'myWitWallet', | ||
}, | ||
mac: { | ||
macos: { | ||
platform: 'Mac OS', | ||
releaseUrl: macRelease.browser_download_url, | ||
downloadName: macRelease.name, | ||
}, | ||
} | ||
return release[os] | ||
}) | ||
} | ||
return null | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.