diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index 0ecdf16..f343182 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -72,7 +72,9 @@ module.exports = { name: utils.assetsPath('fonts/[name].[hash:7].[ext]') } } - ], + ] + + }, plugins: [ new webpack.optimize.CommonsChunkPlugin('common.js'), new webpack.ProvidePlugin({ @@ -80,5 +82,4 @@ module.exports = { $: "jquery" }) ] - } } diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index ad11335..55be00a 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -33,7 +33,7 @@ module.exports = merge(baseWebpackConfig, { new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', - favicon: resolveApp('favicon.ico'), + favicon: resolveApp('logo.ico'), inject: true }), new FriendlyErrorsPlugin() diff --git a/config/index.js b/config/index.js index 9e7a485..70d7e2b 100644 --- a/config/index.js +++ b/config/index.js @@ -27,7 +27,22 @@ module.exports = { autoOpenBrowser: true, assetsSubDirectory: 'static', assetsPublicPath: '/', - proxyTable: {}, + proxyTable: { + '/weather': { + target: 'http://www.sojson.com/open/api/weather/json.shtml', + changeOrigin:true, + pathRewrite: { + '^/weather': '' + } + }, + '/douban': { + target: 'https://api.douban.com/v2',//设置你调用的接口域名和端口号 别忘了加http + changeOrigin: true, + pathRewrite: { + '^/douban': ''//这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替 比如我要调用'http://40.00.100.100:3002/user/add',直接写‘/api/user/add’即可 + } + } + }, // CSS Sourcemaps off by default because relative paths are "buggy" // with this option, according to the CSS-Loader README // (https://github.com/webpack/css-loader#sourcemaps) diff --git a/favicon.ico b/favicon.ico deleted file mode 100644 index 37b44a6..0000000 Binary files a/favicon.ico and /dev/null differ diff --git a/package.json b/package.json index 4b0013b..39547eb 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,10 @@ "lint": "eslint --ext .js,.vue src" }, "dependencies": { - "jquery" : "^3.2.1", "axios": "0.16.2", "element-ui": "^2.0.11", + "http-proxy-middleware": "^0.17.3", + "jquery": "^3.2.1", "js-cookie": "2.1.4", "normalize.css": "7.0.0", "nprogress": "0.2.0", diff --git a/src/router/index.js b/src/router/index.js index eedb483..bdc9f7b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -62,5 +62,15 @@ export const asyncRouterMap = [ children: [{ path: 'index', name: 'Table', component: _import('table/index'), meta: { role: ['user'] }}] }, + { + path: '/DouBan', + component: Layout, + redirect: 'noredirect', + name:"豆瓣查询", + icon: 'tubiao', + children: [{ path: 'movie', name: '热门电影', component: _import('DouBan/movie'), meta: { role: ['system'] }}, + { path: 'music', name: '音乐排行', component: _import('DouBan/music'), meta: { role: ['system'] }}, + { path: 'book', name: '热门图书', component: _import('DouBan/book'), meta: { role: ['system'] }}] + }, { path: '*', redirect: '/404', hidden: true } ] diff --git a/src/store/getters.js b/src/store/getters.js index 8a8bf8b..6a49966 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -2,6 +2,7 @@ const getters = { sidebar: state => state.app.sidebar, token: state => state.user.token, // avatar: state => state.user.avatar, + realname:state=>state.user.realname, name: state => state.user.name, roles: state => state.user.roles, permission_routers: state => state.permission.routers, diff --git a/src/utils/fetch.js b/src/utils/fetch.js index 7ddc3c3..2261364 100644 --- a/src/utils/fetch.js +++ b/src/utils/fetch.js @@ -18,6 +18,7 @@ service.interceptors.request.use(config => { if (store.getters.token) { config.headers['auth'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 } + console.log("拦截req") return config }, error => { // Do something with request error diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index d35a64e..38b5c61 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,20 +1,33 @@ @@ -22,11 +35,15 @@ import { mapGetters } from 'vuex' - import {parseTime} from '@/utils/index' + import { + parseTime + } from '@/utils/index' + import axios from 'axios' export default { data() { return { - currentDate: parseTime(new Date()) + currentDate: parseTime(new Date()), + weather:null } }, name: 'dashboard', @@ -35,6 +52,24 @@ 'name', 'roles' ]) + }, + methods: { + GetNowTime() { + setInterval(() => { + this.currentDate = parseTime(new Date()) + }, 1000) + + }, + GetWeather(){ + axios.get('/weather?city=南京').then(response=>{ + this.weather = response.data + }) + } + }, + created() { + this.GetNowTime() + this.GetWeather() + } }