添加缓存,以及列表页面回显
This commit is contained in:
parent
bcedc39efa
commit
226566a65b
84
src/App.vue
84
src/App.vue
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition :name="transitionName">
|
||||
<keep-alive exclude="AllMessage">
|
||||
<keep-alive :exclude="excludeRoutes">
|
||||
<component :is="Component"/>
|
||||
</keep-alive>
|
||||
</transition>
|
||||
@ -14,9 +14,9 @@
|
||||
* try {navigator.control.gesture(false);} catch (e) {} //UC浏览器关闭默认手势事件
|
||||
try {navigator.control.longpressMenu(false);} catch (e) {} //关闭长按弹出菜单
|
||||
* */
|
||||
import * as Vue from "vue";
|
||||
import Loading from "./components/Loading";
|
||||
import Mask from "./components/Mask";
|
||||
import {mapState} from "vuex";
|
||||
import routes from "./router/routes";
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
@ -28,12 +28,13 @@ export default {
|
||||
transitionName: 'go',
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
computed: {
|
||||
...mapState(['excludeRoutes'])
|
||||
},
|
||||
methods: {},
|
||||
// watch $route 决定使用哪种过渡
|
||||
watch: {
|
||||
'$route'(to, from) {
|
||||
console.log(to)
|
||||
this.$store.commit('setMaskDialog', {state: false, mode: this.maskDialogMode})
|
||||
|
||||
//footer下面的5个按钮,对跳不要用动画
|
||||
@ -42,77 +43,8 @@ export default {
|
||||
return this.transitionName = ''
|
||||
}
|
||||
|
||||
const routeDeep = [
|
||||
'/message', '/attention', '/home', '/me', '/publish',
|
||||
'/home/submit-report',
|
||||
'/home/music',
|
||||
'/home/music-rank-list',
|
||||
'/home/report',
|
||||
'/home/search',
|
||||
|
||||
'/message/more-search',
|
||||
'/message/share-to-friend',
|
||||
'/message/joined-group-chat',
|
||||
'/message/fans',
|
||||
'/message/all',
|
||||
'/message/visitors',
|
||||
'/message/douyin-helper',
|
||||
'/message/system-notice',
|
||||
'/message/task-notice',
|
||||
'/message/live-notice',
|
||||
'/message/money-notice',
|
||||
'/message/notice-setting',
|
||||
'/message/chat',
|
||||
'/message/chat/detail',
|
||||
'/message/chat/red-packet-detail',
|
||||
|
||||
'/me/country-choose',
|
||||
'/me/edit-userinfo',
|
||||
'/me/edit-userinfo-item',
|
||||
'/video-detail',
|
||||
'/me/add-school',
|
||||
'/me/choose-school',
|
||||
'/me/choose-department',
|
||||
'/me/declare-school',
|
||||
'/me/display-type',
|
||||
'/me/choose-location',
|
||||
'/me/choose-province',
|
||||
'/me/choose-city',
|
||||
|
||||
'/people/follow-and-fans',
|
||||
'/people/find-acquaintance',
|
||||
|
||||
'/address-list',
|
||||
'/video-detail',
|
||||
'/me/my-card',
|
||||
'/scan',
|
||||
'/face-to-face',
|
||||
'/set-remark',
|
||||
|
||||
'/me/right-menu/look-history',
|
||||
'/me/right-menu/minor-protection/index',
|
||||
'/me/right-menu/minor-protection/detail-setting',
|
||||
'/me/right-menu/minor-protection/trigger-time',
|
||||
'/me/right-menu/setting',
|
||||
'/me/collect/video-collect',
|
||||
'/me/collect/music-collect',
|
||||
'/me/my-music',
|
||||
'/me/request-update',
|
||||
'/me/my-request-update',
|
||||
|
||||
'/login',
|
||||
'/login/other',
|
||||
'/login/password',
|
||||
'/login/verification-code',
|
||||
'/login/retrieve-password',
|
||||
'/login/help',
|
||||
|
||||
|
||||
'/service-protocol',
|
||||
'',
|
||||
];
|
||||
const toDepth = routeDeep.indexOf(to.path)
|
||||
const fromDepth = routeDeep.indexOf(from.path)
|
||||
const toDepth = routes.findIndex(v => v.path === to.path)
|
||||
const fromDepth = routes.findIndex(v => v.path === from.path)
|
||||
this.transitionName = toDepth > fromDepth ? 'go' : 'back'
|
||||
},
|
||||
},
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div id='BaseHeader' :class="mode">
|
||||
<div id='BaseHeader' :class="[mode,isFixed?'fixed':'']">
|
||||
<div class="header">
|
||||
<back
|
||||
:mode="backMode"
|
||||
@ -22,17 +22,21 @@ export default {
|
||||
type: String,
|
||||
default: 'dark'
|
||||
},
|
||||
backMode:{
|
||||
backMode: {
|
||||
type: String,
|
||||
default: 'gray'
|
||||
},
|
||||
backImg:{
|
||||
backImg: {
|
||||
type: String,
|
||||
default: 'back',
|
||||
},
|
||||
isClose: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isFixed: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -58,8 +62,12 @@ export default {
|
||||
|
||||
#BaseHeader {
|
||||
width: 100%;
|
||||
position: fixed;
|
||||
z-index: 2;
|
||||
|
||||
&.fixed {
|
||||
z-index: 2;
|
||||
top: 0;
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
&.light {
|
||||
background: white;
|
||||
@ -75,7 +83,7 @@ export default {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 6rem;
|
||||
height: @header-height;
|
||||
border-bottom: 1px solid #cccccc11;
|
||||
position: relative;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div v-if="useRefresh" class="scroll-wrapper scroll"
|
||||
<div v-if="useRefresh" class="scroll-wrapper scroll Scroll"
|
||||
ref="wrapper"
|
||||
@touchmove="move"
|
||||
@touchend="end"
|
||||
@ -9,7 +9,7 @@
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="scroll-wrapper scroll" ref="wrapper" @scroll="scroll">
|
||||
<div v-else class="scroll-wrapper scroll Scroll" ref="wrapper" @scroll="scroll">
|
||||
<div class="scroll-content">
|
||||
<slot></slot>
|
||||
</div>
|
||||
@ -17,6 +17,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import Loading from "./Loading";
|
||||
import {nextTick} from "vue";
|
||||
|
||||
export default {
|
||||
name: "Scroll",
|
||||
@ -52,7 +53,9 @@ export default {
|
||||
created() {
|
||||
},
|
||||
mounted() {
|
||||
this.wrapper = this.$refs.wrapper
|
||||
nextTick(() => {
|
||||
this.wrapper = this.$refs.wrapper
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
move(e) {
|
||||
@ -84,12 +87,13 @@ export default {
|
||||
}, 300)
|
||||
},
|
||||
async scroll() {
|
||||
let wrapper = this.$refs.wrapper
|
||||
if (this.fixedHeight !== -1) {
|
||||
this.$emit('fixed', this.fixedHeight < wrapper.scrollTop)
|
||||
this.$emit('fixed', this.fixedHeight < this.wrapper.scrollTop)
|
||||
}
|
||||
if (wrapper.scrollHeight - wrapper.clientHeight < wrapper.scrollTop + 60) {
|
||||
this.$emit('pulldown')
|
||||
if (this.$attrs.onPulldown) {
|
||||
if (this.wrapper.scrollHeight - this.wrapper.clientHeight < this.wrapper.scrollTop + 60) {
|
||||
this.$emit('pulldown')
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
17
src/pages/BasePage.js
Normal file
17
src/pages/BasePage.js
Normal file
@ -0,0 +1,17 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
mainScrollTop: 0,
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
if (this.$refs.mainScroll && this.$refs.mainScroll.wrapper) {
|
||||
this.$refs.mainScroll.wrapper.scrollTop = this.mainScrollTop
|
||||
}
|
||||
},
|
||||
deactivated() {
|
||||
if (this.$refs.mainScroll && this.$refs.mainScroll.wrapper) {
|
||||
this.mainScrollTop = this.$refs.mainScroll.wrapper.scrollTop
|
||||
}
|
||||
},
|
||||
}
|
||||
@ -43,7 +43,7 @@
|
||||
<Loading v-if="loading"/>
|
||||
<Scroll
|
||||
v-else
|
||||
ref="scroll"
|
||||
ref="mainScroll"
|
||||
:use-refresh="true"
|
||||
@refresh="refresh"
|
||||
@pulldown="loadData">
|
||||
@ -122,9 +122,11 @@ import Scroll from "../../components/Scroll";
|
||||
import Loading from "../../components/Loading";
|
||||
import Peoples from "../people/components/Peoples";
|
||||
import resource from "../../assets/data/resource.js";
|
||||
import BasePage from "../BasePage";
|
||||
|
||||
|
||||
export default {
|
||||
extends: BasePage,
|
||||
name: "AllMessage",
|
||||
components: {
|
||||
Scroll,
|
||||
@ -189,7 +191,7 @@ export default {
|
||||
},
|
||||
async refresh() {
|
||||
await this.$sleep(1000)
|
||||
this.$refs.scroll.refreshEnd()
|
||||
this.$refs.mainScroll.refreshEnd()
|
||||
},
|
||||
async loadData() {
|
||||
if (this.loadingMore) return
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div id="Message" ref="app" :class="createChatDialog?'disable-scroll':''">
|
||||
<div class="no-search" v-show="!searching">
|
||||
<BaseHeader>
|
||||
<BaseHeader :isFixed="false">
|
||||
<template v-slot:center>
|
||||
<span class="f16">消息</span>
|
||||
</template>
|
||||
@ -10,7 +10,7 @@
|
||||
</template>
|
||||
</BaseHeader>
|
||||
|
||||
<div class="content">
|
||||
<Scroll ref="mainScroll">
|
||||
<Search class="ml2r mr2r mb2r" @click="searching = true"></Search>
|
||||
<div class="friends pl1r ">
|
||||
<div class="friend pr1r pl1r"
|
||||
@ -251,7 +251,7 @@
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</div>
|
||||
</Scroll>
|
||||
<from-bottom-dialog page-id="Message" v-model="createChatDialog">
|
||||
<div class="create-chat-wrapper" v-show="!showJoinedChat">
|
||||
<Search :isShowRightText="isShowRightText"
|
||||
@ -356,6 +356,8 @@
|
||||
<Mask/>
|
||||
</div>
|
||||
</transition>
|
||||
<Footer v-bind:init-tab="4"/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="searching" v-show="searching">
|
||||
@ -399,7 +401,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Footer v-bind:init-tab="4"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -413,8 +414,10 @@ import Peoples from "../people/components/Peoples";
|
||||
import Mask from "../../components/Mask";
|
||||
import Scroll from "../../components/Scroll";
|
||||
import People from "../people/components/People";
|
||||
import BasePage from "../BasePage";
|
||||
|
||||
export default {
|
||||
extends: BasePage,
|
||||
name: "Message",
|
||||
components: {
|
||||
Scroll,
|
||||
@ -495,7 +498,6 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
@import "../../assets/less/index";
|
||||
|
||||
@ -510,9 +512,7 @@ export default {
|
||||
color: white;
|
||||
|
||||
.no-search {
|
||||
height: calc(100vh - @footer-height);
|
||||
overflow: auto;
|
||||
|
||||
height: 100vh;
|
||||
|
||||
.create-chat-wrapper {
|
||||
min-height: 70vh;
|
||||
@ -756,9 +756,8 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.content {
|
||||
padding-top: @header-height;
|
||||
.scroll {
|
||||
height: calc(100% - @header-height - @footer-height);
|
||||
}
|
||||
|
||||
.friends {
|
||||
|
||||
@ -471,9 +471,6 @@ export default {
|
||||
created() {
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
activated() {
|
||||
this.scrollBottom()
|
||||
},
|
||||
methods: {
|
||||
|
||||
@ -1,165 +1,8 @@
|
||||
import * as VueRouter from "vue-router";
|
||||
import store from "../store";
|
||||
import routes from "./routes";
|
||||
|
||||
import Index from "../pages/home/Index";
|
||||
import Attention from "../pages/home/Attention";
|
||||
import Message from "../pages/message/Message";
|
||||
import Me from "../pages/me/Me";
|
||||
import Music from "../pages/home/Music";
|
||||
import MusicRankList from "../pages/home/MusicRankList";
|
||||
import countryChoose from "../pages/login/countryChoose";
|
||||
import MyCard from "../pages/me/MyCard";
|
||||
import MyCollect from "../pages/me/MyCollect";
|
||||
import VideoDetail from "../pages/me/VideoDetail";
|
||||
import Index2 from "../pages/home/Index2";
|
||||
import EditUserInfo from "../pages/me/userinfo/EditUserInfo";
|
||||
import EditUserInfoItem from "../pages/me/userinfo/EditUserInfoItem";
|
||||
import AddSchool from "../pages/me/userinfo/AddSchool";
|
||||
import ChooseSchool from "../pages/me/userinfo/ChooseSchool";
|
||||
import DeclareSchool from "../pages/me/userinfo/DeclareSchool";
|
||||
import ChooseDepartment from "../pages/me/userinfo/ChooseDepartment";
|
||||
import DisplayType from "../pages/me/userinfo/DisplayType";
|
||||
import Publish from "../pages/home/Publish";
|
||||
import ChooseLocation from "../pages/me/userinfo/ChooseLocation";
|
||||
import ChooseProvince from "../pages/me/userinfo/ChooseProvince";
|
||||
import ChooseCity from "../pages/me/userinfo/ChooseCity";
|
||||
import FindAcquaintance from "../pages/people/FindAcquaintance";
|
||||
import ServiceProtocol from "../pages/other/ServiceProtocol";
|
||||
import AddressList from "../pages/people/AddressList";
|
||||
import Scan from "../pages/people/Scan";
|
||||
import FaceToFace from "../pages/people/FaceToFace";
|
||||
import Chat from "../pages/message/chat/Chat";
|
||||
import ChatDetail from "../pages/message/chat/ChatDetail";
|
||||
import SetRemark from "../pages/message/SetRemark";
|
||||
import LookHistory from "../pages/me/rightMenu/LookHistory";
|
||||
import MinorProtectionIndex from "../pages/me/rightMenu/MinorProtection/Index";
|
||||
import MinorProtectionDetailSetting from "../pages/me/rightMenu/MinorProtection/DetailSetting";
|
||||
import TriggerTime from "../pages/me/rightMenu/MinorProtection/TriggerTime";
|
||||
import Setting from "../pages/me/rightMenu/Setting";
|
||||
import Login from "../pages/login/Login";
|
||||
import OtherLogin from "../pages/login/OtherLogin";
|
||||
import PasswordLogin from "../pages/login/PasswordLogin";
|
||||
import VerificationCode from "../pages/login/VerificationCode";
|
||||
import RetrievePassword from "../pages/login/RetrievePassword";
|
||||
import Help from "../pages/login/Help";
|
||||
import Test from "../pages/test/Test";
|
||||
import Test2 from "../pages/test/Test2";
|
||||
import Test3 from "../pages/test/Test3";
|
||||
import Share2Friend from "../pages/message/Share2Friend";
|
||||
import JoinedGroupChat from "../pages/message/JoinedGroupChat";
|
||||
import Report from "../pages/home/Report";
|
||||
import SubmitReport from "../pages/home/SubmitReport";
|
||||
import RequestUpdate from "../pages/me/RequestUpdate";
|
||||
import Test4 from "../pages/test/Test4";
|
||||
import Search from "../pages/home/SearchPage";
|
||||
import LivePage from "../pages/home/LivePage";
|
||||
import Test5 from "../pages/test/Test5";
|
||||
import MusicCollect from "../pages/me/collect/MusicCollect";
|
||||
import VideoCollect from "../pages/me/collect/VideoCollect";
|
||||
import MyMusic from "../pages/me/MyMusic";
|
||||
import FollowAndFans from "../pages/people/FollowAndFans";
|
||||
import MyRequestUpdate from "../pages/me/MyRequestUpdate";
|
||||
import Fans from "../pages/message/Fans";
|
||||
import AllMessage from "../pages/message/AllMessage";
|
||||
import Visitors from "../pages/message/Visitors";
|
||||
import DouyinHelper from "../pages/message/notice/DouyinHelper";
|
||||
import SystemNotice from "../pages/message/notice/SystemNotice";
|
||||
import NoticeSetting from "../pages/message/notice/NoticeSetting";
|
||||
import TaskNotice from "../pages/message/notice/TaskNotice";
|
||||
import LiveNotice from "../pages/message/notice/LiveNotice";
|
||||
import MoneyNotice from "../pages/message/notice/MoneyNotice";
|
||||
import MoreSearch from "../pages/message/MoreSearch";
|
||||
import TestVue3 from "../pages/test/TestVue3.vue";
|
||||
import RedPacketDetail from "../pages/message/RedPacketDetail";
|
||||
import TestKeepAlive from "../pages/test/TestKeepAlive";
|
||||
import TestKeepAlivePage1 from "../pages/test/TestKeepAlivePage1";
|
||||
|
||||
const routes = [
|
||||
// {path: '', component: Music},
|
||||
// {path: '/', component: Index},
|
||||
{path: '/', component: Index2},
|
||||
{path: '/test', component: Test},
|
||||
{path: '/test2', component: Test2},
|
||||
{path: '/test3', component: Test3},
|
||||
{path: '/test4', component: Test4},
|
||||
{path: '/test5', component: Test5},
|
||||
{path: '/TestVue3', component: TestVue3},
|
||||
{path: '/TestKeepAlive', component: TestKeepAlive},
|
||||
{path: '/TestKeepAlivePage1', component: TestKeepAlivePage1},
|
||||
{path: '/home', component: Index},
|
||||
{path: '/home/submit-report', component: SubmitReport},
|
||||
{path: '/home/music', component: Music},
|
||||
{path: '/home/music-rank-list', component: MusicRankList},
|
||||
{path: '/home/report', component: Report},
|
||||
{path: '/home/search', component: Search},
|
||||
{path: '/home/live', component: LivePage},
|
||||
|
||||
{path: '/video-detail', component: VideoDetail},
|
||||
{path: '/attention', component: Attention},
|
||||
{path: '/publish', component: Publish},
|
||||
|
||||
|
||||
{path: '/message', component: Message, meta: {keepAlive: true,}},
|
||||
{path: '/message/more-search', component: MoreSearch, meta: {keepAlive: true,}},
|
||||
{path: '/message/share-to-friend', component: Share2Friend, meta: {keepAlive: true,}},
|
||||
{path: '/message/joined-group-chat', component: JoinedGroupChat, meta: {keepAlive: true,}},
|
||||
{path: '/message/fans', component: Fans, meta: {keepAlive: true,}},
|
||||
{path: '/message/all', component: AllMessage, meta: {keepAlive: true,}},
|
||||
{path: '/message/visitors', component: Visitors, meta: {keepAlive: true,}},
|
||||
{path: '/message/douyin-helper', component: DouyinHelper, meta: {keepAlive: true,}},
|
||||
{path: '/message/system-notice', component: SystemNotice, meta: {keepAlive: true,}},
|
||||
{path: '/message/task-notice', component: TaskNotice, meta: {keepAlive: true,}},
|
||||
{path: '/message/live-notice', component: LiveNotice, meta: {keepAlive: true,}},
|
||||
{path: '/message/money-notice', component: MoneyNotice, meta: {keepAlive: true,}},
|
||||
{path: '/message/notice-setting', component: NoticeSetting, meta: {keepAlive: true,}},
|
||||
|
||||
{path: '/message/chat', component: Chat, meta: {keepAlive: false,}},
|
||||
{path: '/message/chat/detail', component: ChatDetail, meta: {keepAlive: true,}},
|
||||
{path: '/message/chat/red-packet-detail', component: RedPacketDetail, meta: {keepAlive: true,}},
|
||||
|
||||
|
||||
{path: '/people/find-acquaintance', component: FindAcquaintance},
|
||||
{path: '/people/follow-and-fans', component: FollowAndFans},
|
||||
|
||||
{path: '/service-protocol', component: ServiceProtocol},
|
||||
{path: '/address-list', component: AddressList},
|
||||
{path: '/scan', component: Scan},
|
||||
{path: '/face-to-face', component: FaceToFace},
|
||||
{path: '/set-remark', component: SetRemark},
|
||||
|
||||
{path: '/me', component: Me},
|
||||
{path: '/me/edit-userinfo', component: EditUserInfo},
|
||||
{path: '/me/edit-userinfo-item', component: EditUserInfoItem},
|
||||
{path: '/me/country-choose', component: countryChoose},
|
||||
{path: '/me/my-card', component: MyCard},
|
||||
{path: '/me/my-collect', component: MyCollect},
|
||||
{path: '/me/add-school', component: AddSchool},
|
||||
{path: '/me/choose-school', component: ChooseSchool},
|
||||
{path: '/me/declare-school', component: DeclareSchool},
|
||||
{path: '/me/choose-department', component: ChooseDepartment},
|
||||
{path: '/me/display-type', component: DisplayType},
|
||||
{path: '/me/choose-location', component: ChooseLocation},
|
||||
{path: '/me/choose-province', component: ChooseProvince},
|
||||
{path: '/me/choose-city', component: ChooseCity},
|
||||
{path: '/me/right-menu/look-history', component: LookHistory},
|
||||
{path: '/me/right-menu/minor-protection/index', component: MinorProtectionIndex},
|
||||
{path: '/me/right-menu/minor-protection/detail-setting', component: MinorProtectionDetailSetting},
|
||||
{path: '/me/right-menu/minor-protection/trigger-time', component: TriggerTime},
|
||||
{path: '/me/right-menu/setting', component: Setting},
|
||||
{path: '/me/collect/music-collect', component: MusicCollect},
|
||||
{path: '/me/collect/video-collect', component: VideoCollect},
|
||||
{path: '/me/my-music', component: MyMusic},
|
||||
{path: '/me/request-update', component: RequestUpdate},
|
||||
{path: '/me/my-request-update', component: MyRequestUpdate},
|
||||
|
||||
{path: '/login', component: Login},
|
||||
{path: '/login/other', component: OtherLogin},
|
||||
{path: '/login/password', component: PasswordLogin},
|
||||
{path: '/login/verification-code', component: VerificationCode},
|
||||
{path: '/login/retrieve-password', component: RetrievePassword},
|
||||
{path: '/login/help', component: Help},
|
||||
]
|
||||
|
||||
export default VueRouter.createRouter({
|
||||
const router = VueRouter.createRouter({
|
||||
history: VueRouter.createWebHashHistory(),
|
||||
routes,
|
||||
scrollBehavior(to, from, savedPosition) {
|
||||
@ -170,4 +13,32 @@ export default VueRouter.createRouter({
|
||||
return {top: 0}
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
router.beforeEach((to, from) => {
|
||||
//footer下面的5个按钮,对跳不要用动画
|
||||
let noAnimation = ['/', '/home', '/me', '/attention', '/message', '/publish', '/home/live']
|
||||
if (noAnimation.indexOf(from.path) !== -1 && noAnimation.indexOf(to.path) !== -1) {
|
||||
return true
|
||||
}
|
||||
|
||||
const toDepth = routes.findIndex(v => v.path === to.path)
|
||||
const fromDepth = routes.findIndex(v => v.path === from.path)
|
||||
// const fromDepth = routeDeep.indexOf(from.path)
|
||||
if (toDepth > fromDepth) {
|
||||
let toComponentName = to.matched[0].components.default.name
|
||||
store.commit('updateExcludeRoutes', {type: 'remove', value: toComponentName})
|
||||
// console.log('to', toComponentName)
|
||||
// console.log('前进')
|
||||
// console.log('删除', toComponentName)
|
||||
} else {
|
||||
let fromComponentName = from.matched[0].components.default.name
|
||||
store.commit('updateExcludeRoutes', {type: 'add', value: fromComponentName})
|
||||
// console.log('后退')
|
||||
// console.log('添加', fromComponentName)
|
||||
}
|
||||
// ...
|
||||
// 返回 false 以取消导航
|
||||
return true
|
||||
})
|
||||
|
||||
export default router
|
||||
163
src/router/routes.js
Normal file
163
src/router/routes.js
Normal file
@ -0,0 +1,163 @@
|
||||
import Index2 from "../pages/home/Index2";
|
||||
import Test from "../pages/test/Test";
|
||||
import Test2 from "../pages/test/Test2";
|
||||
import Test3 from "../pages/test/Test3";
|
||||
import Test4 from "../pages/test/Test4";
|
||||
import Test5 from "../pages/test/Test5";
|
||||
import TestVue3 from "../pages/test/TestVue3";
|
||||
import TestKeepAlive from "../pages/test/TestKeepAlive";
|
||||
import TestKeepAlivePage1 from "../pages/test/TestKeepAlivePage1";
|
||||
import Index from "../pages/home";
|
||||
import SubmitReport from "../pages/home/SubmitReport";
|
||||
import Music from "../pages/home/Music";
|
||||
import MusicRankList from "../pages/home/MusicRankList";
|
||||
import Report from "../pages/home/Report";
|
||||
import Search from "../pages/home/SearchPage";
|
||||
import LivePage from "../pages/home/LivePage";
|
||||
import VideoDetail from "../pages/me/VideoDetail";
|
||||
import Attention from "../pages/home/Attention";
|
||||
import Publish from "../pages/home/Publish";
|
||||
import Me from "../pages/me/Me";
|
||||
import EditUserInfo from "../pages/me/userinfo/EditUserInfo";
|
||||
import EditUserInfoItem from "../pages/me/userinfo/EditUserInfoItem";
|
||||
import countryChoose from "../pages/login/countryChoose";
|
||||
import MyCard from "../pages/me/MyCard";
|
||||
import MyCollect from "../pages/me/MyCollect";
|
||||
import AddSchool from "../pages/me/userinfo/AddSchool";
|
||||
import ChooseSchool from "../pages/me/userinfo/ChooseSchool";
|
||||
import DeclareSchool from "../pages/me/userinfo/DeclareSchool";
|
||||
import ChooseDepartment from "../pages/me/userinfo/ChooseDepartment";
|
||||
import DisplayType from "../pages/me/userinfo/DisplayType";
|
||||
import ChooseLocation from "../pages/me/userinfo/ChooseLocation";
|
||||
import ChooseProvince from "../pages/me/userinfo/ChooseProvince";
|
||||
import ChooseCity from "../pages/me/userinfo/ChooseCity";
|
||||
import LookHistory from "../pages/me/rightMenu/LookHistory";
|
||||
import MinorProtectionIndex from "../pages/me/rightMenu/MinorProtection";
|
||||
import MinorProtectionDetailSetting from "../pages/me/rightMenu/MinorProtection/DetailSetting";
|
||||
import TriggerTime from "../pages/me/rightMenu/MinorProtection/TriggerTime";
|
||||
import Setting from "../pages/me/rightMenu/Setting";
|
||||
import MusicCollect from "../pages/me/collect/MusicCollect";
|
||||
import VideoCollect from "../pages/me/collect/VideoCollect";
|
||||
import MyMusic from "../pages/me/MyMusic";
|
||||
import RequestUpdate from "../pages/me/RequestUpdate";
|
||||
import MyRequestUpdate from "../pages/me/MyRequestUpdate";
|
||||
import Message from "../pages/message/Message";
|
||||
import AllMessage from "../pages/message/AllMessage";
|
||||
import MoreSearch from "../pages/message/MoreSearch";
|
||||
import Share2Friend from "../pages/message/Share2Friend";
|
||||
import JoinedGroupChat from "../pages/message/JoinedGroupChat";
|
||||
import Fans from "../pages/message/Fans";
|
||||
import Visitors from "../pages/message/Visitors";
|
||||
import DouyinHelper from "../pages/message/notice/DouyinHelper";
|
||||
import SystemNotice from "../pages/message/notice/SystemNotice";
|
||||
import TaskNotice from "../pages/message/notice/TaskNotice";
|
||||
import LiveNotice from "../pages/message/notice/LiveNotice";
|
||||
import MoneyNotice from "../pages/message/notice/MoneyNotice";
|
||||
import NoticeSetting from "../pages/message/notice/NoticeSetting";
|
||||
import Chat from "../pages/message/chat/Chat";
|
||||
import ChatDetail from "../pages/message/chat/ChatDetail";
|
||||
import RedPacketDetail from "../pages/message/RedPacketDetail";
|
||||
import FindAcquaintance from "../pages/people/FindAcquaintance";
|
||||
import FollowAndFans from "../pages/people/FollowAndFans";
|
||||
import ServiceProtocol from "../pages/other/ServiceProtocol";
|
||||
import AddressList from "../pages/people/AddressList";
|
||||
import Scan from "../pages/people/Scan";
|
||||
import FaceToFace from "../pages/people/FaceToFace";
|
||||
import SetRemark from "../pages/message/SetRemark";
|
||||
import Login from "../pages/login/Login";
|
||||
import OtherLogin from "../pages/login/OtherLogin";
|
||||
import PasswordLogin from "../pages/login/PasswordLogin";
|
||||
import VerificationCode from "../pages/login/VerificationCode";
|
||||
import RetrievePassword from "../pages/login/RetrievePassword";
|
||||
import Help from "../pages/login/Help";
|
||||
|
||||
const routes = [
|
||||
// {path: '', component: Music},
|
||||
// {path: '/', component: Index},
|
||||
{path: '/', component: Index2},
|
||||
{path: '/test', component: Test},
|
||||
{path: '/test2', component: Test2},
|
||||
{path: '/test3', component: Test3},
|
||||
{path: '/test4', component: Test4},
|
||||
{path: '/test5', component: Test5},
|
||||
{path: '/TestVue3', component: TestVue3},
|
||||
{path: '/TestKeepAlive', component: TestKeepAlive},
|
||||
{path: '/TestKeepAlivePage1', component: TestKeepAlivePage1},
|
||||
{path: '/home', component: Index},
|
||||
{path: '/home/submit-report', component: SubmitReport},
|
||||
{path: '/home/music', component: Music},
|
||||
{path: '/home/music-rank-list', component: MusicRankList},
|
||||
{path: '/home/report', component: Report},
|
||||
{path: '/home/search', component: Search},
|
||||
{path: '/home/live', component: LivePage},
|
||||
|
||||
{path: '/video-detail', component: VideoDetail},
|
||||
{path: '/attention', component: Attention},
|
||||
{path: '/publish', component: Publish},
|
||||
|
||||
|
||||
{path: '/me', component: Me,},
|
||||
{path: '/me/edit-userinfo', component: EditUserInfo},
|
||||
{path: '/me/edit-userinfo-item', component: EditUserInfoItem},
|
||||
{path: '/me/country-choose', component: countryChoose},
|
||||
{path: '/me/my-card', component: MyCard},
|
||||
{path: '/me/my-collect', component: MyCollect},
|
||||
{path: '/me/add-school', component: AddSchool},
|
||||
{path: '/me/choose-school', component: ChooseSchool},
|
||||
{path: '/me/declare-school', component: DeclareSchool},
|
||||
{path: '/me/choose-department', component: ChooseDepartment},
|
||||
{path: '/me/display-type', component: DisplayType},
|
||||
{path: '/me/choose-location', component: ChooseLocation},
|
||||
{path: '/me/choose-province', component: ChooseProvince},
|
||||
{path: '/me/choose-city', component: ChooseCity},
|
||||
{path: '/me/right-menu/look-history', component: LookHistory},
|
||||
{path: '/me/right-menu/minor-protection/index', component: MinorProtectionIndex},
|
||||
{path: '/me/right-menu/minor-protection/detail-setting', component: MinorProtectionDetailSetting},
|
||||
{path: '/me/right-menu/minor-protection/trigger-time', component: TriggerTime},
|
||||
{path: '/me/right-menu/setting', component: Setting},
|
||||
{path: '/me/collect/music-collect', component: MusicCollect},
|
||||
{path: '/me/collect/video-collect', component: VideoCollect},
|
||||
{path: '/me/my-music', component: MyMusic},
|
||||
|
||||
{path: '/message', component: Message},
|
||||
{path: '/message/all', component: AllMessage},
|
||||
{path: '/message/more-search', component: MoreSearch},
|
||||
{path: '/message/share-to-friend', component: Share2Friend},
|
||||
{path: '/message/joined-group-chat', component: JoinedGroupChat},
|
||||
{path: '/message/fans', component: Fans},
|
||||
{path: '/message/visitors', component: Visitors},
|
||||
{path: '/message/douyin-helper', component: DouyinHelper},
|
||||
{path: '/message/system-notice', component: SystemNotice},
|
||||
{path: '/message/task-notice', component: TaskNotice},
|
||||
{path: '/message/live-notice', component: LiveNotice},
|
||||
{path: '/message/money-notice', component: MoneyNotice},
|
||||
{path: '/message/notice-setting', component: NoticeSetting},
|
||||
|
||||
{path: '/message/chat', component: Chat},
|
||||
{path: '/message/chat/detail', component: ChatDetail},
|
||||
{path: '/message/chat/red-packet-detail', component: RedPacketDetail},
|
||||
|
||||
|
||||
{path: '/people/find-acquaintance', component: FindAcquaintance},
|
||||
{path: '/people/follow-and-fans', component: FollowAndFans},
|
||||
|
||||
{path: '/service-protocol', component: ServiceProtocol},
|
||||
{path: '/address-list', component: AddressList},
|
||||
{path: '/scan', component: Scan},
|
||||
{path: '/face-to-face', component: FaceToFace},
|
||||
{path: '/set-remark', component: SetRemark},
|
||||
|
||||
|
||||
{path: '/login', component: Login},
|
||||
{path: '/login/other', component: OtherLogin},
|
||||
{path: '/login/password', component: PasswordLogin},
|
||||
{path: '/login/verification-code', component: VerificationCode},
|
||||
{path: '/login/retrieve-password', component: RetrievePassword},
|
||||
{path: '/login/help', component: Help},
|
||||
|
||||
//message页面要跳到这页面,所以放后面
|
||||
{path: '/me/request-update', component: RequestUpdate},
|
||||
{path: '/me/my-request-update', component: MyRequestUpdate},
|
||||
]
|
||||
|
||||
export default routes
|
||||
@ -615,8 +615,8 @@ const store = Vuex.createStore({
|
||||
"select": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
},
|
||||
excludeRoutes: []
|
||||
},
|
||||
mutations: {
|
||||
setUserinfo(store, val) {
|
||||
@ -630,7 +630,20 @@ const store = Vuex.createStore({
|
||||
if (val.mode) {
|
||||
store.maskDialogMode = val.mode
|
||||
}
|
||||
}
|
||||
},
|
||||
updateExcludeRoutes(store, val) {
|
||||
if (val.type === 'add') {
|
||||
if (!store.excludeRoutes.find(v => v === val.value)) {
|
||||
store.excludeRoutes.push(val.value)
|
||||
}
|
||||
} else {
|
||||
let resIndex = store.excludeRoutes.findIndex(v => v === val.value)
|
||||
if (resIndex !== -1) {
|
||||
store.excludeRoutes.splice(resIndex, 1)
|
||||
}
|
||||
}
|
||||
// console.log('store.excludeRoutes', store.excludeRoutes)
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async getFriends(context) {
|
||||
|
||||
@ -22,5 +22,9 @@ export default defineConfig({
|
||||
},
|
||||
build: {
|
||||
sourcemap: false
|
||||
},
|
||||
server: {
|
||||
open: true,
|
||||
host: '0.0.0.0'
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user