├── .browserslistrc ├── .gitattributes ├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── public ├── favicon.ico └── index.html └── src ├── App.vue ├── assets ├── avatar.jpg ├── css │ └── global.css └── logo.png ├── components ├── Home.vue ├── Login.vue ├── Welcome.vue ├── goods │ ├── Add.vue │ ├── Cate.vue │ ├── Edit.vue │ ├── List.vue │ └── Params.vue ├── order │ ├── Order.vue │ └── citydata.js ├── power │ ├── Rights.vue │ └── Roles.vue ├── report │ └── Report.vue └── user │ └── Users.vue ├── main.js ├── plugins ├── axios.js └── element.js └── router └── index.js /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-language=vue -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | pnpm-debug.log* 14 | 15 | # Editor directories and files 16 | .idea 17 | .vscode 18 | *.suo 19 | *.ntvs* 20 | *.njsproj 21 | *.sln 22 | *.sw? 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-shop 2 | 3 | ## Blog 4 | 5 | https://naccl.top/blog/15 6 | 7 | ## Project setup 8 | 9 | ``` 10 | npm install 11 | ``` 12 | 13 | ### Compiles and hot-reloads for development 14 | ``` 15 | npm run serve 16 | ``` 17 | 18 | ### Compiles and minifies for production 19 | ``` 20 | npm run build 21 | ``` 22 | 23 | ### Customize configuration 24 | See [Configuration Reference](https://cli.vuejs.org/config/). 25 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | //项目发布阶段使用的babel插件 2 | const prodPlugins = [] 3 | if (process.env.NODE_ENV === 'production') { 4 | prodPlugins.push('transform-remove-console') 5 | } 6 | 7 | module.exports = { 8 | "presets": [ 9 | "@vue/cli-plugin-babel/preset" 10 | ], 11 | 'plugins': [ 12 | ...prodPlugins 13 | ] 14 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-shop", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build" 8 | }, 9 | "dependencies": { 10 | "core-js": "^3.6.5", 11 | "echarts": "^4.8.0", 12 | "element-ui": "^2.4.5", 13 | "lodash": "^4.17.19", 14 | "moment": "^2.27.0", 15 | "nprogress": "^0.2.0", 16 | "vue": "^2.6.11", 17 | "vue-quill-editor": "^3.0.6", 18 | "vue-router": "^3.2.0" 19 | }, 20 | "devDependencies": { 21 | "@vue/cli-plugin-babel": "~4.4.0", 22 | "@vue/cli-plugin-router": "~4.4.0", 23 | "@vue/cli-plugin-vuex": "~4.4.0", 24 | "@vue/cli-service": "~4.4.0", 25 | "axios": "^0.18.0", 26 | "babel-plugin-transform-remove-console": "^6.9.4", 27 | "less-loader": "^6.2.0", 28 | "vue-cli-plugin-axios": "0.0.4", 29 | "vue-cli-plugin-element": "^1.0.1", 30 | "vue-template-compiler": "^2.6.11" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naccl/vue-shop/eed28f5ad4e75ac6abf306b9569248e41a7f64e1/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 14 | 17 | -------------------------------------------------------------------------------- /src/assets/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naccl/vue-shop/eed28f5ad4e75ac6abf306b9569248e41a7f64e1/src/assets/avatar.jpg -------------------------------------------------------------------------------- /src/assets/css/global.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #app { 4 | height: 100%; 5 | margin: 0; 6 | padding: 0; 7 | min-width: 1366px; 8 | } 9 | 10 | .el-breadcrumb { 11 | margin-bottom: 15px; 12 | } 13 | 14 | .el-card { 15 | box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15) !important; 16 | } 17 | 18 | .el-table { 19 | margin-top: 15px; 20 | margin-bottom: 15px; 21 | } 22 | 23 | .el-steps { 24 | margin: 20px 0; 25 | } 26 | 27 | .el-step__title { 28 | font-size: 14px; 29 | } 30 | 31 | .ql-editor { 32 | min-height: 300px; 33 | } -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Naccl/vue-shop/eed28f5ad4e75ac6abf306b9569248e41a7f64e1/src/assets/logo.png -------------------------------------------------------------------------------- /src/components/Home.vue: -------------------------------------------------------------------------------- 1 | 44 | 45 | 99 | 100 | -------------------------------------------------------------------------------- /src/components/Login.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 69 | 70 | -------------------------------------------------------------------------------- /src/components/Welcome.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /src/components/goods/Add.vue: -------------------------------------------------------------------------------- 1 | 75 | 76 | 264 | 265 | -------------------------------------------------------------------------------- /src/components/goods/Cate.vue: -------------------------------------------------------------------------------- 1 | 112 | 113 | 330 | 331 | -------------------------------------------------------------------------------- /src/components/goods/Edit.vue: -------------------------------------------------------------------------------- 1 | 75 | 76 | 273 | 274 | -------------------------------------------------------------------------------- /src/components/goods/List.vue: -------------------------------------------------------------------------------- 1 | 50 | 51 | 115 | 116 | -------------------------------------------------------------------------------- /src/components/goods/Params.vue: -------------------------------------------------------------------------------- 1 | 106 | 107 | 332 | 333 | -------------------------------------------------------------------------------- /src/components/order/Order.vue: -------------------------------------------------------------------------------- 1 | 78 | 79 | 160 | 161 | -------------------------------------------------------------------------------- /src/components/power/Rights.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 58 | 59 | -------------------------------------------------------------------------------- /src/components/power/Roles.vue: -------------------------------------------------------------------------------- 1 | 108 | 109 | 335 | 336 | -------------------------------------------------------------------------------- /src/components/report/Report.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 75 | 76 | -------------------------------------------------------------------------------- /src/components/user/Users.vue: -------------------------------------------------------------------------------- 1 | 123 | 124 | 370 | 371 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | import './plugins/axios' 5 | import './plugins/element.js' 6 | import moment from "moment"; 7 | import './assets/css/global.css' 8 | //富文本编辑器 9 | import VueQuillEditor from 'vue-quill-editor' 10 | import 'quill/dist/quill.core.css' // import styles 11 | import 'quill/dist/quill.snow.css' // for snow theme 12 | import 'quill/dist/quill.bubble.css' // for bubble theme 13 | 14 | //进度条 15 | import NProgress from 'nprogress' 16 | import 'nprogress/nprogress.css' 17 | 18 | axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/' 19 | axios.interceptors.request.use(config => { 20 | NProgress.start() 21 | config.headers.Authorization = window.sessionStorage.getItem('token') 22 | return config 23 | }) 24 | axios.interceptors.response.use(config => { 25 | NProgress.done() 26 | return config 27 | }) 28 | 29 | 30 | Vue.filter('dateFormat', function (value, format = 'YYYY-MM-DD HH:mm:ss') { 31 | return moment(value).format(format) 32 | }) 33 | 34 | 35 | Vue.use(VueQuillEditor) 36 | 37 | 38 | Vue.config.productionTip = false 39 | 40 | new Vue({ 41 | router, 42 | render: h => h(App) 43 | }).$mount('#app') 44 | -------------------------------------------------------------------------------- /src/plugins/axios.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | import Vue from 'vue'; 4 | import axios from "axios"; 5 | 6 | // Full config: https://github.com/axios/axios#request-config 7 | // axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || ''; 8 | // axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; 9 | // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; 10 | 11 | let config = { 12 | // baseURL: process.env.baseURL || process.env.apiUrl || "" 13 | // timeout: 60 * 1000, // Timeout 14 | // withCredentials: true, // Check cross-site Access-Control 15 | }; 16 | 17 | const _axios = axios.create(config); 18 | 19 | _axios.interceptors.request.use( 20 | function(config) { 21 | // Do something before request is sent 22 | return config; 23 | }, 24 | function(error) { 25 | // Do something with request error 26 | return Promise.reject(error); 27 | } 28 | ); 29 | 30 | // Add a response interceptor 31 | _axios.interceptors.response.use( 32 | function(response) { 33 | // Do something with response data 34 | return response; 35 | }, 36 | function(error) { 37 | // Do something with response error 38 | return Promise.reject(error); 39 | } 40 | ); 41 | 42 | Plugin.install = function(Vue, options) { 43 | Vue.axios = _axios; 44 | window.axios = _axios; 45 | Object.defineProperties(Vue.prototype, { 46 | axios: { 47 | get() { 48 | return _axios; 49 | } 50 | }, 51 | $axios: { 52 | get() { 53 | return _axios; 54 | } 55 | }, 56 | }); 57 | }; 58 | 59 | Vue.use(Plugin) 60 | 61 | export default Plugin; 62 | -------------------------------------------------------------------------------- /src/plugins/element.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Element from 'element-ui' 3 | import 'element-ui/lib/theme-chalk/index.css' 4 | 5 | Vue.use(Element) -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | import Login from "../components/Login"; 4 | import Home from "../components/Home"; 5 | import Welcome from "../components/Welcome"; 6 | import Users from "../components/user/Users"; 7 | import Rights from "../components/power/Rights"; 8 | import Roles from "../components/power/Roles"; 9 | import Cate from "../components/goods/Cate"; 10 | import Params from "../components/goods/Params"; 11 | import GoodsList from "../components/goods/List"; 12 | import GoodsAdd from "../components/goods/Add"; 13 | import GoodsEdit from "../components/goods/Edit"; 14 | import Order from "../components/order/Order"; 15 | import Report from "../components/report/Report"; 16 | 17 | Vue.use(VueRouter) 18 | 19 | const routes = [ 20 | { 21 | path: '/', 22 | redirect: '/login' 23 | }, 24 | { 25 | path: '/login', 26 | component: Login 27 | }, 28 | { 29 | path: '/home', 30 | component: Home, 31 | redirect: '/welcome', 32 | children: [ 33 | { 34 | path: '/welcome', 35 | component: Welcome 36 | }, 37 | { 38 | path: '/users', 39 | component: Users 40 | }, 41 | { 42 | path: '/rights', 43 | component: Rights 44 | }, 45 | { 46 | path: '/roles', 47 | component: Roles 48 | }, 49 | { 50 | path: '/categories', 51 | component: Cate 52 | }, 53 | { 54 | path: '/params', 55 | component: Params 56 | }, 57 | { 58 | path: '/goods', 59 | component: GoodsList 60 | }, 61 | { 62 | path: '/goods/add', 63 | component: GoodsAdd 64 | }, 65 | { 66 | path: '/goods/edit/:id', 67 | component: GoodsEdit 68 | }, 69 | { 70 | path: '/orders', 71 | component: Order 72 | }, 73 | { 74 | path: '/reports', 75 | component: Report 76 | } 77 | ] 78 | } 79 | // { 80 | // path: '/about', 81 | // name: 'About', 82 | // // route level code-splitting 83 | // // this generates a separate chunk (about.[hash].js) for this route 84 | // // which is lazy-loaded when the route is visited. 85 | // component: () => import(/* webpackChunkName: "about" */ '../views/About.vue') 86 | // } 87 | ] 88 | 89 | const router = new VueRouter({ 90 | mode: 'history', 91 | base: process.env.BASE_URL, 92 | routes 93 | }) 94 | 95 | const originalPush = VueRouter.prototype.push; 96 | VueRouter.prototype.push = function(location) { 97 | return originalPush.call(this, location).catch(err => err) 98 | } 99 | 100 | //挂载路由导航守卫 101 | router.beforeEach((to, from, next) => { 102 | // to将要访问的路径 103 | // from代表从哪个路径跳转而来 104 | // next是一个函数,表示放行 105 | // next()放行 next('/login')强制跳转 106 | if (to.path === '/login') return next() 107 | //获取token 108 | const tokenStr = window.sessionStorage.getItem('token') 109 | if (!tokenStr) return next("/login") 110 | next() 111 | }) 112 | 113 | 114 | export default router 115 | --------------------------------------------------------------------------------