Merge pull request #8281 from dataease/pr@dev-v2_dzz_mobile

fix(移动端): 查看仪表板后,返回时建议能返回到查看操作发起的页面
This commit is contained in:
dataeaseShu 2024-03-01 18:58:06 +08:00 committed by GitHub
commit 0c82effa01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 39 additions and 7 deletions

View File

@ -2,6 +2,7 @@
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { useCache } from '@/hooks/web/useCache'
import { BusiTreeRequest } from '@/models/tree/TreeNode' import { BusiTreeRequest } from '@/models/tree/TreeNode'
import { interactiveStoreWithOut } from '@/store/modules/interactive' import { interactiveStoreWithOut } from '@/store/modules/interactive'
import DashboardCell from '@/views/mobile/components/DashboardCell.vue' import DashboardCell from '@/views/mobile/components/DashboardCell.vue'
@ -19,6 +20,7 @@ const activeDirectName = ref('')
const interactiveStore = interactiveStoreWithOut() const interactiveStore = interactiveStoreWithOut()
const dvMainStore = dvMainStoreWithOut() const dvMainStore = dvMainStoreWithOut()
const { dvInfo } = storeToRefs(dvMainStore) const { dvInfo } = storeToRefs(dvMainStore)
const { wsCache } = useCache('sessionStorage')
const dfsTree = (ids, arr) => { const dfsTree = (ids, arr) => {
const id = ids.shift() const id = ids.shift()
@ -50,6 +52,10 @@ const onClickLeft = () => {
const router = useRouter() const router = useRouter()
const handleCellClick = ele => { const handleCellClick = ele => {
wsCache.set('directName', directName.value)
wsCache.set('activeDirectName', activeDirectName.value)
wsCache.set('activeTabbar', 'direct')
wsCache.set('directId', directId.value)
router.push({ router.push({
path: '/panel/mobile', path: '/panel/mobile',
query: { query: {
@ -59,13 +65,14 @@ const handleCellClick = ele => {
} }
const dataClick = val => { const dataClick = val => {
directName.value.push(val.name)
activeDirectName.value = val.name
directId.value.push(val.id)
if (val.leaf) { if (val.leaf) {
emits('hiddenTabbar', true) emits('hiddenTabbar', true)
handleCellClick(val) handleCellClick(val)
return
} }
directName.value.push(val.name)
activeDirectName.value = val.name
directId.value.push(val.id)
} }
const getTree = async () => { const getTree = async () => {
@ -87,6 +94,14 @@ const getTree = async () => {
onMounted(() => { onMounted(() => {
getTree() getTree()
activeDirectName.value = wsCache.get('activeDirectName')
if (wsCache.get('activeTabbar') !== 'direct' || !activeDirectName.value) return
directName.value = wsCache.get('directName')
directId.value = wsCache.get('directId')
wsCache.set('directName', [])
wsCache.set('activeDirectName', '')
wsCache.set('directId', [])
wsCache.set('activeTabbar', '')
}) })
</script> </script>

View File

@ -4,6 +4,7 @@ import { interactiveStoreWithOut } from '@/store/modules/interactive'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { shortcutOption } from '@/views/workbranch/ShortcutOption' import { shortcutOption } from '@/views/workbranch/ShortcutOption'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useCache } from '@/hooks/web/useCache'
import Workbranch from '@/views/mobile/components/Workbranch.vue' import Workbranch from '@/views/mobile/components/Workbranch.vue'
import request from '@/config/axios' import request from '@/config/axios'
import nothingNone from '@/assets/img/none.png' import nothingNone from '@/assets/img/none.png'
@ -18,6 +19,7 @@ import 'vant/es/tabs/style'
const router = useRouter() const router = useRouter()
const { t } = useI18n() const { t } = useI18n()
const { wsCache } = useCache('sessionStorage')
const activeTab = ref('recent') const activeTab = ref('recent')
const emptyTips = ref('') const emptyTips = ref('')
@ -104,14 +106,17 @@ const handleClick = ({ name, disabled }) => {
} }
} }
onMounted(() => { onMounted(() => {
activeTab.value = wsCache.get('activeTab') || 'recent'
wsCache.set('activeTab', '')
!!busiAuthList.length && !!busiAuthList.length &&
handleClick({ handleClick({
name: 'recent', name: activeTab.value,
disabled: false disabled: false
}) })
}) })
const handleCellClick = ele => { const handleCellClick = ele => {
wsCache.set('activeTab', activeTab.value)
router.push({ router.push({
path: '/panel/mobile', path: '/panel/mobile',
query: { query: {

View File

@ -1,7 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue' import { ref, onBeforeMount } from 'vue'
import Home from './home/index.vue' import Home from './home/index.vue'
import Directory from './directory/index.vue' import Directory from './directory/index.vue'
import { useCache } from '@/hooks/web/useCache'
import Personal from './personal/index.vue' import Personal from './personal/index.vue'
import VanTabbar from 'vant/es/tabbar' import VanTabbar from 'vant/es/tabbar'
import VanTabbarItem from 'vant/es/tabbar-item' import VanTabbarItem from 'vant/es/tabbar-item'
@ -15,6 +16,11 @@ import 'vant/es/loading/style'
const activeTabbar = ref('home') const activeTabbar = ref('home')
const showLoading = ref(false) const showLoading = ref(false)
const hiddenTabbar = ref(false) const hiddenTabbar = ref(false)
const { wsCache } = useCache('sessionStorage')
onBeforeMount(() => {
activeTabbar.value = wsCache.get('activeTabbar') || 'home'
})
</script> </script>
<template> <template>

View File

@ -50,16 +50,22 @@ const loadCanvasData = (dvId, weight?) => {
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
let fromPage, cache
onBeforeMount(() => { onBeforeMount(() => {
dvMainStore.setMobileInPc(true) dvMainStore.setMobileInPc(true)
const dvId = route.query.dvId as unknown as string const dvId = route.query.dvId as unknown as string
fromPage = route.query.from as unknown as string
cache = route.query.cache as unknown as string
loadCanvasData(dvId) loadCanvasData(dvId)
}) })
const onClickLeft = () => { const onClickLeft = () => {
router.replace({ router.replace({
path: '/index' path: '/index',
query: {
from: fromPage,
cache: cache
}
}) })
} }
</script> </script>