icon changed
This commit is contained in:
+8
-42
@@ -55,25 +55,6 @@
|
||||
</router-view>
|
||||
</div>
|
||||
</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
|
||||
v-if="showSupportButton && !showSplash"
|
||||
id="support-button"
|
||||
@@ -104,17 +85,18 @@
|
||||
>
|
||||
<AppCreditLink variant="float" />
|
||||
</div>
|
||||
|
||||
<VersionUpdateModal />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import pkg from '../package.json'
|
||||
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_pattern from '@/views/login/assets/img/pattern.svg'
|
||||
import {LoadingOutlined} from '@ant-design/icons-vue'
|
||||
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 {useConfigStore} from "@/store/configStore";
|
||||
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 { useRoute } from 'vue-router'
|
||||
|
||||
const VersionUpdateModal = defineAsyncComponent(
|
||||
() => import('@/modules/version/VersionUpdateModal.vue')
|
||||
)
|
||||
|
||||
useApplyDesktopLayoutClass()
|
||||
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
@@ -139,7 +125,7 @@ const showDesktopFloatingCredit = computed(() => {
|
||||
return route.name === 'login' || !!route.meta.hideMenu
|
||||
})
|
||||
|
||||
const {offlineReady, needRefresh, updateServiceWorker} = useRegisterSW()
|
||||
useRegisterSW()
|
||||
const config = useConfigStore()
|
||||
const splashIndicator = computed(() => h(LoadingOutlined, {
|
||||
style: {
|
||||
@@ -251,7 +237,6 @@ onMounted(async () => {
|
||||
await config.getConfigData()
|
||||
await loadSupportMessengerFromSettings()
|
||||
console.log(config?.config?.color)
|
||||
checkVersion()
|
||||
setTimeout(() => {
|
||||
showSplash.value = false
|
||||
}, 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>
|
||||
|
||||
<style lang="less">
|
||||
|
||||
@@ -4,9 +4,9 @@ import { applyAppConfig } from '@/config/apply-config'
|
||||
import { startPwaManifest } from '@/modules/pwa/manifest'
|
||||
import { createVueApp } from '@/app/createApp'
|
||||
import { setupRouterGuards } from '@/app/setupRouter'
|
||||
import router from '@/router'
|
||||
import { applyProjectTheme } from '@/utils/config'
|
||||
import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { getToken } from '@/utils'
|
||||
|
||||
type BootWindow = Window & {
|
||||
@@ -98,12 +98,14 @@ export async function bootstrapApp() {
|
||||
|
||||
setupRouterGuards()
|
||||
|
||||
if (getToken()) {
|
||||
await useUserStore().getMyInfo()
|
||||
}
|
||||
|
||||
app.mount('#app')
|
||||
|
||||
await router.isReady()
|
||||
|
||||
if (!getToken() && router.currentRoute.value.name !== 'login') {
|
||||
await router.replace({ name: 'login' })
|
||||
}
|
||||
|
||||
;(window as BootWindow).__APP_BOOTSTRAPPED__ = true
|
||||
clearBootTimeout()
|
||||
sessionStorage.removeItem('__APP_BOOT_RECOVERY_DONE__')
|
||||
|
||||
+88
-95
@@ -4,21 +4,33 @@ import { authenticateWithFingerprint, getToken, isIphone, removeToken } from '@/
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { useWalletStore } from '@/store/walletStore'
|
||||
import { useFundUserStore } from '@/store/fundStore'
|
||||
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
|
||||
import type { NavigationGuardNext } from 'vue-router'
|
||||
import { useAuthStore } from '@/store/useAuthStore'
|
||||
import { getConfigApp } from '@/utils/config'
|
||||
import { getFingerPosition, setFingerPosition } from '@/app/authBoot'
|
||||
|
||||
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() {
|
||||
const userStore = useUserStore()
|
||||
const walletStore = useWalletStore()
|
||||
const fundStore = useFundUserStore()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const isApple: boolean = isIphone()
|
||||
let isFirst = true
|
||||
const isApple = isIphone()
|
||||
let fingerprintChecked = false
|
||||
let timeoutId: ReturnType<typeof setTimeout> | null = null
|
||||
let hasFingerPrint = false
|
||||
|
||||
@@ -32,122 +44,76 @@ export function setupRouterGuards() {
|
||||
}
|
||||
}
|
||||
|
||||
function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||
if (to.name !== 'login') {
|
||||
return next({ name: 'login' })
|
||||
}
|
||||
return next()
|
||||
}
|
||||
async function resolveSession() {
|
||||
const token = getToken()
|
||||
|
||||
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
|
||||
if (to.name !== 'home') {
|
||||
return next({ name: 'home' })
|
||||
if (!token) {
|
||||
userStore.userInfo = undefined
|
||||
return false
|
||||
}
|
||||
return next()
|
||||
}
|
||||
|
||||
function isPublicRoute(name: string | symbol | null | undefined) {
|
||||
return PUBLIC_ROUTE_NAMES.includes(name as (typeof PUBLIC_ROUTE_NAMES)[number])
|
||||
if (!userStore.userInfo) {
|
||||
await userStore.getMyInfo()
|
||||
}
|
||||
|
||||
if (!userStore.userInfo) {
|
||||
removeToken()
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
authStore.setLoading(true)
|
||||
|
||||
try {
|
||||
if (getToken() && !userStore.userInfo) {
|
||||
await userStore.getMyInfo()
|
||||
}
|
||||
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId)
|
||||
}
|
||||
|
||||
if (to.name == 'giftCard' && getConfigApp('name') != 'garoosi') {
|
||||
return next({ name: from.name })
|
||||
if (to.name === 'giftCard' && getConfigApp('name') !== 'garoosi') {
|
||||
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(() => {
|
||||
if (hasFingerPrint) {
|
||||
setFingerPosition(false)
|
||||
console.log('Fingerprint authentication reset after 5 seconds of inactivity')
|
||||
}
|
||||
}, 180000)
|
||||
}
|
||||
|
||||
if (isFirst) {
|
||||
isFirst = false
|
||||
|
||||
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 (to.name === 'login') {
|
||||
return goToHome(next)
|
||||
}
|
||||
|
||||
if (getFingerPosition()) {
|
||||
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)
|
||||
return next()
|
||||
} finally {
|
||||
authStore.setLoading(false)
|
||||
}
|
||||
@@ -155,3 +121,30 @@ export function setupRouterGuards() {
|
||||
|
||||
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 { getHomeLayoutId } from '../layouts/registry'
|
||||
import { initHomePageData, resetHomePageData, useHomePageLoading } from './useHomePageData'
|
||||
import { ensureAuthenticatedRoute } from '@/app/setupRouter'
|
||||
import { resetWalletPageData } from '../../wallet/composables/useWalletPageData'
|
||||
import { resetAddressPageData } from '../../address/composables/useAddressPageData'
|
||||
import { resetTransactionsPageData } from '../../transactions/composables/useTransactionsPageData'
|
||||
@@ -279,13 +280,10 @@ export function useHomePageContext() {
|
||||
}
|
||||
|
||||
async function ensureHomeUserAndData() {
|
||||
const userStore = useUserStore()
|
||||
|
||||
if (getToken() && !userStore.userInfo) {
|
||||
await userStore.getMyInfo()
|
||||
const authed = await ensureAuthenticatedRoute()
|
||||
if (!authed) {
|
||||
return
|
||||
}
|
||||
|
||||
if (getToken()) {
|
||||
await initHomePageData()
|
||||
}
|
||||
await initHomePageData()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user