icon changed
This commit is contained in:
+8
-42
@@ -55,25 +55,6 @@
|
|||||||
</router-view>
|
</router-view>
|
||||||
</div>
|
</div>
|
||||||
</AConfigProvider>
|
</AConfigProvider>
|
||||||
<van-dialog
|
|
||||||
v-model:show="versionDialog"
|
|
||||||
class="updateButton"
|
|
||||||
teleport="body"
|
|
||||||
:z-index="5300"
|
|
||||||
confirm-button-text="به روزرسانی کنید"
|
|
||||||
show-confirm-button
|
|
||||||
@confirm="update()"
|
|
||||||
>
|
|
||||||
<div class="flex flex-col items-center p-2">
|
|
||||||
<DotLottieVue
|
|
||||||
class="w-full aspect-square"
|
|
||||||
autoplay
|
|
||||||
loop
|
|
||||||
src="https://lottie.host/cb620e8e-c64a-42e8-a6b5-8844146e5999/nmft7oBO8q.json"
|
|
||||||
/>
|
|
||||||
<div class="home_appear_fade_in_up mt-2">نسخه جدید منتشر شد!</div>
|
|
||||||
</div>
|
|
||||||
</van-dialog>
|
|
||||||
<div
|
<div
|
||||||
v-if="showSupportButton && !showSplash"
|
v-if="showSupportButton && !showSplash"
|
||||||
id="support-button"
|
id="support-button"
|
||||||
@@ -104,17 +85,18 @@
|
|||||||
>
|
>
|
||||||
<AppCreditLink variant="float" />
|
<AppCreditLink variant="float" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<VersionUpdateModal />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import pkg from '../package.json'
|
import pkg from '../package.json'
|
||||||
import {useRegisterSW} from 'virtual:pwa-register/vue'
|
import {useRegisterSW} from 'virtual:pwa-register/vue'
|
||||||
import {computed, h, onMounted, ref, watch} from 'vue'
|
import {computed, defineAsyncComponent, h, onMounted, ref, watch} from 'vue'
|
||||||
import img_topGradiant from '@/views/login/assets/img/gr_top_white.svg'
|
import img_topGradiant from '@/views/login/assets/img/gr_top_white.svg'
|
||||||
import img_pattern from '@/views/login/assets/img/pattern.svg'
|
import img_pattern from '@/views/login/assets/img/pattern.svg'
|
||||||
import {LoadingOutlined} from '@ant-design/icons-vue'
|
import {LoadingOutlined} from '@ant-design/icons-vue'
|
||||||
import img_bottomGradiant from '@/views/login/assets/img/gr_bottom_white.svg'
|
import img_bottomGradiant from '@/views/login/assets/img/gr_bottom_white.svg'
|
||||||
import {DotLottieVue} from '@lottiefiles/dotlottie-vue'
|
|
||||||
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
||||||
import {useConfigStore} from "@/store/configStore";
|
import {useConfigStore} from "@/store/configStore";
|
||||||
import {getProjectFontFamily, getProjectSplashBackground, getProjectSplashLogo, getProjectBrandRed, hasCustomLoginLogoLayout, isBoursecuProject, resetAppSurfaceBackground} from "@/utils/config";
|
import {getProjectFontFamily, getProjectSplashBackground, getProjectSplashLogo, getProjectBrandRed, hasCustomLoginLogoLayout, isBoursecuProject, resetAppSurfaceBackground} from "@/utils/config";
|
||||||
@@ -130,6 +112,10 @@ import { useDraggableFloatingButton } from '@/utils/useDraggableFloatingButton'
|
|||||||
import AppCreditLink from '@/components/AppCreditLink.vue'
|
import AppCreditLink from '@/components/AppCreditLink.vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
const VersionUpdateModal = defineAsyncComponent(
|
||||||
|
() => import('@/modules/version/VersionUpdateModal.vue')
|
||||||
|
)
|
||||||
|
|
||||||
useApplyDesktopLayoutClass()
|
useApplyDesktopLayoutClass()
|
||||||
|
|
||||||
const isDesktop = useDesktopBreakpoint()
|
const isDesktop = useDesktopBreakpoint()
|
||||||
@@ -139,7 +125,7 @@ const showDesktopFloatingCredit = computed(() => {
|
|||||||
return route.name === 'login' || !!route.meta.hideMenu
|
return route.name === 'login' || !!route.meta.hideMenu
|
||||||
})
|
})
|
||||||
|
|
||||||
const {offlineReady, needRefresh, updateServiceWorker} = useRegisterSW()
|
useRegisterSW()
|
||||||
const config = useConfigStore()
|
const config = useConfigStore()
|
||||||
const splashIndicator = computed(() => h(LoadingOutlined, {
|
const splashIndicator = computed(() => h(LoadingOutlined, {
|
||||||
style: {
|
style: {
|
||||||
@@ -251,7 +237,6 @@ onMounted(async () => {
|
|||||||
await config.getConfigData()
|
await config.getConfigData()
|
||||||
await loadSupportMessengerFromSettings()
|
await loadSupportMessengerFromSettings()
|
||||||
console.log(config?.config?.color)
|
console.log(config?.config?.color)
|
||||||
checkVersion()
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
showSplash.value = false
|
showSplash.value = false
|
||||||
}, 2000)
|
}, 2000)
|
||||||
@@ -263,25 +248,6 @@ watch(showSplash, (visible) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const versionDialog = ref<boolean>(false)
|
|
||||||
|
|
||||||
function checkVersion() {
|
|
||||||
const version = localStorage.getItem('version')
|
|
||||||
// if (true) {
|
|
||||||
if (!version) {
|
|
||||||
update()
|
|
||||||
}
|
|
||||||
if (version != pkg.version) {
|
|
||||||
versionDialog.value = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function update() {
|
|
||||||
localStorage.setItem('version', pkg.version)
|
|
||||||
updateServiceWorker()
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import { applyAppConfig } from '@/config/apply-config'
|
|||||||
import { startPwaManifest } from '@/modules/pwa/manifest'
|
import { startPwaManifest } from '@/modules/pwa/manifest'
|
||||||
import { createVueApp } from '@/app/createApp'
|
import { createVueApp } from '@/app/createApp'
|
||||||
import { setupRouterGuards } from '@/app/setupRouter'
|
import { setupRouterGuards } from '@/app/setupRouter'
|
||||||
|
import router from '@/router'
|
||||||
import { applyProjectTheme } from '@/utils/config'
|
import { applyProjectTheme } from '@/utils/config'
|
||||||
import { useSettingsStore } from '@/store/settingsStore'
|
import { useSettingsStore } from '@/store/settingsStore'
|
||||||
import { useUserStore } from '@/store/userStore'
|
|
||||||
import { getToken } from '@/utils'
|
import { getToken } from '@/utils'
|
||||||
|
|
||||||
type BootWindow = Window & {
|
type BootWindow = Window & {
|
||||||
@@ -98,12 +98,14 @@ export async function bootstrapApp() {
|
|||||||
|
|
||||||
setupRouterGuards()
|
setupRouterGuards()
|
||||||
|
|
||||||
if (getToken()) {
|
|
||||||
await useUserStore().getMyInfo()
|
|
||||||
}
|
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|
||||||
|
await router.isReady()
|
||||||
|
|
||||||
|
if (!getToken() && router.currentRoute.value.name !== 'login') {
|
||||||
|
await router.replace({ name: 'login' })
|
||||||
|
}
|
||||||
|
|
||||||
;(window as BootWindow).__APP_BOOTSTRAPPED__ = true
|
;(window as BootWindow).__APP_BOOTSTRAPPED__ = true
|
||||||
clearBootTimeout()
|
clearBootTimeout()
|
||||||
sessionStorage.removeItem('__APP_BOOT_RECOVERY_DONE__')
|
sessionStorage.removeItem('__APP_BOOT_RECOVERY_DONE__')
|
||||||
|
|||||||
+88
-95
@@ -4,21 +4,33 @@ import { authenticateWithFingerprint, getToken, isIphone, removeToken } from '@/
|
|||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import { useWalletStore } from '@/store/walletStore'
|
import { useWalletStore } from '@/store/walletStore'
|
||||||
import { useFundUserStore } from '@/store/fundStore'
|
import { useFundUserStore } from '@/store/fundStore'
|
||||||
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
|
import type { NavigationGuardNext } from 'vue-router'
|
||||||
import { useAuthStore } from '@/store/useAuthStore'
|
import { useAuthStore } from '@/store/useAuthStore'
|
||||||
import { getConfigApp } from '@/utils/config'
|
import { getConfigApp } from '@/utils/config'
|
||||||
import { getFingerPosition, setFingerPosition } from '@/app/authBoot'
|
import { getFingerPosition, setFingerPosition } from '@/app/authBoot'
|
||||||
|
|
||||||
const PUBLIC_ROUTE_NAMES = ['login', '404', 'educate', 'aboutUs'] as const
|
const PUBLIC_ROUTE_NAMES = ['login', '404', 'educate', 'aboutUs'] as const
|
||||||
|
|
||||||
|
function isPublicRoute(name: string | symbol | null | undefined) {
|
||||||
|
return PUBLIC_ROUTE_NAMES.includes(name as (typeof PUBLIC_ROUTE_NAMES)[number])
|
||||||
|
}
|
||||||
|
|
||||||
|
function goToLogin(next: NavigationGuardNext) {
|
||||||
|
return next({ name: 'login' })
|
||||||
|
}
|
||||||
|
|
||||||
|
function goToHome(next: NavigationGuardNext) {
|
||||||
|
return next({ name: 'home' })
|
||||||
|
}
|
||||||
|
|
||||||
export function setupRouterGuards() {
|
export function setupRouterGuards() {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const walletStore = useWalletStore()
|
const walletStore = useWalletStore()
|
||||||
const fundStore = useFundUserStore()
|
const fundStore = useFundUserStore()
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
const isApple: boolean = isIphone()
|
const isApple = isIphone()
|
||||||
let isFirst = true
|
let fingerprintChecked = false
|
||||||
let timeoutId: ReturnType<typeof setTimeout> | null = null
|
let timeoutId: ReturnType<typeof setTimeout> | null = null
|
||||||
let hasFingerPrint = false
|
let hasFingerPrint = false
|
||||||
|
|
||||||
@@ -32,122 +44,76 @@ export function setupRouterGuards() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
async function resolveSession() {
|
||||||
if (to.name !== 'login') {
|
const token = getToken()
|
||||||
return next({ name: 'login' })
|
|
||||||
}
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
if (!token) {
|
||||||
if (to.name !== 'home') {
|
userStore.userInfo = undefined
|
||||||
return next({ name: 'home' })
|
return false
|
||||||
}
|
}
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
function isPublicRoute(name: string | symbol | null | undefined) {
|
if (!userStore.userInfo) {
|
||||||
return PUBLIC_ROUTE_NAMES.includes(name as (typeof PUBLIC_ROUTE_NAMES)[number])
|
await userStore.getMyInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userStore.userInfo) {
|
||||||
|
removeToken()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
authStore.setLoading(true)
|
authStore.setLoading(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (getToken() && !userStore.userInfo) {
|
|
||||||
await userStore.getMyInfo()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeoutId) {
|
if (timeoutId) {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to.name == 'giftCard' && getConfigApp('name') != 'garoosi') {
|
if (to.name === 'giftCard' && getConfigApp('name') !== 'garoosi') {
|
||||||
return next({ name: from.name })
|
return next({ name: (from.name as string) || 'home' })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from.name !== 'login' || from.name !== undefined) {
|
const authenticated = await resolveSession()
|
||||||
|
|
||||||
|
if (!authenticated) {
|
||||||
|
if (isPublicRoute(to.name)) {
|
||||||
|
return next()
|
||||||
|
}
|
||||||
|
return goToLogin(next)
|
||||||
|
}
|
||||||
|
|
||||||
|
hasFingerPrint = !!userStore.userInfo?.finger_print
|
||||||
|
|
||||||
|
if (isApple && userStore.userInfo?.finger_print) {
|
||||||
|
removeToken()
|
||||||
|
return goToLogin(next)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isApple && userStore.userInfo?.finger_print) {
|
||||||
|
if (!fingerprintChecked) {
|
||||||
|
fingerprintChecked = true
|
||||||
|
setFingerPosition(await authenticateWithFingerprint())
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!getFingerPosition()) {
|
||||||
|
return goToLogin(next)
|
||||||
|
}
|
||||||
|
|
||||||
timeoutId = setTimeout(() => {
|
timeoutId = setTimeout(() => {
|
||||||
if (hasFingerPrint) {
|
if (hasFingerPrint) {
|
||||||
setFingerPosition(false)
|
setFingerPosition(false)
|
||||||
console.log('Fingerprint authentication reset after 5 seconds of inactivity')
|
|
||||||
}
|
}
|
||||||
}, 180000)
|
}, 180000)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFirst) {
|
if (to.name === 'login') {
|
||||||
isFirst = false
|
return goToHome(next)
|
||||||
|
|
||||||
if (getToken()) {
|
|
||||||
await userStore.getMyInfo()
|
|
||||||
|
|
||||||
if (!userStore.userInfo) {
|
|
||||||
return goToLogin(to, next)
|
|
||||||
}
|
|
||||||
|
|
||||||
const finger_print = userStore.userInfo.finger_print
|
|
||||||
hasFingerPrint = !!finger_print
|
|
||||||
|
|
||||||
if (isApple && finger_print) {
|
|
||||||
removeToken()
|
|
||||||
return goToLogin(to, next)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isApple && finger_print) {
|
|
||||||
setFingerPosition(await authenticateWithFingerprint())
|
|
||||||
|
|
||||||
if (!getFingerPosition()) {
|
|
||||||
return goToLogin(to, next)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to.name === 'login') {
|
|
||||||
return goToHome(to, next)
|
|
||||||
}
|
|
||||||
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to.name == 'login') {
|
|
||||||
return goToHome(to, next)
|
|
||||||
}
|
|
||||||
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPublicRoute(to.name)) {
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
return goToLogin(to, next)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getFingerPosition()) {
|
return next()
|
||||||
if (getToken()) {
|
|
||||||
if (to.name === 'login') {
|
|
||||||
return next({ name: from.name || 'home' })
|
|
||||||
}
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPublicRoute(to.name)) {
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
return next({ name: 'login' })
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getToken() && !hasFingerPrint) {
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPublicRoute(to.name)) {
|
|
||||||
if (to.name === 'login') {
|
|
||||||
return goToLogin(to, next)
|
|
||||||
}
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
return goToLogin(to, next)
|
|
||||||
} finally {
|
} finally {
|
||||||
authStore.setLoading(false)
|
authStore.setLoading(false)
|
||||||
}
|
}
|
||||||
@@ -155,3 +121,30 @@ export function setupRouterGuards() {
|
|||||||
|
|
||||||
watch(currentRoute, async () => (userStore.userInfo ? '' : await start()))
|
watch(currentRoute, async () => (userStore.userInfo ? '' : await start()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function ensureAuthenticatedRoute() {
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const token = getToken()
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
userStore.userInfo = undefined
|
||||||
|
if (router.currentRoute.value.name !== 'login') {
|
||||||
|
await router.replace({ name: 'login' })
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userStore.userInfo) {
|
||||||
|
await userStore.getMyInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userStore.userInfo) {
|
||||||
|
removeToken()
|
||||||
|
if (router.currentRoute.value.name !== 'login') {
|
||||||
|
await router.replace({ name: 'login' })
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { usePriceChart, type ChartMetalType } from './usePriceChart'
|
|||||||
import type { HomeActionItem } from '../layouts/types'
|
import type { HomeActionItem } from '../layouts/types'
|
||||||
import { getHomeLayoutId } from '../layouts/registry'
|
import { getHomeLayoutId } from '../layouts/registry'
|
||||||
import { initHomePageData, resetHomePageData, useHomePageLoading } from './useHomePageData'
|
import { initHomePageData, resetHomePageData, useHomePageLoading } from './useHomePageData'
|
||||||
|
import { ensureAuthenticatedRoute } from '@/app/setupRouter'
|
||||||
import { resetWalletPageData } from '../../wallet/composables/useWalletPageData'
|
import { resetWalletPageData } from '../../wallet/composables/useWalletPageData'
|
||||||
import { resetAddressPageData } from '../../address/composables/useAddressPageData'
|
import { resetAddressPageData } from '../../address/composables/useAddressPageData'
|
||||||
import { resetTransactionsPageData } from '../../transactions/composables/useTransactionsPageData'
|
import { resetTransactionsPageData } from '../../transactions/composables/useTransactionsPageData'
|
||||||
@@ -279,13 +280,10 @@ export function useHomePageContext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function ensureHomeUserAndData() {
|
async function ensureHomeUserAndData() {
|
||||||
const userStore = useUserStore()
|
const authed = await ensureAuthenticatedRoute()
|
||||||
|
if (!authed) {
|
||||||
if (getToken() && !userStore.userInfo) {
|
return
|
||||||
await userStore.getMyInfo()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getToken()) {
|
await initHomePageData()
|
||||||
await initHomePageData()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user