Showing
6 changed files
with
124 additions
and
15 deletions
.jshintrc
0 → 100644
| 1 | +{ | ||
| 2 | + "bitwise": false, | ||
| 3 | + "camelcase": true, | ||
| 4 | + "curly": true, | ||
| 5 | + "eqeqeq": true, | ||
| 6 | + "esversion": 6, | ||
| 7 | + "forin": true, | ||
| 8 | + "freeze": true, | ||
| 9 | + "funcscope": true, | ||
| 10 | + "futurehostile": true, | ||
| 11 | + "immed": true, | ||
| 12 | + "indent": 4, | ||
| 13 | + "latedef": true, | ||
| 14 | + "maxdepth": 4, | ||
| 15 | + "maxerr": 10000, | ||
| 16 | + "maxlen": 200, | ||
| 17 | + "maxparams": 4, | ||
| 18 | + "maxstatements": 1000, | ||
| 19 | + "newcap": true, | ||
| 20 | + "noarg": true, | ||
| 21 | + "nocomma": true, | ||
| 22 | + "noempty": false, | ||
| 23 | + "nonbsp": true, | ||
| 24 | + "nonew": true, | ||
| 25 | + "notypeof": false, | ||
| 26 | + "quotmark": "single", | ||
| 27 | + "shadow": "inner", | ||
| 28 | + "singleGroups": true, | ||
| 29 | + "strict": false, | ||
| 30 | + "undef": true, | ||
| 31 | + "unused": true, | ||
| 32 | + "varstmt": false, | ||
| 33 | + "asi": true, | ||
| 34 | + "boss": true, | ||
| 35 | + "debug": true, | ||
| 36 | + "elision": true, | ||
| 37 | + "eqnull": true, | ||
| 38 | + "evil": true, | ||
| 39 | + "expr": true, | ||
| 40 | + "lastsemic": true, | ||
| 41 | + "laxbreak": true, | ||
| 42 | + "laxcomma": true, | ||
| 43 | + "loopfunc": true, | ||
| 44 | + "multistr": true, | ||
| 45 | + "plusplus": false, | ||
| 46 | + "proto": true, | ||
| 47 | + "sub": true, | ||
| 48 | + "browser": true, | ||
| 49 | + "jquery": true, | ||
| 50 | + "devel": true, | ||
| 51 | + "globals": { | ||
| 52 | + "define": true, | ||
| 53 | + "module": true, | ||
| 54 | + "export": true, | ||
| 55 | + "console": true, | ||
| 56 | + "THREE": true, | ||
| 57 | + "TWEEN": true, | ||
| 58 | + "Stats":true, | ||
| 59 | + "_": true | ||
| 60 | + } | ||
| 61 | +} |
src/http.js
0 → 100644
| 1 | +import axios from 'axios' | ||
| 2 | +import router from './router' | ||
| 3 | + | ||
| 4 | +// 请求拦截器 | ||
| 5 | +axios.interceptors.request.use( | ||
| 6 | + config => { | ||
| 7 | + // 发送请求前 | ||
| 8 | + let hash = location.hash.split('?')[0]; | ||
| 9 | + config.headers['Step-Url'] = location.pathname + hash; | ||
| 10 | + if (config.params) { | ||
| 11 | + config.params = _.merge(config.params, { version: 'v.1.1.0 ' }) | ||
| 12 | + } else { | ||
| 13 | + config.params = { | ||
| 14 | + version: 'v.1.1.0' | ||
| 15 | + } | ||
| 16 | + } | ||
| 17 | + return config; | ||
| 18 | + }, | ||
| 19 | + error => { | ||
| 20 | + // 请求错误处理 | ||
| 21 | + return Promise.reject(error); | ||
| 22 | + }) | ||
| 23 | + | ||
| 24 | +// 响应拦截器 | ||
| 25 | +axios.interceptors.response.use( | ||
| 26 | + response => { | ||
| 27 | + return response; | ||
| 28 | + }, | ||
| 29 | + error => { | ||
| 30 | + if (error.response) { | ||
| 31 | + switch (error.response.status) { | ||
| 32 | + case 401: | ||
| 33 | + if (window.location.hostname === 'localhost') { | ||
| 34 | + window.location.href = '../login.html'; | ||
| 35 | + } else { | ||
| 36 | + let h = window.location.origin + '/' + _.split(window.location.pathname, '/', 2)[1] + '/login.html'; | ||
| 37 | + window.location.href = error.response.data.hasOwnProperty('content') ? error.response.data.content : h; | ||
| 38 | + } | ||
| 39 | + break; | ||
| 40 | + case 404: | ||
| 41 | + router.replace({ | ||
| 42 | + path: '/' | ||
| 43 | + }) | ||
| 44 | + break; | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + return Promise.reject(error.response.data); | ||
| 48 | + }) | ||
| 49 | +export default axios; |
| ... | @@ -2,6 +2,7 @@ import Vue from 'vue' | ... | @@ -2,6 +2,7 @@ import Vue from 'vue' |
| 2 | import App from './App.vue' | 2 | import App from './App.vue' |
| 3 | import router from './router' | 3 | import router from './router' |
| 4 | import store from './store' | 4 | import store from './store' |
| 5 | +import axios from './http' | ||
| 5 | import MuseUI from 'muse-ui'; | 6 | import MuseUI from 'muse-ui'; |
| 6 | import 'muse-ui/dist/muse-ui.css'; | 7 | import 'muse-ui/dist/muse-ui.css'; |
| 7 | import Toast from 'muse-ui-toast'; | 8 | import Toast from 'muse-ui-toast'; |
| ... | @@ -20,5 +21,6 @@ Vue.use(NProgress); | ... | @@ -20,5 +21,6 @@ Vue.use(NProgress); |
| 20 | new Vue({ | 21 | new Vue({ |
| 21 | router, | 22 | router, |
| 22 | store, | 23 | store, |
| 24 | + axios, | ||
| 23 | render: h => h(App) | 25 | render: h => h(App) |
| 24 | }).$mount('#app') | 26 | }).$mount('#app') | ... | ... |
| ... | @@ -148,9 +148,6 @@ export default { | ... | @@ -148,9 +148,6 @@ export default { |
| 148 | position: relative; | 148 | position: relative; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | - // /deep/.mu-table th.is-sortable { | ||
| 152 | - // color: rgba(0,0,0,.87); | ||
| 153 | - // } | ||
| 154 | /deep/.mu-table th.is-sortable .mu-table-sort-icon { | 151 | /deep/.mu-table th.is-sortable .mu-table-sort-icon { |
| 155 | opacity: .6; | 152 | opacity: .6; |
| 156 | } | 153 | } | ... | ... |
| ... | @@ -3,7 +3,7 @@ const path = require('path') | ... | @@ -3,7 +3,7 @@ const path = require('path') |
| 3 | const webpack = require('webpack') | 3 | const webpack = require('webpack') |
| 4 | const CompressionWebpackPlugin = require('compression-webpack-plugin') | 4 | const CompressionWebpackPlugin = require('compression-webpack-plugin') |
| 5 | 5 | ||
| 6 | -function resolve(dir) { | 6 | +function resolve (dir) { |
| 7 | return path.join(__dirname, './', dir) | 7 | return path.join(__dirname, './', dir) |
| 8 | } | 8 | } |
| 9 | 9 | ||
| ... | @@ -119,16 +119,16 @@ module.exports = { | ... | @@ -119,16 +119,16 @@ module.exports = { |
| 119 | */ | 119 | */ |
| 120 | config | 120 | config |
| 121 | .plugin('html-index') | 121 | .plugin('html-index') |
| 122 | - .tap(args => { | 122 | + .tap(args => { |
| 123 | - if (process.env.NODE_ENV === 'production') { | 123 | + if (process.env.NODE_ENV === 'production') { |
| 124 | - args[0].cdn = cdn.build | 124 | + args[0].cdn = cdn.build |
| 125 | - } | 125 | + } |
| 126 | - if (process.env.NODE_ENV === 'development') { | 126 | + if (process.env.NODE_ENV === 'development') { |
| 127 | - args[0].cdn = cdn.dev | 127 | + args[0].cdn = cdn.dev |
| 128 | - } | 128 | + } |
| 129 | - return args | 129 | + return args |
| 130 | - }) | 130 | + }) |
| 131 | - .end() | 131 | + .end() |
| 132 | }, | 132 | }, |
| 133 | // css相关配置 | 133 | // css相关配置 |
| 134 | css: { | 134 | css: { | ... | ... |
-
Please register or login to post a comment