├── .browserslistrc ├── .eslintrc.js ├── .github └── ISSUE_TEMPLATE │ └── bug_report.md ├── .gitignore ├── .vscode ├── launch.json └── settings.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── public ├── favicon.ico ├── img │ └── icons │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── apple-touch-icon-120x120.png │ │ ├── apple-touch-icon-152x152.png │ │ ├── apple-touch-icon-180x180.png │ │ ├── apple-touch-icon-60x60.png │ │ ├── apple-touch-icon-76x76.png │ │ ├── apple-touch-icon.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── msapplication-icon-144x144.png │ │ ├── mstile-150x150.png │ │ └── safari-pinned-tab.svg ├── index.html ├── manifest.json └── robots.txt ├── src ├── App.vue ├── api │ └── login.js ├── assets │ └── logo.png ├── components │ └── header │ │ └── header.vue ├── constants │ └── index.js ├── main.js ├── registerServiceWorker.js ├── router │ ├── index.js │ └── modules │ │ └── dashboard.js ├── store │ ├── getters.js │ ├── index.js │ └── modules │ │ └── user │ │ ├── actions.js │ │ └── index.js ├── utils │ └── request.js └── views │ ├── auth │ ├── signin.vue │ └── signup.vue │ ├── dashboard │ └── dashboard.vue │ └── welcome │ └── welcome.vue └── vue.config.js /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ["@vue/airbnb","plugin:vue/base","plugin:vue/essential","plugin:vue/strongly-recommended"], 7 | rules: { 8 | "no-console": process.env.NODE_ENV === "production" ? "error" : "off", 9 | "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" 10 | }, 11 | parserOptions: { 12 | parser: "babel-eslint", 13 | ecmaVersion: 2017, 14 | sourceType: "module" 15 | }, 16 | plugins: [ 17 | "vue", 18 | "html" 19 | ] 20 | }; 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.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 | 14 | # Editor directories and files 15 | .idea 16 | *.suo 17 | *.ntvs* 18 | *.njsproj 19 | *.sln 20 | *.sw* 21 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "configurations": [ 4 | { 5 | "type": "chrome", 6 | "request": "launch", 7 | "name": "Launch Chrome", 8 | "url": "http://localhost:8080", 9 | "webRoot": "${workspaceFolder}" 10 | }, 11 | ] 12 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to override the default and user settings 2 | { 3 | // This is required for ESLint to work in Vue in VS Code. 4 | "eslint.options": { 5 | "extensions": [".html", ".js", ".vue", ".jsx"] 6 | }, 7 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at sureshapn.m@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | Please contribute with this. 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 SUBRAMANIAN 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Pull request 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-folder-structure 2 | 3 | 4 | # vue-large-scale-folder-structure 5 | 6 | # vue-js Vuex Vue-router axios vue-notification 7 | Vue js large scale folder structure 8 | 9 | created by sureshapn (sureshapn.m@gmail.com) 10 | 11 | Vuex, Vue-router, axios 12 | 13 | 14 | develop large scale vue js app using this code structure. 15 | 16 | 17 | Please contribute and develop. 18 | ## For SSR Server Side Rendering 19 | Use branch SSR 20 | 21 | ## Project setup 22 | ``` 23 | npm install 24 | ``` 25 | 26 | ### Compiles and hot-reloads for development 27 | ``` 28 | npm run serve 29 | ``` 30 | 31 | ### Compiles and minifies for production 32 | ``` 33 | npm run build 34 | ``` 35 | 36 | ### Lints and fixes files 37 | ``` 38 | npm run lint 39 | ``` 40 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@vue/app'], 3 | }; 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-folder-structure", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "axios": "^0.18.0", 12 | "element-ui": "^2.4.6", 13 | "register-service-worker": "^1.0.0", 14 | "vue": "^2.5.17", 15 | "vue-router": "^3.0.1", 16 | "vuex": "^3.0.1" 17 | }, 18 | "devDependencies": { 19 | "@vue/cli-plugin-babel": "^3.0.1", 20 | "@vue/cli-plugin-eslint": "^3.0.1", 21 | "@vue/cli-plugin-pwa": "^3.0.1", 22 | "@vue/cli-service": "^3.0.1", 23 | "@vue/eslint-config-airbnb": "^3.0.1", 24 | "babel-eslint": "^9.0.0", 25 | "eslint": "^5.5.0", 26 | "eslint-config-airbnb-base": "^13.1.0", 27 | "eslint-plugin-html": "^4.0.5", 28 | "eslint-plugin-import": "^2.14.0", 29 | "eslint-plugin-vue": "^4.7.1", 30 | "node-sass": "^4.9.0", 31 | "sass-loader": "^7.0.1", 32 | "vue-template-compiler": "^2.5.17" 33 | }, 34 | "description": "## Project setup ``` npm install ```", 35 | "main": ".eslintrc.js", 36 | "keywords": [ 37 | "vue-folder-structure-for-large-scale", 38 | "vue project with vuex, vue-router, auth, axios" 39 | ], 40 | "author": "sureshapn (SUBRAMANIAN)", 41 | "email": "sureshapn.m@gmail.com", 42 | "license": "ISC" 43 | } 44 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {}, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/favicon.ico -------------------------------------------------------------------------------- /public/img/icons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/android-chrome-192x192.png -------------------------------------------------------------------------------- /public/img/icons/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/android-chrome-512x512.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/apple-touch-icon.png -------------------------------------------------------------------------------- /public/img/icons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/favicon-16x16.png -------------------------------------------------------------------------------- /public/img/icons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/favicon-32x32.png -------------------------------------------------------------------------------- /public/img/icons/msapplication-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/msapplication-icon-144x144.png -------------------------------------------------------------------------------- /public/img/icons/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/public/img/icons/mstile-150x150.png -------------------------------------------------------------------------------- /public/img/icons/safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | Created by potrace 1.11, written by Peter Selinger 2001-2013 9 | 10 | 12 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | vue-folder-structure 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-folder-structure", 3 | "short_name": "vue-folder-structure", 4 | "icons": [ 5 | { 6 | "src": "/img/icons/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/img/icons/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "start_url": "/index.html", 17 | "display": "standalone", 18 | "background_color": "#000000", 19 | "theme_color": "#4DBA87" 20 | } 21 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 17 | 18 | -------------------------------------------------------------------------------- /src/api/login.js: -------------------------------------------------------------------------------- 1 | import request from '@/utils/request'; 2 | 3 | export function loginByUsername(username, password) { 4 | const data = { 5 | username, 6 | password, 7 | }; 8 | return request({ 9 | url: '/logout', 10 | method: 'post', 11 | data, 12 | }); 13 | } 14 | 15 | export function logout() { 16 | return request({ 17 | url: '/logout', 18 | method: 'get', 19 | }); 20 | } 21 | 22 | export function getUserInfo(token) { 23 | return request({ 24 | url: '/user/info', 25 | method: 'get', 26 | params: { token }, 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Honest0/vue-large-scale-folder-structure/040c9c890b54aeec6cb5105708f6fc52b0019b7f/src/assets/logo.png -------------------------------------------------------------------------------- /src/components/header/header.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 39 | 40 | -------------------------------------------------------------------------------- /src/constants/index.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | apiUrl: 'http://localhost:7000', 3 | }; 4 | export default config; 5 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | 2 | import ElementUI from 'element-ui'; 3 | import 'element-ui/lib/theme-chalk/index.css'; 4 | import Vue from 'vue'; 5 | import App from './App.vue'; 6 | import router from './router'; 7 | import store from './store'; 8 | import './registerServiceWorker'; 9 | 10 | Vue.use(ElementUI); 11 | 12 | Vue.config.productionTip = false; 13 | 14 | new Vue({ 15 | router, 16 | store, 17 | render: h => h(App), 18 | }).$mount('#app'); 19 | -------------------------------------------------------------------------------- /src/registerServiceWorker.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | 3 | import { register } from 'register-service-worker'; 4 | 5 | if (process.env.NODE_ENV === 'production') { 6 | register(`${process.env.BASE_URL}service-worker.js`, { 7 | ready() { 8 | console.log('App is being served from cache by a service worker.\n' + 9 | 'For more details, visit https://goo.gl/AFskqB'); 10 | }, 11 | cached() { 12 | console.log('Content has been cached for offline use.'); 13 | }, 14 | updated() { 15 | console.log('New content is available; please refresh.'); 16 | }, 17 | offline() { 18 | console.log('No internet connection found. App is running in offline mode.'); 19 | }, 20 | error(error) { 21 | console.error('Error during service worker registration:', error); 22 | }, 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Router from 'vue-router'; 3 | import WelcomePage from '../views/welcome/welcome.vue'; 4 | import dashboardRouter from './modules/dashboard'; 5 | 6 | Vue.use(Router); 7 | 8 | export default new Router({ 9 | mode: 'history', 10 | routes: [ 11 | { path: '/', component: WelcomePage }, 12 | { path: '/signup', component: () => import('../views/auth/signup.vue') }, 13 | { path: '/signin', component: () => import('../views/auth/signin.vue') }, 14 | dashboardRouter, 15 | { path: '*', redirect: '/', hidden: true }, 16 | ], 17 | }); 18 | -------------------------------------------------------------------------------- /src/router/modules/dashboard.js: -------------------------------------------------------------------------------- 1 | /** When your routing table is too long, you can split it into small modules* */ 2 | 3 | import store from '@/store'; 4 | import DashboardPage from '@/views/dashboard/dashboard.vue'; 5 | 6 | const dashboardRouter = { 7 | path: '/dashboard', 8 | component: DashboardPage, 9 | beforeEnter(to, from, next) { 10 | if (store.state.idToken) { 11 | next(); 12 | } else { 13 | next('/signin'); 14 | } 15 | }, 16 | }; 17 | 18 | export default dashboardRouter; 19 | -------------------------------------------------------------------------------- /src/store/getters.js: -------------------------------------------------------------------------------- 1 | const getters = { 2 | token: state => state.user.token, 3 | name: state => state.user.name, 4 | }; 5 | export default getters; 6 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Vuex from 'vuex'; 3 | import user from './modules/user'; 4 | import getters from './getters'; 5 | 6 | Vue.use(Vuex); 7 | 8 | const store = new Vuex.Store({ 9 | modules: { 10 | user, 11 | }, 12 | getters, 13 | }); 14 | 15 | export default store; 16 | -------------------------------------------------------------------------------- /src/store/modules/user/actions.js: -------------------------------------------------------------------------------- 1 | 2 | import { loginByUsername, logout, getUserInfo } from '@/api/login'; 3 | 4 | export default { 5 | 6 | async LoginByUsername({ commit }, userInfo) { 7 | try { 8 | const token = await loginByUsername(userInfo); 9 | commit('SET_TOKEN', token); 10 | return token; 11 | } catch (e) { 12 | throw e; 13 | } 14 | }, 15 | 16 | async LogOut({ commit, state }) { 17 | try { 18 | await logout(state.token); 19 | commit('SET_TOKEN', ''); 20 | } catch (e) { 21 | throw e; 22 | } 23 | }, 24 | 25 | async GetUserInfo({ commit, state }) { 26 | try { 27 | const userData = await getUserInfo(state.token); 28 | commit('SET_NAME', userData.name); 29 | return userData; 30 | } catch (e) { 31 | throw e; 32 | } 33 | }, 34 | 35 | 36 | }; 37 | -------------------------------------------------------------------------------- /src/store/modules/user/index.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import actions from './actions'; 4 | 5 | const user = { 6 | state: { 7 | user: '', 8 | name: '', 9 | token: '', 10 | }, 11 | 12 | mutations: { 13 | SET_TOKEN: (state, token) => { 14 | Object.assign(state, { token }); 15 | }, 16 | SET_STATUS: (state, status) => { 17 | Object.assign(state, { status }); 18 | }, 19 | SET_NAME: (state, name) => { 20 | Object.assign(state, { name }); 21 | }, 22 | }, 23 | 24 | actions, 25 | }; 26 | 27 | export default user; 28 | -------------------------------------------------------------------------------- /src/utils/request.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | import { Message } from 'element-ui'; 3 | import store from '@/store'; 4 | import config from '@/constants'; 5 | 6 | // create an axios instance 7 | const service = axios.create({ 8 | baseURL: config.apiUrl, 9 | timeout: 5000, // request timeout 10 | }); 11 | 12 | // request interceptor 13 | service.interceptors.request.use( 14 | (serviceConfig) => { 15 | if (store.getters.token) { 16 | // serviceConfig.headers['X-Token'] = getToken(); 17 | } 18 | return serviceConfig; 19 | }, 20 | (error) => { 21 | Promise.reject(error); 22 | }, 23 | ); 24 | 25 | // respone interceptor 26 | service.interceptors.response.use( 27 | (response) => { 28 | const res = response.data; 29 | if (res.status !== 200) { 30 | return Message({ 31 | message: res.message, 32 | type: 'error', 33 | duration: 5 * 1000, 34 | }); 35 | } 36 | return res; 37 | }, 38 | (error) => { 39 | Message({ 40 | message: error.message, 41 | type: 'error', 42 | duration: 5 * 1000, 43 | }); 44 | return Promise.resolve(error); 45 | }, 46 | ); 47 | 48 | export default service; 49 | -------------------------------------------------------------------------------- /src/views/auth/signin.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 47 | 48 | -------------------------------------------------------------------------------- /src/views/auth/signup.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 46 | 47 | -------------------------------------------------------------------------------- /src/views/dashboard/dashboard.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 23 | 24 | -------------------------------------------------------------------------------- /src/views/welcome/welcome.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | configureWebpack: { 3 | devtool: 'source-map', 4 | }, 5 | }; 6 | --------------------------------------------------------------------------------