Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa44005

Browse files
author
spt
committed
跨域代理配置
1 parentc21a5d3 commitaa44005

File tree

7 files changed

+79
-49
lines changed

7 files changed

+79
-49
lines changed

‎config/index.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ module.exports = {
2727
autoOpenBrowser:true,
2828
assetsSubDirectory:'static',
2929
assetsPublicPath:'/',
30-
proxyTable:{},
30+
proxyTable:{
31+
'/api-v1':{
32+
target:'http://localhost:8081',
33+
changeOrigin:true
34+
}
35+
},
3136
// CSS Sourcemaps off by default because relative paths are "buggy"
3237
// with this option, according to the CSS-Loader README
3338
// (https://github.com/webpack/css-loader#sourcemaps)

‎doc/vue/跨域代理配置‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
当跨域无法请求的时候我们可以修改工程下config文件夹下的index.js中的dev:{}部分。dev: {
2+
env: require('./dev.env'),
3+
port: 8080,
4+
autoOpenBrowser: false,
5+
assetsSubDirectory: 'static',
6+
assetsPublicPath: '/',
7+
proxyTable: {
8+
'/api': {
9+
target: 'http://api.douban.com/v2',
10+
changeOrigin: true,
11+
pathRewrite: {
12+
'^/api': ''
13+
}
14+
}
15+
},
16+
// CSS Sourcemaps off by default because relative paths are "buggy"
17+
// with this option, according to the CSS-Loader README
18+
// (https://github.com/webpack/css-loader#sourcemaps)
19+
// In our experience, they generally work as expected,
20+
// just be aware of this issue when enabling this option.
21+
cssSourceMap: false
22+
}

‎src/components/platform/platform.component.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import PlatformService from '../../services/platform.service';
66
importmomentfrom'moment';
77
importdebouncefrom'throttle-debounce/debounce';
88
import{Vue,Prop,Component}from'vue-property-decorator'
9-
109
importTodoListItemfrom'@/components/todo-list-item/TodoListItem.vue'
1110
importZeusMenufrom'@/components/zeus-menu/zeus-menu.vue';
11+
importZeusUserfrom'@/components/zeus-user/zeus-user.vue';
1212
@Component({
1313
components:{
14-
ZeusMenu
14+
ZeusMenu,
15+
ZeusUser
1516
}
1617
})
1718
exportdefaultclassPlatformComponentextendsVue{
@@ -38,7 +39,7 @@ export default class PlatformComponent extends Vue {
3839
companyInfo:any=null// 公司信息 - 修改
3940

4041
created(){
41-
//this.search();
42+
this.search();
4243
}
4344

4445
// 获取左侧列表接口

‎src/components/platform/platform.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</div>
1515
<divclass="header-help">
1616
<el-buttontype="primary"@click="addNew">新增</el-button>
17-
<!--<zeus-user></zeus-user>-->
17+
<zeus-user></zeus-user>
1818
</div>
1919
</header>
2020
<transitionname="fade"mode="out-in"v-if="navList.length">
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import{Vue,Component}from'vue-property-decorator'
2+
//import Api from '../../services/login.js';
3+
importClickoutsidefrom'element-ui/lib/utils/clickoutside';
4+
@Component({
5+
name:'zeus-user',
6+
directives:{ Clickoutside}
7+
})
8+
exportdefaultclassUserComponentextendsVue{
9+
activeName:string='';
10+
showDropDown:boolean=false;
11+
dropDown(){
12+
this.showDropDown=!this.showDropDown;
13+
}
14+
handleBlur(){
15+
this.showDropDown=false;
16+
}
17+
logout(){
18+
//const userInfo = JSON.parse(localStorage.getItem('userInfo'));
19+
// Api.logout({
20+
// token: userInfo.token,
21+
// accountId: userInfo.username
22+
// })
23+
// .then(({data}) => {
24+
// if (data.code === 1) {
25+
// this.$message({
26+
// message: '退出成功',
27+
// type: 'success'
28+
// });
29+
// setTimeout(() => {
30+
// location.href = '/login';
31+
// }, 500);
32+
// } else {
33+
// this.$message({
34+
// message: data.message,
35+
// type: 'warning'
36+
// });
37+
// }
38+
// });
39+
}
40+
}

‎src/components/user/index.vue‎renamed to ‎src/components/zeus-user/zeus-user.vue‎

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,9 @@
1010
</transition>
1111
</div>
1212
</template>
13-
<script>
14-
importApifrom'../../services/login.js';
15-
importClickoutsidefrom'element-ui/lib/utils/clickoutside';
16-
exportdefault {
17-
directives: { Clickoutside },
18-
data() {
19-
return {
20-
activeName:'',
21-
showDropDown:false
22-
};
23-
},
24-
methods: {
25-
dropDown() {
26-
this.showDropDown=!this.showDropDown;
27-
},
28-
handleBlur() {
29-
this.showDropDown=false;
30-
},
31-
logout() {
32-
constuserInfo=JSON.parse(localStorage.getItem('userInfo'));
33-
Api.logout({
34-
token:userInfo.token,
35-
accountId:userInfo.username
36-
})
37-
.then(({data})=> {
38-
if (data.code===1) {
39-
this.$message({
40-
message:'退出成功',
41-
type:'success'
42-
});
43-
setTimeout(()=> {
44-
location.href='/login';
45-
},500);
46-
}else {
47-
this.$message({
48-
message:data.message,
49-
type:'warning'
50-
});
51-
}
52-
});
53-
}
54-
}
55-
};
13+
<script lang="ts">
14+
importZeusUserComponentfrom'@/components/zeus-user/zeus-user.component'
15+
exportdefaultZeusUserComponent
5616
</script>
5717
<style scoped lang="scss">
5818
.user {

‎src/main.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
importVuefrom'vue'
77
importAppfrom'./App.vue'
88
importrouterfrom'./router'
9-
9+
importaxiosfrom'axios';
1010
importElementUIfrom'element-ui'
1111
import'element-ui/lib/theme-default/index.css'
1212
importInfiniteScrollfrom'vue-infinite-scroll';
1313
import'./assets/css/index.scss';
1414
import'font-awesome/css/font-awesome.css';
15+
16+
axios.defaults.baseURL='/api-v1/';
1517
Vue.use(ElementUI)
1618
Vue.use(InfiniteScroll)
1719
/* eslint-disable no-new */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp