After reading an article by Nuggets, I made a vue background management system modeled on someone else’s demo.
Nuggets original article address
The technology stacks involved in this project are vue vue-cli vue-Router axios Echarts element-ui fastmock webpack
The github address of this project is vue-admin-webapp
vue-admin-webapp is a background management system, based on vuecli and element-ui , using fastmock to simulate data, including charts, tables, permissions, excel, etc. You can add routing according to your needs.
## 克隆项目
git clone git@github.com:yqxshiki/vue-admin-webapp.git
## 进入项目目录
cd vue-admin-webapp
## 安装依赖
npm install
## 启动服务
npm run serve
After startup, the browser http://localhost:8080 will be opened automatically , and you can see the effect of the project.
Go out to the login page, the page is mainly composed of three parts: the head sidebar display page , you can click the sidebar to route and jump
Receive the token from fastmock, store it in localStorage when logging in , set a global front guard, and enter other pages only when there is a token, otherwise it will jump to the login page
router.beforeEach((to, from, next) => {
const isLogin = localStorage.loginToken ? true : false;
if (to.path == "/login") {
next();
} else {
isLogin ? next() : next('/login')
}
})
axios.interceptors.request.use(config => {
// 判断是否有token
if (localStorage.loginToken) {
config.headers.Authorization = localStorage.loginToken;
}
return config;
}, err => {
// 请求错误
return Promise.reject(err);
})
axios . interceptors . response . use ( res => {
return res ;
} ,
err => {
const { status } = err . response ;
if ( status == 401 ) {
// background defines 401 as expired
alert ( "token expired Please log in again "! )
// clear token
localStorage . removeItem ( " loginToken " ) ;
Router . the Push("/login");
} else {
alert(err.response.data)
}
return Promise.reject(err);
});
Familiar with Echart, line graph, pie chart, histogram, dynamic data graph, etc., such as the following figure
In actual projects, excel is mainly done on the back-end. Of course, the front-end can also be done, but I don’t think it is necessary now. You can search for it if you want to know.
The official introduction is quoted here
fastmock allows you to simulate ajax requests online without a back-end program. You can use fatmock to demonstrate the effect of the pure front-end project at the beginning of the project, or use fastmock to implement data simulation during development to achieve separation of front-end and back-end. Before using fastmock, your team may implement data simulation in one or more of the following scenarios
Author: yqxshiki
Demo: https://yqxshiki.gitee.io/yqx-vue-admin-webapp/
Source Code: https://github.com/yqxshiki/vue-admin-webapp
#vue #vuejs #javascript