Skip to content

Commit

Permalink
Merge pull request lin-xin#183 from lin-xin/dev
Browse files Browse the repository at this point in the history
请求不使用代理
  • Loading branch information
lin-xin authored Jun 23, 2019
2 parents 5ac78cf + bee36e1 commit 38a5bd4
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 118 deletions.
Binary file removed favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",
"element-ui": "^2.8.2",
"element-ui": "^2.9.2",
"mavon-editor": "^2.6.17",
"vue": "^2.6.10",
"vue-cropperjs": "^3.0.0",
Expand Down
53 changes: 0 additions & 53 deletions public/vuetable.json

This file was deleted.

9 changes: 9 additions & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import request from '../utils/request';

export const fetchData = (query) => {
return request({
url: '/ms/table/list',
method: 'post',
data: query
})
}
43 changes: 0 additions & 43 deletions src/assets/vuetable.json

This file was deleted.

6 changes: 6 additions & 0 deletions src/components/common/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
}
]
}
,
{
icon: 'el-icon-lx-redpacket_fill',
index: '/donate',
title: '支持作者'
}
]
}
},
Expand Down
14 changes: 5 additions & 9 deletions src/components/page/BaseTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
</div>
<div class="container">
<div class="handle-box">
<el-button type="primary" icon="delete" class="handle-del mr10" @click="delAll">批量删除</el-button>
<el-button type="primary" icon="el-icon-delete" class="handle-del mr10" @click="delAll">批量删除</el-button>
<el-select v-model="select_cate" placeholder="筛选省份" class="handle-select mr10">
<el-option key="1" label="广东省" value="广东省"></el-option>
<el-option key="2" label="湖南省" value="湖南省"></el-option>
</el-select>
<el-input v-model="select_word" placeholder="筛选关键词" class="handle-input mr10"></el-input>
<el-button type="primary" icon="search" @click="search">搜索</el-button>
<el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
</div>
<el-table :data="data" border class="table" ref="multipleTable" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"></el-table-column>
Expand Down Expand Up @@ -68,11 +68,11 @@
</template>

<script>
import { fetchData } from '../../api/index';
export default {
name: 'basetable',
data() {
return {
url: './vuetable.json',
tableData: [],
cur_page: 1,
multipleSelection: [],
Expand Down Expand Up @@ -123,14 +123,10 @@
},
// 获取 easy-mock 的模拟数据
getData() {
// 开发环境使用 easy-mock 数据,正式环境使用 json 文件
if (process.env.NODE_ENV === 'development') {
this.url = '/ms/table/list';
};
this.$axios.post(this.url, {
fetchData({
page: this.cur_page
}).then((res) => {
this.tableData = res.data.list;
this.tableData = res.list;
})
},
search() {
Expand Down
26 changes: 26 additions & 0 deletions src/components/page/Donate.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<div>
<div class="crumbs">
<el-breadcrumb separator="/">
<el-breadcrumb-item><i class="el-icon-lx-redpacket_fill"></i> 支持作者</el-breadcrumb-item>
</el-breadcrumb>
</div>
<div class="container">
<div class="plugins-tips">
如果该框架对你有帮助,那就请作者喝杯饮料吧!加微信号linxin_20探讨问题。
</div>
<div><img src="http://blog.gdfengshuo.com/images/weixin.jpg"></div>
</div>

</div>
</template>

<script>
export default {
}
</script>

<style>
</style>
2 changes: 1 addition & 1 deletion src/components/page/Upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<el-upload
class="upload-demo"
drag
action="/api/posts/"
action="http://jsonplaceholder.typicode.com/api/posts/"
multiple>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
Expand Down
5 changes: 5 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export default new Router({
path: '/403',
component: resolve => require(['../components/page/403.vue'], resolve),
meta: { title: '403' }
},
{
path: '/donate',
component: resolve => require(['../components/page/Donate.vue'], resolve),
meta: { title: '支持作者' }
}
]
},
Expand Down
27 changes: 27 additions & 0 deletions src/utils/request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import axios from 'axios';

const service = axios.create({
// process.env.NODE_ENV === 'development' 来判断是否开发环境
baseURL: 'https://www.easy-mock.com/mock/592501a391470c0ac1fab128',
timeout: 5000
})

service.interceptors.request.use( config => {
return config;
}, error => {
console.log(error);
return Promise.reject();
})

service.interceptors.response.use(response => {
if(response.status === 200){
return response.data;
}else{
Promise.reject();
}
}, error => {
console.log(error);
return Promise.reject();
})

export default service;
19 changes: 8 additions & 11 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
module.exports = {
baseUrl: './',
assetsDir: 'static',
productionSourceMap: false,
devServer: {
proxy: {
'/api':{
target:'http://jsonplaceholder.typicode.com',
changeOrigin:true,
pathRewrite:{
'/api':''
}
},
'/ms':{
target: 'https://www.easy-mock.com/mock/592501a391470c0ac1fab128',
changeOrigin: true
}
// '/api':{
// target:'http://jsonplaceholder.typicode.com',
// changeOrigin:true,
// pathRewrite:{
// '/api':''
// }
// }
}
}
}

0 comments on commit 38a5bd4

Please sign in to comment.