fix(avatar): 仅在 uniapp 容器展示充值入口
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { getAuthToken } from '@/api'
|
||||
import { isInUniWebView } from '@/utils/uniapp-bridge'
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
@@ -55,7 +56,7 @@ const routes: RouteRecordRaw[] = [
|
||||
path: '/token/charge',
|
||||
name: 'TokenCharge',
|
||||
component: () => import('@/views/TokenCharge.vue'),
|
||||
meta: { title: '积分充值', requiresAuth: true }
|
||||
meta: { title: '积分充值', requiresAuth: true, requiresUniWebView: true }
|
||||
},
|
||||
{
|
||||
path: '/avatar/card',
|
||||
@@ -133,6 +134,10 @@ const router = createRouter({
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
document.title = to.meta.title as string || '会会数字分身'
|
||||
if (to.meta.requiresUniWebView && !isInUniWebView()) {
|
||||
next({ path: '/avatar/manage' })
|
||||
return
|
||||
}
|
||||
const hasLocalSession = Boolean(localStorage.getItem('hh_app_token'))
|
||||
const hasInjectedSession = Boolean(getAuthToken())
|
||||
if (to.meta.requiresAuth && !hasLocalSession && !hasInjectedSession) {
|
||||
|
||||
Reference in New Issue
Block a user