Commit e67f7a54 authored by 周远喜's avatar 周远喜

打开页面设置,基本正常。

parent f174bcba
......@@ -32,9 +32,10 @@
},
methods: {
handleOpenLog () {
this.$router.push({
name: 'log'
});
// this.$router.push({
// name: 'log'
// });
this.$router.push("/system/log");
}
}
}
......
<template>
<MainLayout/>
<MainLayout />
</template>
<script>
import MainLayout from './basic-layout'
import MainLayout from "./basic-layout";
// 配置
import Setting from "@/setting";
// 方法
import { getHeaderName, getMenuSider, getSiderSubmenu } from "@/libs/system";
// 菜单和路由
import router from '@/router';
import menuHeader from '@/menu/header';
import menuSider from '@/menu/sider';
import { frameInRoutes } from '@/router/routes';
export default {
components:{MainLayout}
}
components: { MainLayout },
created() {
// const filterMenuSider = getMenuSider(menuSider, "home");
// this.$store.commit("admin/menu/setSider", filterMenuSider);
console.warn("menu",menuSider,frameInRoutes,menuHeader);
// 处理路由 得到每一级的路由设置
this.$store.commit("admin/page/init", frameInRoutes);
// 设置顶栏菜单
this.$store.commit("admin/menu/setHeader", menuHeader);
// 加载用户登录的数据
this.$store.dispatch("admin/account/load");
// 初始化全屏监听
this.$store.dispatch("admin/layout/listenFullscreen");
},
watch: {
// 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要)
$route(to, from) {
console.warn("to,from", to, from);
let path = to.matched[to.matched.length - 1].path;
if (!Setting.dynamicSiderMenu) {
let headerName = getHeaderName(path, menuSider);
if (headerName === null) {
path = to.path;
headerName = getHeaderName(path, menuSider);
}
// 在 404 时,是没有 headerName 的
if (headerName !== null) {
this.$store.commit("admin/menu/setHeaderName", headerName);
const filterMenuSider = getMenuSider(menuSider, headerName);
this.$store.commit("admin/menu/setSider", filterMenuSider);
this.$store.commit("admin/menu/setActivePath", to.path);
const openNames = getSiderSubmenu(path, menuSider);
this.$store.commit("admin/menu/setOpenNames", openNames);
}
}
// this.appRouteChange(to, from);
}
}
};
</script>
\ No newline at end of file
......@@ -54,7 +54,8 @@ export default {
** Plugins to load before mounting the App
*/
plugins: [
'@/plugins/iview'
'@/plugins/iview',
'@/plugins/route'
],
/*
** Nuxt.js dev-modules
......
import iView from 'view-design';
import util from '@/libs/util'
import Setting from '@/setting';
export default ({
app,
router,
store
}) => {
/**
* 路由拦截
* 权限验证
*/
app.router.beforeEach((to, from, next) => {
if (Setting.showProgressBar) iView.LoadingBar.start();
// 判断是否需要登录才可以进入
if (to.matched.some(_ => _.meta.auth)) {
// 这里依据 token 判断是否登录,可视情况修改
const token = util.cookies.get('token');
if (token && token !== 'undefined') {
next();
} else {
// 没有登录的时候跳转到登录界面
// 携带上登陆成功之后需要跳转的页面完整路径
next({
name: 'login',
query: {
redirect: to.fullPath
}
});
}
} else {
// 不需要身份校验 直接通过
next();
}
});
app.router.afterEach(to => {
if (Setting.showProgressBar) iView.LoadingBar.finish();
// 多页控制 打开新的页面
store.dispatch('admin/page/open', to);
console.info("log",to)
// 更改标题
util.title({
title: to.meta.title
});
// 返回页面顶端
window.scrollTo(0, 0);
});
}
......@@ -16,13 +16,17 @@ const frameIn = [
{
path: 'index',
name: 'index',
meta: {
title: '首页',
auth: true
},
redirect: {
name: 'dashboard-console'
}
},
{
path: 'log',
name: 'log',
path: '/system/log',
name: 'system-log',
meta: {
title: '前端日志',
auth: true
......
......@@ -9,7 +9,7 @@ import { getAllSiderMenu, includeArray } from '@/libs/system';
// 判定是否需要缓存
const isKeepAlive = data => get(data, 'meta.cache', false);
export const strict=false;
export const state=()=>({
// 可以在多页 tab 模式下显示的页面
pool: [],
......
......@@ -4,6 +4,9 @@ export const state=()=>({
export const mutations={
increment(state){
state.counter++
},
setUser(state,info){
state.info=info;
}
}
export const actions={
......@@ -13,10 +16,11 @@ export const actions={
* @param {Object} dispatch vuex dispatch
* @param {*} info info
*/
set ({ state, dispatch }, info) {
set ({ state, dispatch,commit}, info) {
return new Promise(async resolve => {
// store 赋值
state.info = info;
// state.info = info;
commit("setUser",info)
// 持久化
await dispatch('admin/db/set', {
dbName: 'sys',
......@@ -33,15 +37,16 @@ export const actions={
* @param {Object} state vuex state
* @param {Object} dispatch vuex dispatch
*/
load ({ state, dispatch }) {
load ({ state, dispatch ,commit}) {
return new Promise(async resolve => {
// store 赋值
state.info = await dispatch('admin/db/get', {
let info = await dispatch('admin/db/get', {
dbName: 'sys',
path: 'user.info',
defaultValue: {},
user: true
}, { root: true });
commit("setUser",info)
// end
resolve();
})
......
import createVuexAlong from 'vuex-along'
export const state=()=>({
counter:0
})
......@@ -5,4 +6,21 @@ export const mutations={
increment(state){
state.counter++
}
}
\ No newline at end of file
}
export const plugins= [
createVuexAlong({
// 设置保存的集合名字,避免同站点下的多项目数据冲突
name: "hyhmes",
local: {
list: ["hyhmes"],
// 过滤模块 ma 数据, 将其他的存入 localStorage
isFilter: true,
},
session: {
// 保存模块 ma 中的 a1 到 sessionStorage
list: ["hyhmes.session"],
},
}),
]
//设置 strict 为不严格模式,即可在actions中修改state
export const strict=false;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment