Browse Source

修改

master
wen 2 years ago
parent
commit
f9944eb2f5
  1. 8
      src/api/user.js
  2. BIN
      src/common/img/jialuoma.png
  3. BIN
      src/common/img/jialuoma2.png
  4. 3
      src/layout/components/AppMain.vue
  5. 4
      src/layout/components/Sidebar/SidebarItem.vue
  6. 1
      src/layout/components/Sidebar/index.vue
  7. 27
      src/layout/index.vue
  8. 4
      src/main.js
  9. 122
      src/permission.js
  10. 151
      src/router/index.js
  11. 49
      src/styles/publics.scss
  12. 2
      src/styles/sidebar.scss
  13. 2
      src/styles/variables.scss
  14. 1
      src/utils/request.js
  15. 22
      src/views/login/index.vue

8
src/api/user.js

@ -15,3 +15,11 @@ export function login(datas) {
data: datas data: datas
}) })
} }
export function mirlist(datas) {
return request({
url: '/api/ls',
method: 'post',
data: datas
})
}

BIN
src/common/img/jialuoma.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
src/common/img/jialuoma2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

3
src/layout/components/AppMain.vue

@ -20,7 +20,8 @@ export default {
<style scoped> <style scoped>
.app-main { .app-main {
/*50 = navbar */ /*50 = navbar */
min-height: calc(100vh - 50px); /* min-height: calc(100vh - 50px); */
min-height:100%;
width: 100%; width: 100%;
position: relative; position: relative;
overflow: hidden; overflow: hidden;

4
src/layout/components/Sidebar/SidebarItem.vue

@ -30,7 +30,6 @@ import { isExternal } from '@/utils/validate'
import Item from './Item' import Item from './Item'
import AppLink from './Link' import AppLink from './Link'
import FixiOSBug from './FixiOSBug' import FixiOSBug from './FixiOSBug'
export default { export default {
name: 'SidebarItem', name: 'SidebarItem',
components: { Item, AppLink }, components: { Item, AppLink },
@ -50,6 +49,9 @@ export default {
default: '' default: ''
} }
}, },
// mounted: function () {
// console.log(222);
// },
data() { data() {
// To fix https://github.com/PanJiaChen/vue-admin-template/issues/237 // To fix https://github.com/PanJiaChen/vue-admin-template/issues/237
// TODO: refactor with render function // TODO: refactor with render function

1
src/layout/components/Sidebar/index.vue

@ -23,7 +23,6 @@ import { mapGetters } from 'vuex'
import Logo from './Logo' import Logo from './Logo'
import SidebarItem from './SidebarItem' import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss' import variables from '@/styles/variables.scss'
export default { export default {
components: { SidebarItem, Logo }, components: { SidebarItem, Logo },
computed: { computed: {

27
src/layout/index.vue

@ -2,27 +2,28 @@
<div :class="classObj" class="app-wrapper"> <div :class="classObj" class="app-wrapper">
<div class="toptitle clearfix"> <div class="toptitle clearfix">
<a class="leftk" href="javascript:;"> <a class="leftk" href="javascript:;">
<img src="" alt="图片"> <img src="../common/img/jialuoma.png" alt="图片">
<em class="erectline"></em>
<span>后台管理系统</span>
</a> </a>
<div class="rightk tpriht"> <div class="rightk tpriht">
<a id="dLabel" href="javascript:;" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> <a id="dLabel" href="javascript:;" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<img class="mailtp verMiddle" src="" alt="图片"> <img class="mailtp verMiddle" src="../common/img/jialuoma.png" alt="图片">
<span class="verMiddle glyphicon glyphicon-menu-down"></span> <span class="verMiddle glyphicon glyphicon-menu-down"></span>
</a> </a>
<em class="erectline"></em> <em class="erectline"></em>
<!-- <a class="Cache tuichu" href="/admin.php/Cache/index.html">清除缓存</a> --> <!-- <a class="Cache tuichu" href="/admin.php/Cache/index.html">清除缓存</a> -->
<el-button class="quit" @click="dengchu" id="tuichu" size="mini" round>退出</el-button> <!-- <el-button class="quit" @click="dengchu" id="tuichu" size="mini" round>退出</el-button> -->
</div> </div>
</div> </div>
<div class="content_main"> <div class="content_main">
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" /> <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
<sidebar class="sidebar-container" /> <sidebar class="sidebar-container" />
<div class="main-container"> <div class="main-container">
<div :class="{'fixed-header':fixedHeader}"> <div :class="{'fixed-header':fixedHeader}">
<navbar /> <navbar />
</div> </div>
<app-main /> <app-main />
</div> </div>
</div> </div>
</div> </div>
@ -59,6 +60,7 @@ export default {
} }
} }
}, },
methods: { methods: {
handleClickOutside() { handleClickOutside() {
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false }) this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
@ -70,6 +72,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
@import "~@/styles/mixin.scss"; @import "~@/styles/mixin.scss";
@import "~@/styles/variables.scss"; @import "~@/styles/variables.scss";
@import "~@/styles/publics.scss";
.app-wrapper { .app-wrapper {
@include clearfix; @include clearfix;
@ -108,11 +111,5 @@ export default {
width: 100%; width: 100%;
} }
.content_main{margin-top:91px;} .content_main{padding-top:91px;}
.toptitle{color:#FFF;height:91px;padding:0 6% 0 34px;z-index:1002;background-color:#2b3245;position:fixed;top:0;left:0;right:0;}
.toptitle .leftk{float:left;margin-top:18px;}
.toptitle .leftk>img{vertical-align:middle;}
.toptitle .leftk>i{vertical-align:middle;color:#FFF;font-size:30px;margin:6px 0 0 15px;}
.toptitle .rightk{float:right;margin-top:24px;position:relative;}
.toptitle .erectline{margin:0 18px;display:inline-block;vertical-align:middle;height:40px;width:1px;background-color:#414758;}
</style> </style>

4
src/main.js

@ -1,6 +1,6 @@
import Vue from 'vue' import Vue from 'vue'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets //import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI from 'element-ui' import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css' import 'element-ui/lib/theme-chalk/index.css'
@ -13,7 +13,7 @@ import store from './store'
import router from './router' import router from './router'
import '@/icons' // icon import '@/icons' // icon
//import '@/permission' // permission control如果 import '@/permission' // 权限处理
/** /**
* If you don't want to use mock-server * If you don't want to use mock-server

122
src/permission.js

@ -10,55 +10,103 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration
const whiteList = ['/login'] // no redirect whitelist const whiteList = ['/login'] // no redirect whitelist
// 动态添加路由
import { mirlist } from '@/api/user'
mirlist().then(response => {
let datamain = response.data;
routesData(datamain.data.menus);
//console.log(response);
}).catch(function (error) {
Message({
showClose: true,
message: error,
type: 'error'
});
});
function routesData(data) {
// 重新加载一次 VueRouter
//router.reloadRouter()
let currentMenu = [
{
path: '/',
component: () => import('@/views/systme/changepass'),
children: []
}
]
console.log(router);
data.forEach(item => {
console.log(item);
const temp = {
name: item.directory,
path: item.directory,
component: () => import(`../page/${item.path}/${firstUppercase(i.path)}.vue`)
}
// 动态添加为 filemange 的子路由
router.addRoutes(currentMenu)
// item.children.forEach(i => {
// // 组装路由配置
// const temp = {
// name: i.path,
// path: i.path,
// component: () => import(`../page/${item.path}/${firstUppercase(i.path)}.vue`)
// }
// // 动态添加为 filemange 的子路由
// router.addRoute("filemange", temp)
// })
})
}
router.beforeEach(async(to, from, next) => { router.beforeEach(async(to, from, next) => {
// start progress bar // start progress bar
NProgress.start() NProgress.start()
// set page title // set page title
document.title = getPageTitle(to.meta.title) document.title = getPageTitle(to.meta.title)
next()
// determine whether the user has logged in // determine whether the user has logged in
const hasToken = getToken() // const hasToken = getToken()
if (hasToken) { // if (hasToken) {
if (to.path === '/login') { // if (to.path === '/login') {
// if is logged in, redirect to the home page // // if is logged in, redirect to the home page
next({ path: '/' }) // next({ path: '/' })
NProgress.done() // NProgress.done()
} else { // } else {
const hasGetUserInfo = store.getters.name // const hasGetUserInfo = store.getters.name
if (hasGetUserInfo) { // if (hasGetUserInfo) {
next() // next()
} else { // } else {
try { // try {
// get user info // // get user info
await store.dispatch('user/getInfo') // await store.dispatch('user/getInfo')
next() // next()
} catch (error) { // } catch (error) {
// remove token and go to login page to re-login // // remove token and go to login page to re-login
await store.dispatch('user/resetToken') // await store.dispatch('user/resetToken')
Message.error(error || 'Has Error') // Message.error(error || 'Has Error')
next(`/login?redirect=${to.path}`) // next(`/login?redirect=${to.path}`)
NProgress.done() // NProgress.done()
} // }
} // }
} // }
} else { // } else {
/* has no token*/ // /* has no token*/
if (whiteList.indexOf(to.path) !== -1) { // if (whiteList.indexOf(to.path) !== -1) {
// in the free login whitelist, go directly // // in the free login whitelist, go directly
next() // next()
} else { // } else {
// other pages that do not have permission to access are redirected to the login page. // // other pages that do not have permission to access are redirected to the login page.
next(`/login?redirect=${to.path}`) // next(`/login?redirect=${to.path}`)
NProgress.done() // NProgress.done()
} // }
} // }
}) })
router.afterEach(() => { router.afterEach(() => {
// finish progress bar // finish progress bar
NProgress.done() NProgress.done() // 释放钩子
}) })

151
src/router/index.js

@ -46,12 +46,19 @@ export const constantRoutes = [
path: '/', path: '/',
component: Layout, component: Layout,
redirect: '/filemange', // 重定向地址 redirect: '/filemange', // 重定向地址
children: [{ name: 'filemange',
path: 'filemange', alwaysShow: false,
name: 'Filemange', meta: { title: '文件管理', icon: 'el-icon-s-help' },
component: () => import('@/views/filemange/index'), children: [
meta: { title: '文件管理', icon: 'dashboard' } {
}] path: 'filemange',
name: 'Filemange',
component: () => import('@/views/filemange/index'),
meta: { title: '文件管理', icon: 'dashboard' }
}
]
}, },
{ {
path: '', path: '',
@ -64,31 +71,6 @@ export const constantRoutes = [
meta: { title: '用户管理', icon: 'dashboard' } meta: { title: '用户管理', icon: 'dashboard' }
}] }]
}, },
// {
// path: '/',
// component: Layout,
// redirect: '/filemange', // 重定向地址
// children: [{
// path: 'filemange',
// name: 'filemange',
// component: () => import('@/views/dashboard/index?a=1'),
// meta: { title: '文件管理', icon: 'dashboard' }
// }]
// },
// {
// path: '/',
// component: Layout,
// redirect: '/usermange',
// children: [{
// path: 'usermange',
// name: 'usermange',
// component: () => import('@/views/dashboard/index?a=2'),
// meta: { title: '用户管理', icon: 'dashboard' }
// }]
// },
{ {
path: '/systme', path: '/systme',
component: Layout, component: Layout,
@ -107,96 +89,32 @@ export const constantRoutes = [
name: 'userrelated', name: 'userrelated',
component: () => import('@/views/systme/userrelated'), component: () => import('@/views/systme/userrelated'),
meta: { title: '用户相关', icon: 'tree' } meta: { title: '用户相关', icon: 'tree' }
},
{
path: 'userrelated2',
name: 'userrelated2',
component: () => import('@/views/systme/userrelated'),
meta: { title: '皮肤更换', icon: 'tree' }
}
]
},
{
path: 'external-link',
component: Layout,
children: [
{
path: 'https://dev.filesite.io/',
meta: { title: '前端展示页面', icon: 'link' }
} }
] ]
}, },
// {
// path: '/form',
// component: Layout,
// children: [
// {
// path: 'index',
// name: 'Form',
// component: () => import('@/views/form/index'),
// meta: { title: 'Form', icon: 'form' }
// }
// ]
// },
// {
// path: '/nested',
// component: Layout,
// redirect: '/nested/menu1',
// name: 'Nested',
// meta: {
// title: 'Nested',
// icon: 'nested'
// },
// children: [
// {
// path: 'menu1',
// component: () => import('@/views/nested/menu1/index'), // Parent router-view
// name: 'Menu1',
// meta: { title: 'Menu1' },
// children: [
// {
// path: 'menu1-1',
// component: () => import('@/views/nested/menu1/menu1-1'),
// name: 'Menu1-1',
// meta: { title: 'Menu1-1' }
// },
// {
// path: 'menu1-2',
// component: () => import('@/views/nested/menu1/menu1-2'),
// name: 'Menu1-2',
// meta: { title: 'Menu1-2' },
// children: [
// {
// path: 'menu1-2-1',
// component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
// name: 'Menu1-2-1',
// meta: { title: 'Menu1-2-1' }
// },
// {
// path: 'menu1-2-2',
// component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
// name: 'Menu1-2-2',
// meta: { title: 'Menu1-2-2' }
// },
// {
// path: 'menu1-2-3',
// component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
// name: 'jiamaluo',
// meta: { title: 'jialmal' }
// }
// ]
// },
// {
// path: 'menu1-3',
// component: () => import('@/views/nested/menu1/menu1-3'),
// name: 'Menu1-3',
// meta: { title: 'Menu1-3' }
// }
// ]
// },
// {
// path: 'menu2',
// component: () => import('@/views/nested/menu2/index'),
// name: 'Menu2',
// meta: { title: 'menu2' }
// }
// ]
// },
// 404 page must be placed at the end !!! // 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true } { path: '*', redirect: '/404', hidden: true }
] ]
const createRouter = () => new Router({ const createRouter = () => new Router({
// mode: 'history', // require service support //mode: 'history', // require service support
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes routes: constantRoutes
}) })
@ -206,7 +124,12 @@ const router = createRouter()
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() { export function resetRouter() {
const newRouter = createRouter() const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router router.matcher = newRouter.matcher // reset router 重置路由器
} }
// router.reloadRouter = function () {
// router.matcher = new Router({
// mode: "history",
// constantRoutes
// }).matcher
// }
export default router export default router

49
src/styles/publics.scss

@ -0,0 +1,49 @@
.toptitle {
color: #FFF;
height: 91px;
padding: 0 6% 0 36px;
z-index: 1002;
background-color: #2b3245;
position: fixed;
top: 0;
left: 0;
right: 0;
overflow:hidden;
}
.toptitle .leftk {
float: left;
margin-top: 16px;
height:60px;
}
.toptitle .leftk>img {
vertical-align: middle;
display:inline-block;
max-width: 100%;
height:100%;
background-color:#FFF;
border-radius:50%;
}
.toptitle .leftk>i {
vertical-align: middle;
color: #FFF;
font-size: 30px;
margin: 6px 0 0 15px;
}
.toptitle .rightk {
float: right;
margin-top: 24px;
position: relative;
}
.toptitle .erectline {
margin: 0 18px;
display: inline-block;
vertical-align: middle;
height: 40px;
width: 1px;
background-color: #414758;
}

2
src/styles/sidebar.scss

@ -17,7 +17,7 @@
top: 91px; top: 91px;
bottom: 0; bottom: 0;
left: 0; left: 0;
z-index: 1001; z-index: 2002;
overflow: hidden; overflow: hidden;
// reset element-ui css // reset element-ui css

2
src/styles/variables.scss

@ -3,7 +3,7 @@ $menuText:#bfcbd9;
$menuActiveText:#409EFF; $menuActiveText:#409EFF;
$subMenuActiveText:#f4f4f5; //https://github.com/ElemeFE/element/issues/12951 $subMenuActiveText:#f4f4f5; //https://github.com/ElemeFE/element/issues/12951
$menuBg:#304156; $menuBg:#2b3245;
$menuHover:#263445; $menuHover:#263445;
$subMenuBg:#1f2d3d; $subMenuBg:#1f2d3d;

1
src/utils/request.js

@ -13,6 +13,7 @@ const service = axios.create({
// }, // },
timeout: 0 // request timeout timeout: 0 // request timeout
}) })
//service.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
// request interceptor // request interceptor
// service.interceptors.request.use( // service.interceptors.request.use(

22
src/views/login/index.vue

@ -1,7 +1,11 @@
<template> <template>
<div class="login-container"> <div class="login-container">
<div class="toptitle clearfix"> <div class="toptitle clearfix">
<a class="leftk" href="javascript:;"><img src="" alt="图片"></a> <a class="leftk" href="javascript:;">
<img src="../../common/img/jialuoma.png" alt="图片">
<em class="erectline"></em>
<span>后台管理系统</span>
</a>
</div> </div>
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left"> <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
@ -82,7 +86,7 @@
import { captcha, login } from '@/api/user' import { captcha, login } from '@/api/user'
export default { export default {
mounted: function () { created: function () {
this.getcaptcha(); this.getcaptcha();
}, },
data() { data() {
@ -165,10 +169,10 @@ export default {
// console.log(valid); // console.log(valid);
if (valid) { if (valid) {
this.loading = true this.loading = true
//let thiss = this; let thiss = this;
login(this.loginForm).then(response => { login(this.loginForm).then(response => {
let datamain = response.data; let datamain = response.data;
//console.log(response); console.log(1111);
if (datamain.code == 0) { if (datamain.code == 0) {
this.loading = false; this.loading = false;
this.$message({ this.$message({
@ -182,7 +186,13 @@ export default {
this.$router.push({path: '/filemange'}) this.$router.push({path: '/filemange'})
//console.log('6666'); //console.log('6666');
}) }).catch(function (error) {
thiss.$message({
showClose: true,
message: error,
type: 'error'
});
});
// axios.post('/api/login', this.loginForm, {headers: {'Content-Type': 'multipart/form-data'} // axios.post('/api/login', this.loginForm, {headers: {'Content-Type': 'multipart/form-data'}
// }).then(function (response) { // }).then(function (response) {
@ -210,6 +220,8 @@ export default {
} }
</script> </script>
<style lang="scss"> <style lang="scss">
@import "~@/styles/publics.scss";
$bg:#283443; $bg:#283443;
$light_gray:#fff; $light_gray:#fff;
$cursor: #3c3535; $cursor: #3c3535;

Loading…
Cancel
Save