Commit c98f8614 authored by smallwei's avatar smallwei

sys cli2

parent 50b98c63
{ {
"name": "avue-cli", "name": "avue-cli",
"version": "2.0.0", "version": "2.0.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"lint": "vue-cli-service lint", "lint": "vue-cli-service lint",
"test:unit": "vue-cli-service test:unit", "test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e" "test:e2e": "vue-cli-service test:e2e"
}, },
"dependencies": { "dependencies": {
"@smallwei/avue": "^1.3.1-beta3", "@smallwei/avue": "^1.4.0",
"avue-plugin-transfer": "^0.0.2", "avue-plugin-transfer": "^0.0.2",
"avue-plugin-ueditor": "^0.0.1", "avue-plugin-ueditor": "^0.0.1",
"axios": "^0.18.0", "axios": "^0.18.0",
"babel-loader": "^8.0.2", "babel-loader": "^8.0.2",
"babel-plugin-transform-runtime": "^6.23.0", "babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"classlist-polyfill": "^1.2.0", "classlist-polyfill": "^1.2.0",
"driver.js": "^0.6.2", "driver.js": "^0.6.2",
"element-ui": "^2.4.6", "element-ui": "^2.4.6",
"file-saver": "^1.3.8", "file-saver": "^1.3.8",
"html2canvas": "^1.0.0-alpha.12", "html2canvas": "^1.0.0-alpha.12",
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"mockjs": "^1.0.1-beta3", "mockjs": "^1.0.1-beta3",
"moment": "^2.22.2", "moment": "^2.22.2",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"script-loader": "^0.7.2", "script-loader": "^0.7.2",
"vue": "^2.5.16", "vue": "^2.5.16",
"vue-axios": "^2.1.2", "vue-axios": "^2.1.2",
"vue-clipboard2": "^0.2.1", "vue-clipboard2": "^0.2.1",
"vue-json-editor": "^1.2.3", "vue-json-editor": "^1.2.3",
"vue-json-tree-view": "^2.1.4", "vue-json-tree-view": "^2.1.4",
"vue-quill-editor": "^3.0.6", "vue-quill-editor": "^3.0.6",
"vue-router": "^3.0.1", "vue-router": "^3.0.1",
"vuedraggable": "^2.16.0", "vuedraggable": "^2.16.0",
"vuex": "^3.0.1", "vuex": "^3.0.1",
"xlsx": "^0.13.3" "xlsx": "^0.13.3"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^3.0.0", "@vue/cli-plugin-babel": "^3.1.1",
"@vue/cli-plugin-e2e-cypress": "^3.0.0", "@vue/cli-plugin-e2e-cypress": "^3.1.2",
"@vue/cli-plugin-eslint": "^3.0.0", "@vue/cli-plugin-eslint": "^3.1.5",
"@vue/cli-plugin-unit-mocha": "^3.0.0", "@vue/cli-plugin-unit-mocha": "^3.1.1",
"@vue/cli-service": "^3.0.0", "@vue/cli-service": "^3.1.4",
"@vue/test-utils": "^1.0.0-beta.20", "@vue/test-utils": "^1.0.0-beta.25",
"chai": "^4.1.2", "chai": "^4.1.2",
"node-sass": "^4.9.0", "node-sass": "^4.9.0",
"sass-loader": "^7.0.1", "sass-loader": "^7.0.1",
"vue-template-compiler": "^2.5.17" "vue-template-compiler": "^2.5.17"
}, },
"lint-staged": { "lint-staged": {
"*.js": [ "*.js": [
"vue-cli-service lint", "vue-cli-service lint",
"git add" "git add"
], ],
"*.vue": [ "*.vue": [
"vue-cli-service lint", "vue-cli-service lint",
"git add" "git add"
] ]
} }
} }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<script src="<%= BASE_URL %>util/pad-zeropadding.js" charset="utf-8"></script> <script src="<%= BASE_URL %>util/pad-zeropadding.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/vue/2.5.2/vue.min.js" charset="utf-8"></script> <script src="<%= BASE_URL %>cdn/vue/2.5.2/vue.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/vuex/2.4.1/vuex.min.js" charset="utf-8"></script> <script src="<%= BASE_URL %>cdn/vuex/2.4.1/vuex.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/vue-router/3.0.1/vue-router.js" charset="utf-8"></script> <script src="<%= BASE_URL %>cdn/vue-router/3.0.1/vue-router.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/axios/1.0.0/axios.min.js" charset="utf-8"></script> <script src="<%= BASE_URL %>cdn/axios/1.0.0/axios.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/element-ui/2.4.6/index.js" charset="utf-8"></script> <script src="<%= BASE_URL %>cdn/element-ui/2.4.6/index.js" charset="utf-8"></script>
</body> </body>
......
export default { export default {
title: "Avue", title: "PigX",
logo: "A", logo: "P",
indexTitle: 'avue-cli By smallwei', indexTitle: 'avue-cli By smallwei',
whiteList: ["/login", "/404", "/401", "/lock"], //配置无权限可以访问的页面 whiteList: ["/login", "/404", "/401", "/lock"], //配置无权限可以访问的页面
whiteTagList: ["/login", "/404", "/401", "/lock", ], //配置不添加tags页面 ('/advanced-router/mutative-detail/*'——*为通配符) whiteTagList: ["/login", "/404", "/401", "/lock", ], //配置不添加tags页面 ('/advanced-router/mutative-detail/*'——*为通配符)
...@@ -25,4 +25,4 @@ export default { ...@@ -25,4 +25,4 @@ export default {
children: 'children' children: 'children'
} }
} }
} }
\ No newline at end of file
...@@ -31,8 +31,8 @@ export default { ...@@ -31,8 +31,8 @@ export default {
created () { created () {
this.$store.dispatch("GetMenu").then(data => { this.$store.dispatch("GetMenu").then(data => {
if (data.length === 0) return if (data.length === 0) return
this.$router.addRoutes(this.$router.$avueRouter.formatRoutes(data, true)) this.$router.$avueRouter.formatRoutes(data, true);
}); })
}, },
computed: { computed: {
...mapGetters(['website', 'menu', 'tag', 'keyCollapse', 'screen']), ...mapGetters(['website', 'menu', 'tag', 'keyCollapse', 'screen']),
...@@ -43,5 +43,4 @@ export default { ...@@ -43,5 +43,4 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
</style> </style>
\ No newline at end of file
<template> <template>
<div class="menu-wrapper"> <div class="menu-wrapper">
<template v-for="(item,index) in menu"> <template v-for="item in menu">
<el-menu-item v-if="validatenull(item[childrenKey])" <el-menu-item v-if="validatenull(item[childrenKey]) && vaildRoles(item)"
:index="filterPath(item[pathKey],index)" :index="item[pathKey]"
@click="open(item)" @click="open(item)"
:key="item[labelKey]"> :key="item[labelKey]"
:class="{'is-active':nowTagValue===item[pathKey]}">
<i :class="item[iconKey]"></i> <i :class="item[iconKey]"></i>
<span slot="title">{{item[labelKey]}}</span> <span slot="title">{{item[labelKey]}}</span>
</el-menu-item> </el-menu-item>
<el-submenu v-else <el-submenu v-else-if="!validatenull(item[childrenKey])&&vaildRoles(item)"
:index="filterPath(item[labelKey],index)" :index="item[pathKey]"
:key="item[labelKey]"> :key="item[labelKey]">
<template slot="title"> <template slot="title">
<i :class="item[iconKey]"></i> <i :class="item[iconKey]"></i>
...@@ -17,16 +18,16 @@ ...@@ -17,16 +18,16 @@
:class="{'el-menu--display':collapse}">{{item[labelKey]}}</span> :class="{'el-menu--display':collapse}">{{item[labelKey]}}</span>
</template> </template>
<template v-for="(child,cindex) in item[childrenKey]"> <template v-for="(child,cindex) in item[childrenKey]">
<el-menu-item :class="{'siderbar-active':nowTagValue==child[pathKey]}" <el-menu-item :index="child[pathKey],cindex"
:index="filterPath(child[pathKey],cindex)"
@click="open(child)" @click="open(child)"
:class="{'is-active':nowTagValue===child[pathKey]}"
v-if="validatenull(child[childrenKey])" v-if="validatenull(child[childrenKey])"
:key="child[labelKey]"> :key="child[labelKey]">
<i :class="child[iconKey]"></i> <i :class="child[iconKey]"></i>
<span slot="title">{{child[labelKey]}}</span> <span slot="title">{{child[labelKey]}}</span>
</el-menu-item> </el-menu-item>
<sidebar-item v-else <sidebar-item v-else
:menu="[child]" :menu="child[childrenKey]"
:key="cindex" :key="cindex"
:props="props" :props="props"
:screen="screen" :screen="screen"
...@@ -37,6 +38,7 @@ ...@@ -37,6 +38,7 @@
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import { validatenull } from '@/util/validate'; import { validatenull } from '@/util/validate';
import config from './config.js' import config from './config.js'
export default { export default {
...@@ -65,6 +67,7 @@ export default { ...@@ -65,6 +67,7 @@ export default {
}, },
mounted () { }, mounted () { },
computed: { computed: {
...mapGetters(['roles']),
labelKey () { return this.props.label || this.config.propsDefault.label }, labelKey () { return this.props.label || this.config.propsDefault.label },
pathKey () { return this.props.path || this.config.propsDefault.path }, pathKey () { return this.props.path || this.config.propsDefault.path },
iconKey () { return this.props.icon || this.config.propsDefault.icon }, iconKey () { return this.props.icon || this.config.propsDefault.icon },
...@@ -72,12 +75,13 @@ export default { ...@@ -72,12 +75,13 @@ export default {
nowTagValue () { return this.$router.$avueRouter.getValue(this.$route) } nowTagValue () { return this.$router.$avueRouter.getValue(this.$route) }
}, },
methods: { methods: {
vaildRoles (item) {
item.meta = item.meta || {};
return item.meta.roles ? item.meta.roles.includes(this.roles) : true
},
validatenull (val) { validatenull (val) {
return validatenull(val); return validatenull(val);
}, },
filterPath (path, index) {
return path == null ? index + '' : path
},
open (item) { open (item) {
if (this.screen <= 1) this.$store.commit("SET_COLLAPSE"); if (this.screen <= 1) this.$store.commit("SET_COLLAPSE");
this.$router.push({ this.$router.push({
...@@ -91,13 +95,3 @@ export default { ...@@ -91,13 +95,3 @@ export default {
} }
} }
</script> </script>
<style lang="scss" scoped>
//刷新激活状态
.siderbar-active {
i,
span {
color: #409eff;
}
}
</style>
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
<script> <script>
import { mapGetters, mapState } from 'vuex' import { mapGetters, mapState } from 'vuex'
import { isObjectValueEqual } from '@/util/util';
export default { export default {
name: 'tags', name: 'tags',
data () { data () {
...@@ -89,9 +88,6 @@ export default { ...@@ -89,9 +88,6 @@ export default {
query: tag.query query: tag.query
}) })
}, },
isObjectValueEqual (a, b) {
return isObjectValueEqual(a, b)
},
closeOthersTags () { closeOthersTags () {
this.$store.commit('DEL_TAG_OTHER') this.$store.commit('DEL_TAG_OTHER')
}, },
...@@ -118,4 +114,3 @@ export default { ...@@ -118,4 +114,3 @@ export default {
} }
</script> </script>
...@@ -2,15 +2,19 @@ ...@@ -2,15 +2,19 @@
<div class="login-container pull-height" <div class="login-container pull-height"
@keyup.enter.native="handleLogin"> @keyup.enter.native="handleLogin">
<div class="login-logo animated fadeIn"> <div class="login-logo animated fadeIn">
<el-dropdown @command="handleCommand"> <el-select v-model="active"
<span class="el-dropdown-link"> placeholder="请选择租户,不选为默认"
默认租户<i class="el-icon-arrow-down el-icon--right"></i> size="mini">
</span> <el-option label="默认租户"
<el-dropdown-menu slot="dropdown"> value="">
<el-dropdown-item command="1">租户1</el-dropdown-item> </el-option>
<el-dropdown-item command="2">租户2</el-dropdown-item> <el-option label="租户1"
</el-dropdown-menu> value="1">
</el-dropdown> </el-option>
<el-option label="租户2"
value="2">
</el-option>
</el-select>
</div> </div>
<div class="login-weaper"> <div class="login-weaper">
<div class="login-left animated fadeInLeft"> <div class="login-left animated fadeInLeft">
...@@ -30,7 +34,8 @@ ...@@ -30,7 +34,8 @@
</div> </div>
<div class="login-border animated fadeInRight"> <div class="login-border animated fadeInRight">
<div class="login-main"> <div class="login-main">
<h4 class="login-title">登录 {{website.title}}</h4> <h4 class="login-title">登录 {{website.title}}
</h4>
<userLogin v-if="activeName==='user'"></userLogin> <userLogin v-if="activeName==='user'"></userLogin>
<codeLogin v-else-if="activeName==='code'"></codeLogin> <codeLogin v-else-if="activeName==='code'"></codeLogin>
<thirdLogin v-else-if="activeName==='third'"></thirdLogin> <thirdLogin v-else-if="activeName==='third'"></thirdLogin>
...@@ -53,6 +58,7 @@ import codeLogin from "./codelogin"; ...@@ -53,6 +58,7 @@ import codeLogin from "./codelogin";
import thirdLogin from "./thirdlogin"; import thirdLogin from "./thirdlogin";
import topColor from "../index/top/top-color"; import topColor from "../index/top/top-color";
import color from "@/mixins/color"; import color from "@/mixins/color";
import { setStore } from '@/util/store'
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import { validatenull } from '@/util/validate' import { validatenull } from '@/util/validate'
export default { export default {
...@@ -66,6 +72,7 @@ export default { ...@@ -66,6 +72,7 @@ export default {
}, },
data () { data () {
return { return {
active: '',
activeName: "user" activeName: "user"
}; };
}, },
...@@ -95,9 +102,9 @@ export default { ...@@ -95,9 +102,9 @@ export default {
}, },
props: [], props: [],
methods: { methods: {
handleCommand(command) { handleCommand (command) {
sessionStorage.setItem('tenantId',command) setStore({ name: 'tenantId', content: command, type: 'session' })
} }
} }
}; };
</script> </script>
...@@ -114,7 +121,7 @@ export default { ...@@ -114,7 +121,7 @@ export default {
left: 0; left: 0;
width: 100%; width: 100%;
height: 500px; height: 500px;
margin-top: -200px; margin-top: -220px;
} }
.login-container::before { .login-container::before {
z-index: -1024; z-index: -1024;
...@@ -134,8 +141,8 @@ export default { ...@@ -134,8 +141,8 @@ export default {
} }
.login-logo { .login-logo {
position: absolute; position: absolute;
top: 0; top: 10px;
right: 0; right: 30px;
font-size: 24px; font-size: 24px;
color: #333; color: #333;
} }
...@@ -161,6 +168,9 @@ export default { ...@@ -161,6 +168,9 @@ export default {
width: 50%; width: 50%;
box-sizing: border-box; box-sizing: border-box;
} }
.login-select {
display: inline-block;
}
.login-main > h3 { .login-main > h3 {
margin-bottom: 20px; margin-bottom: 20px;
} }
......
import router from './router/router' import router from './router/router'
import store from './store' import store from './store'
import { getToken } from '@/util/auth'
import NProgress from 'nprogress' // progress bar import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style import 'nprogress/nprogress.css' // progress bar style
import { asyncRouterMap } from '@/router/router'
NProgress.configure({ showSpinner: false }); NProgress.configure({ showSpinner: false });
const lockPage = store.getters.website.lockPage; //锁屏页 const lockPage = store.getters.website.lockPage; //锁屏页
const whiteList = store.getters.website.whiteList; //不鉴权白名单
const whiteTagList = store.getters.website.whiteTagList; //不加tags白名单
router.addRoutes(asyncRouterMap);
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start()
if (store.getters.access_token) { const meta = to.meta || {};
if (getToken()) {
if (store.getters.isLock && to.path != lockPage) { if (store.getters.isLock && to.path != lockPage) {
next({ path: lockPage }) next({ path: lockPage })
} else if (to.path === '/login') { } else if (to.path === '/login') {
...@@ -27,8 +23,8 @@ router.beforeEach((to, from, next) => { ...@@ -27,8 +23,8 @@ router.beforeEach((to, from, next) => {
}) })
}) })
} else { } else {
if (!router.$avueRouter.vaildPath(whiteTagList, to.path)) { if (meta.isTab !== false) {
const value = to.query.src ? to.query.src : to.path; const value = to.query.src ? to.query.src : to.fullPath;
const label = to.query.name ? to.query.name : to.name; const label = to.query.name ? to.query.name : to.name;
store.commit('ADD_TAG', { store.commit('ADD_TAG', {
label: label, label: label,
...@@ -41,7 +37,7 @@ router.beforeEach((to, from, next) => { ...@@ -41,7 +37,7 @@ router.beforeEach((to, from, next) => {
} }
} }
} else { } else {
if (router.$avueRouter.vaildPath(whiteList, to.path)) { if (meta.isAuth === false) {
next() next()
} else { } else {
next('/login') next('/login')
...@@ -53,5 +49,4 @@ router.afterEach(() => { ...@@ -53,5 +49,4 @@ router.afterEach(() => {
NProgress.done(); NProgress.done();
const title = store.getters.tag.label; const title = store.getters.tag.label;
router.$avueRouter.setTitle(title); router.$avueRouter.setTitle(title);
}); });
//正则验证路由 \ No newline at end of file
\ No newline at end of file
...@@ -16,9 +16,10 @@ RouterPlugin.install = function(router, store) { ...@@ -16,9 +16,10 @@ RouterPlugin.install = function(router, store) {
this.$router.$avueRouter = { this.$router.$avueRouter = {
//全局配置 //全局配置
$website: this.$store.getters.website, $website: this.$store.getters.website,
safe: this,
// 设置标题 // 设置标题
setTitle: function(title) { setTitle: function(title) {
title = title ? `${title}——Avue 通用管理 系统快速开发框架` : 'Avue 通用管理 系统快速开发框架'; title = title ? `${title}——PigX Pro 快速开发框架` : 'PigX Pro 快速开发框架';
document.title = title; document.title = title;
}, },
closeTag: (value) => { closeTag: (value) => {
...@@ -57,7 +58,6 @@ RouterPlugin.install = function(router, store) { ...@@ -57,7 +58,6 @@ RouterPlugin.install = function(router, store) {
}, },
//动态路由 //动态路由
formatRoutes: function(aMenu, first) { formatRoutes: function(aMenu, first) {
if (!aMenu) return;
const aRouter = [] const aRouter = []
const propsConfig = this.$website.menu.props; const propsConfig = this.$website.menu.props;
const propsDefault = { const propsDefault = {
...@@ -66,6 +66,7 @@ RouterPlugin.install = function(router, store) { ...@@ -66,6 +66,7 @@ RouterPlugin.install = function(router, store) {
icon: propsConfig.icon || 'icon', icon: propsConfig.icon || 'icon',
children: propsConfig.children || 'children' children: propsConfig.children || 'children'
} }
if (!aMenu) return;
aMenu.forEach(oMenu => { aMenu.forEach(oMenu => {
const path = oMenu[propsDefault.path], const path = oMenu[propsDefault.path],
component = oMenu.component, component = oMenu.component,
...@@ -113,9 +114,13 @@ RouterPlugin.install = function(router, store) { ...@@ -113,9 +114,13 @@ RouterPlugin.install = function(router, store) {
})() })()
} }
aRouter.push(oRouter) aRouter.push(oRouter)
}) })
return aRouter if (first) {
this.safe.$router.addRoutes(aRouter)
} else {
return aRouter
}
} }
} }
} }
......
...@@ -5,63 +5,60 @@ ...@@ -5,63 +5,60 @@
*/ */
// 引入axios以及element ui中的loading和message组件 // 引入axios以及element ui中的loading和message组件
import axios from 'axios' import axios from 'axios'
import router from '../router/router' import { serialize } from '@/util/util'
import store from '../store' import store from '../store'
import { import { getStore } from '../util/store'
getToken import { getToken } from '@/util/auth'
} from '@/util/auth'
import NProgress from 'nprogress' // progress bar import NProgress from 'nprogress' // progress bar
import errorCode from '@/const/errorCode' import errorCode from '@/const/errorCode'
import { import { Message } from 'element-ui'
Message
} from 'element-ui'
import 'nprogress/nprogress.css' // progress bar style import 'nprogress/nprogress.css' // progress bar style
axios.defaults.timeout = 30000; axios.defaults.timeout = 30000;
//返回其他状态吗 //返回其他状态吗
// axios.defaults.validateStatus = function(status) { axios.defaults.validateStatus = function(status) {
// return status >= 200 && status < 500; // 默认的 return status >= 200 && status <= 500; // 默认的
// }; };
//跨域请求,允许保存cookie //跨域请求,允许保存cookie
axios.defaults.withCredentials = true; axios.defaults.withCredentials = true;
// NProgress Configuration
NProgress.configure({ NProgress.configure({
showSpinner: false showSpinner: false
}) // NProgress Configuration });
//HTTPrequest拦截 //HTTPrequest拦截
axios.interceptors.request.use(config => { axios.interceptors.request.use(config => {
NProgress.start() // start progress bar NProgress.start() // start progress bar
if (store.getters.access_token) { if (store.getters.access_token) {
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改 config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
} }
const TENANT_ID = getStore({ name: 'tenantId' });
if (sessionStorage.getItem('tenantId')) { if (TENANT_ID) {
config.headers['TENANT_ID'] = sessionStorage.getItem('tenantId') // 租户ID config.headers['TENANT_ID'] = TENANT_ID // 租户ID
} }
return config //headers中配置serialize为true开启序列化
if (config.methods === 'post' && config.headers.serialize) {
config.data = serialize(config.data);
delete config.data.serialize;
}
return config
}, error => { }, error => {
console.log('err' + error) // for debug return Promise.reject(error)
return Promise.reject(error) });
})
//HTTPresponse拦截 //HTTPresponse拦截
axios.interceptors.response.use(res => { axios.interceptors.response.use(res => {
NProgress.done(); NProgress.done();
return res const status = Number(res.status);
const message = res.data.message || errorCode[status] || errorCode['default'];
if (status !== 200) {
Message({
message: message,
type: 'error'
})
return Promise.reject(new Error(message))
}
return res;
}, error => { }, error => {
NProgress.done() NProgress.done()
let errMsg = error.toString() return Promise.reject(new Error(error))
let code = errMsg.substr(errMsg.indexOf('code') + 5)
Message({
message: errorCode[code] || errorCode['default'],
type: 'error'
})
if (parseInt(code) === 401 || parseInt(code) === 403) {
store.dispatch('FedLogOut').then(() => {
router.push({
path: '/login'
});
})
}
return Promise.reject(new Error(error))
}) })
export default axios export default axios
\ No newline at end of file
import Layout from '@/page/index/' import Layout from '@/page/index/'
export default [{ export default [{
path: '*',
redirect: '/404',
hidden: true
}, {
path: '/login', path: '/login',
name: '登录页', name: '登录页',
component: () => component: () =>
import ( /* webpackChunkName: "page" */ '@/page/login/index'), import ( /* webpackChunkName: "page" */ '@/page/login/index'),
meta: { meta: {
keepAlive: true, keepAlive: true,
isTab: false,
isAuth: false
} }
}, },
{
path: '/authredirect',
name: '授权页',
component: () =>
import ( /* webpackChunkName: "page" */ '@/page/login/authredirect')
},
{ {
path: '/lock', path: '/lock',
name: '锁屏页', name: '锁屏页',
component: () => component: () =>
import ( /* webpackChunkName: "page" */ '@/page/lock/index'), import ( /* webpackChunkName: "page" */ '@/page/lock/index'),
meta: {
keepAlive: true,
isTab: false,
isAuth: false
}
}, },
{ {
path: '/404', path: '/404',
component: () => component: () =>
import ( /* webpackChunkName: "page" */ '@/components/error-page/404'), import ( /* webpackChunkName: "page" */ '@/components/error-page/404'),
name: '404' name: '404',
meta: {
keepAlive: true,
isTab: false,
isAuth: false
}
}, },
{ {
path: '/403', path: '/403',
component: () => component: () =>
import ( /* webpackChunkName: "page" */ '@/components/error-page/403'), import ( /* webpackChunkName: "page" */ '@/components/error-page/403'),
name: '403' name: '403',
meta: {
keepAlive: true,
isTab: false,
isAuth: false
}
}, },
{ {
path: '/500', path: '/500',
component: () => component: () =>
import ( /* webpackChunkName: "page" */ '@/components/error-page/500'), import ( /* webpackChunkName: "page" */ '@/components/error-page/500'),
name: '500' name: '500',
meta: {
keepAlive: true,
isTab: false,
isAuth: false
}
}, },
{ {
path: '/', path: '/',
name: '主页', name: '主页',
redirect: '/wel' redirect: '/wel'
}, },
{
path: '/wel',
component: Layout,
redirect: '/wel/index',
children: [{
path: 'index',
name: '首页',
component: () =>
import ( /* webpackChunkName: "page" */ '@/page/wel'),
}]
},
{ {
path: '/myiframe', path: '/myiframe',
component: Layout, component: Layout,
......
...@@ -20,6 +20,6 @@ let Router = new VueRouter({ ...@@ -20,6 +20,6 @@ let Router = new VueRouter({
routes: [].concat([]) routes: [].concat([])
}); });
AvueRouter.install(Router, Store); AvueRouter.install(Router, Store);
Router.addRoutes(Router.$avueRouter.formatRoutes(Store.state.user.menu, true)); Router.$avueRouter.formatRoutes(Store.state.user.menu, true);
export default Router; Router.addRoutes([...PageRouter, ...ViewsRouter]);
export const asyncRouterMap = [].concat(PageRouter, ViewsRouter) export default Router;
\ No newline at end of file \ No newline at end of file
import Layout from '@/page/index/' import Layout from '@/page/index/'
export default [{ export default [{
path: '/info', path: '/wel',
component: Layout, component: Layout,
redirect: '/info/index', redirect: '/wel/index',
children: [{ children: [{
path: 'index', path: 'index',
name: '首页', name: '首页',
component: () => component: () =>
import ( /* webpackChunkName: "views" */ '@/views/admin/user/info') import ( /* webpackChunkName: "views" */ '@/page/wel')
}] }]
}, { }, {
path: '/crud', path: '/crud',
......
import { setStore, getStore } from '@/util/store' import { setStore, getStore } from '@/util/store'
import { isObjectValueEqual } from '@/util/util' import { diff } from '@/util/util'
const tagObj = { const tagObj = {
label: '', //标题名称 label: '', //标题名称
value: '', //标题的路径 value: '', //标题的路径
...@@ -38,22 +38,14 @@ const navs = { ...@@ -38,22 +38,14 @@ const navs = {
ADD_TAG: (state, action) => { ADD_TAG: (state, action) => {
state.tag = action; state.tag = action;
setStore({ name: 'tag', content: state.tag, type: 'session' }) setStore({ name: 'tag', content: state.tag, type: 'session' })
if (state.tagList.some(ele => isObjectValueEqual(ele, action))) return if (state.tagList.some(ele => diff(ele, action))) return
state.tagList.push(action) state.tagList.push(action)
setFistTag(state.tagList); setFistTag(state.tagList);
setStore({ name: 'tagList', content: state.tagList, type: 'session' }) setStore({ name: 'tagList', content: state.tagList, type: 'session' })
}, },
DEL_TAG: (state, action) => { DEL_TAG: (state, action) => {
state.tagList = state.tagList.filter(item => { state.tagList = state.tagList.filter(item => {
if (typeof(action) === 'object') { return !diff(item, action);
let a = Object.assign({}, item);
let b = Object.assign({}, action);
delete a.close;
delete b.__ob__;
return !isObjectValueEqual(a, b)
} else {
return item.value !== action
}
}) })
setFistTag(state.tagList); setFistTag(state.tagList);
setStore({ name: 'tagList', content: state.tagList, type: 'session' }) setStore({ name: 'tagList', content: state.tagList, type: 'session' })
......
import { import { validatenull } from './validate'
validatenull //表单序列化
} from './validate' export const serialize = data => {
let list = [];
Object.keys(data).forEach(ele => {
list.push(`${ele}=${data[ele]}`)
})
return list.join('&');
};
/** /**
* 设置灰度模式 * 判断路由是否相等
*/ */
export const diff = (obj1, obj2) => {
delete obj1.close;
var o1 = obj1 instanceof Object;
var o2 = obj2 instanceof Object;
if (!o1 || !o2) { /* 判断不是对象 */
return obj1 === obj2;
}
if (Object.keys(obj1).length !== Object.keys(obj2).length) {
return false;
//Object.keys() 返回一个由对象的自身可枚举属性(key值)组成的数组,例如:数组返回下表:let arr = ["a", "b", "c"];console.log(Object.keys(arr))->0,1,2;
}
for (var attr in obj1) {
var t1 = obj1[attr] instanceof Object;
var t2 = obj2[attr] instanceof Object;
if (t1 && t2) {
return diff(obj1[attr], obj2[attr]);
} else if (obj1[attr] !== obj2[attr]) {
return false;
}
}
return true;
}
/**
* 设置灰度模式
*/
export const toggleGrayMode = (status) => { export const toggleGrayMode = (status) => {
if (status) { if (status) {
document.body.className = document.body.className + ' grayMode'; document.body.className = document.body.className + ' grayMode';
......
...@@ -22,9 +22,8 @@ ...@@ -22,9 +22,8 @@
ref="crud" ref="crud"
v-model="form" v-model="form"
:page="page" :page="page"
@on-load="getList"
:table-loading="listLoading" :table-loading="listLoading"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
@search-change="handleFilter" @search-change="handleFilter"
@refresh-change="handleRefreshChange" @refresh-change="handleRefreshChange"
@row-update="update" @row-update="update"
...@@ -118,14 +117,11 @@ export default { ...@@ -118,14 +117,11 @@ export default {
page: { page: {
total: 0, // 总页数 total: 0, // 总页数
currentPage: 1, // 当前页数 currentPage: 1, // 当前页数
pageSize: 20 // 每页显示多少条 pageSize: 20, // 每页显示多少条,
isAsc: false//是否倒序
}, },
list: [], list: [],
listLoading: true, listLoading: true,
listQuery: {
page: 1,
limit: 20
},
role: [], role: [],
form: {}, form: {},
rolesOptions: [], rolesOptions: [],
...@@ -150,16 +146,17 @@ export default { ...@@ -150,16 +146,17 @@ export default {
} }
}, },
created () { created () {
this.getList();
this.sys_user_add = this.permissions["sys_user_add"]; this.sys_user_add = this.permissions["sys_user_add"];
this.sys_user_edit = this.permissions["sys_user_edit"]; this.sys_user_edit = this.permissions["sys_user_edit"];
this.sys_user_del = this.permissions["sys_user_del"]; this.sys_user_del = this.permissions["sys_user_del"];
}, },
methods: { methods: {
getList () { getList (page, params) {
this.listLoading = true; this.listLoading = true;
this.listQuery.isAsc = false; fetchList(Object.assign({
fetchList(this.listQuery).then(response => { page: page.currentPage,
limit: page.pageSize
}, params)).then(response => {
this.list = response.data.records; this.list = response.data.records;
this.page.total = response.data.total this.page.total = response.data.total
this.listLoading = false; this.listLoading = false;
...@@ -176,20 +173,11 @@ export default { ...@@ -176,20 +173,11 @@ export default {
}); });
}, },
handleFilter (param) { handleFilter (param) {
this.listQuery = Object.assign(this.listQuery, param) this.page.page = 1;
this.listQuery.page = 1; this.getList(this.page, param);
this.getList();
},
handleSizeChange (val) {
this.listQuery.limit = val;
this.getList();
}, },
handleRefreshChange () { handleRefreshChange () {
this.getList() this.getList(this.page)
},
handleCurrentChange (val) {
this.listQuery.page = val;
this.getList();
}, },
handleCreate () { handleCreate () {
this.$refs.crud.rowAdd(); this.$refs.crud.rowAdd();
......
...@@ -66,4 +66,4 @@ module.exports = { ...@@ -66,4 +66,4 @@ module.exports = {
}, },
} }
} }
} }
\ No newline at end of file
This diff is collapsed.
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