修复一波页面导航
This commit is contained in:
@@ -34,8 +34,9 @@ export default {
|
|||||||
name: "navTabs",
|
name: "navTabs",
|
||||||
components: {Setting, Close},
|
components: {Setting, Close},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(mainStore, ['pages']),
|
...mapState(mainStore, ['pages', 'routes']),
|
||||||
tabs: v => v.pages
|
tabs: v => v.pages,
|
||||||
|
currentTab: v => v.$route.fullPath
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(mainStore, ['deletePage', 'clearOtherPages', 'addPage']),
|
...mapActions(mainStore, ['deletePage', 'clearOtherPages', 'addPage']),
|
||||||
@@ -43,14 +44,15 @@ export default {
|
|||||||
const {pages} = this
|
const {pages} = this
|
||||||
if (id == this.currentTab) {
|
if (id == this.currentTab) {
|
||||||
const index = pages.findIndex(e => e.id == id)
|
const index = pages.findIndex(e => e.id == id)
|
||||||
const next = pages?.[index + 1] || pages?.[index - 1] || {id: this.fixed.id || "/"}
|
const next = pages?.[index + 1] || pages?.[index - 1] || {id: "/"}
|
||||||
|
console.log(next, this.currentTab)
|
||||||
this.handleJump({name: next.id})
|
this.handleJump({name: next.id})
|
||||||
}
|
}
|
||||||
this.deletePage(id)
|
this.deletePage(id)
|
||||||
},
|
},
|
||||||
handleJump(page) {
|
handleJump(page) {
|
||||||
const {name} = page
|
const {name} = page
|
||||||
name != this.$route.fullPath && this.$router.push(name)
|
name != this.currentTab && this.$router.push(name)
|
||||||
},
|
},
|
||||||
handleOpt(v) {
|
handleOpt(v) {
|
||||||
const opts = {
|
const opts = {
|
||||||
@@ -67,14 +69,10 @@ export default {
|
|||||||
$route: {
|
$route: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler(v) {
|
handler(v) {
|
||||||
const currentPage = this.pages.find(e => e.name == v.name);
|
const currentPage = this.routes.find(e => e.name == v.name);
|
||||||
currentPage && this.addPage(currentPage)
|
currentPage && this.addPage(currentPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
created() {
|
|
||||||
const currentPage = JSON.parse(localStorage.getItem("apps") || null)?.find(e => e.name == this.$route.name);
|
|
||||||
currentPage && mainStore().addPage(currentPage)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ app.config.globalProperties.$sys = {
|
|||||||
title: "综合业务管理平台"
|
title: "综合业务管理平台"
|
||||||
}
|
}
|
||||||
Object.keys(tools).map(e => app.config.globalProperties[e] = tools[e])
|
Object.keys(tools).map(e => app.config.globalProperties[e] = tools[e])
|
||||||
|
app.use(eui, {locale: zhCn})
|
||||||
|
const store = createPinia()
|
||||||
|
store.use(persist)
|
||||||
|
app.use(store)
|
||||||
router.then(r => {
|
router.then(r => {
|
||||||
app.use(eui, {locale: zhCn})
|
|
||||||
app.use(r)
|
app.use(r)
|
||||||
const store = createPinia()
|
|
||||||
store.use(persist)
|
|
||||||
app.use(store)
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import {createRouter, createWebHistory} from 'vue-router'
|
import {createRouter, createWebHistory} from 'vue-router'
|
||||||
import {getToken} from './tools'
|
import {getToken} from './tools'
|
||||||
|
import {mainStore} from "./store";
|
||||||
|
|
||||||
|
|
||||||
let home = {name: "工作台", path: "/v", component: () => import('../views/home')},
|
let home = {name: "工作台", path: "/", component: () => import('../views/home')},
|
||||||
routes = [{name: "登录", path: "/login", component: () => import('../views/login')}]
|
routes = [{name: "登录", path: "/login", component: () => import('../views/login')}]
|
||||||
const loadApps = () => {
|
const loadApps = () => {
|
||||||
const files = import.meta.glob('../apps/App*.vue'), apps = []
|
const files = import.meta.glob('../apps/App*.vue'), apps = []
|
||||||
@@ -19,7 +20,7 @@ const loadApps = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})).then(() => {
|
})).then(() => {
|
||||||
localStorage.setItem("apps", JSON.stringify(apps))
|
mainStore().setRoutes(apps)
|
||||||
home.children = apps
|
home.children = apps
|
||||||
routes.push(home)
|
routes.push(home)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ export const mainStore = defineStore('main', {
|
|||||||
state: () => ({
|
state: () => ({
|
||||||
user: {},
|
user: {},
|
||||||
token: "",
|
token: "",
|
||||||
pages: []
|
pages: [],
|
||||||
|
routes: []
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
getToken(params) {
|
getToken(params) {
|
||||||
@@ -25,7 +26,8 @@ export const mainStore = defineStore('main', {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
addPage(page) {
|
addPage(page) {
|
||||||
if (!this.pages.find(e => e.id == location.href)) this.pages.push({...page, id: location.href})
|
const id = page?.id || location.href?.replace(location.origin, "")
|
||||||
|
if (!this.pages.find(e => e.id == id)) this.pages.push({...page, id})
|
||||||
},
|
},
|
||||||
deletePage(id) {
|
deletePage(id) {
|
||||||
id = id || location.href?.replace(location.origin, "")
|
id = id || location.href?.replace(location.origin, "")
|
||||||
@@ -42,6 +44,9 @@ export const mainStore = defineStore('main', {
|
|||||||
logout() {
|
logout() {
|
||||||
this.user = {}
|
this.user = {}
|
||||||
this.token = ""
|
this.token = ""
|
||||||
|
},
|
||||||
|
setRoutes(routes) {
|
||||||
|
this.routes = routes
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
persist: {
|
persist: {
|
||||||
|
|||||||
Reference in New Issue
Block a user