提交 ae1b01ab authored 作者: lidongxu's avatar lidongxu

refactor(login): 登录页面_勤策判断有点问题

state 值用飞书时也有,导致勤策登录也走了,不对
上级 8a34c656
<template>
<router-view />
<router-view v-slot="{ Component }">
<keep-alive include="ab">
<component :is="Component"></component>
</keep-alive>
</router-view>
<back-to-up></back-to-up>
</template>
<script setup>
import useSettingsStore from '@/store/modules/settings'
import { handleThemeStyle } from '@/utils/theme'
import { constantRoutes } from '@/router'
onMounted(() => {
nextTick(() => {
// 初始化主题样式
handleThemeStyle(useSettingsStore().theme)
})
})
const cachedViews = ref([])
constantRoutes.forEach(o => {
console.log('1', o)
// 暂时只缓存第一层
if (o.meta?.keepAlive) {
cachedViews.value.push(o.name)
}
})
console.log(cachedViews.value)
</script>
......@@ -67,31 +67,6 @@
</div>
</template>
</van-cell>
<van-cell v-for="item in planList"
:key="item.id"
label-class="image-cell">
<template #title>
<p>{{ item.temporaryName }}</p>
<p>{{ item.province + item.city }}</p>
</template>
<template #label>
<div class="item"
v-for="o in item.photoList">
<template v-if="o.list">
<p>{{ o.title }}</p>
<div class="image-wrap">
<div class="small-item"
v-for="obj, index in o.list">
<van-image :src="obj.photoUrl"
@click="previewImage(o.list, index)" />
<p>{{ obj.title }}</p>
<p>{{ obj.time }}</p>
</div>
</div>
</template>
</div>
</template>
</van-cell>
</van-cell-group>
</van-list>
</van-pull-refresh>
......
......@@ -147,6 +147,10 @@
</template>
<script setup>
// 指定当前组件的名字
defineOptions({
name: 'ab'
})
import { parseTime } from '@/utils'
import { useDatePickerOptions } from '@/hooks'
import { getChargeListAPI, getPlanListAPI } from '@/api'
......@@ -332,6 +336,11 @@ const resetFn = () => {
planQueryParams.pageNum = 1
getPlanList()
}
onUnmounted(() => {
console.log('des')
})
</script>
<style scoped
......
......@@ -95,9 +95,10 @@ export const constantMobileRoutes = [
},
{
path: '/promotion',
component: () => import('@/mobile_views/promotion/index'),
name: 'Index',
component: () => import('@/mobile_views/promotion/promotion'),
name: 'Mobile_Promotion', // 和组件内的名字保持一致
hidden: true,
meta: { keepAlive: true } // 标记该路由需要缓存
},
{
path: '/promotion_detail/:id',
......@@ -190,7 +191,7 @@ if (isMobile()) {
const router = createRouter({
history: createWebHashHistory(),
routes: constantRoutes,
routes: [...constantRoutes],
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
......
......@@ -150,9 +150,17 @@ checkFsLoginAuth()
// 检查-是否勤策回跳,并客户端登录
const checkQcLoginAuth = async () => {
isShowLogin.value = false
const isState = window.location.href.includes('state')
if (isState) {
loginByType('qc', window.location.href.split('?')[2])
// 勤策的 state 取值比较特殊
// ?redirect=/promotion?state=STATE&code=CODE 这个格式
const url = window.location.href.split('?')[2]
if (url) {
const params = new URLSearchParams(url);
const state = params.get('state');
if (state === 'STATE') {
loginByType('qc', window.location.href.split('?')[2])
} else {
isShowLogin.value = true
}
} else {
isShowLogin.value = true
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论