-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.vue
129 lines (127 loc) · 4.71 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
<div id="app">
<div id="navmenu">
<!-- NOT LOGIN -->
<template v-if="blogin==false">
Access: {{navname}}
</template>
<!-- LOGIN TO ACCESS VIEW -->
<template v-if="blogin">
<!-- <a href="#" >Home</a> -->
<a href="#" v-for="item in navmenus" v-on:click="setViewComponent(item.context)" :key="item.context"> {{item.name}} |</a>
<DisplayNameComponent></DisplayNameComponent>
<PublicKeyDisplayComponent></PublicKeyDisplayComponent>
</template>
</div>
<div id="content">
<!-- LOGIN TO ACCESS VIEW -->
<template v-if="blogin">
<component :is="currentView" ></component>
</template>
<!-- NOT LOGIN DEFAULT ACCESS -->
<template v-else>
<template v-if="bforgotpassphrase==false">
<LoginComponent></LoginComponent>
</template>
<template v-else>
<ForgotComponent></ForgotComponent>
</template>
</template>
</div>
</div>
</template>
<script>
import HomeLayoutComponent from './components/HomeLayoutComponent';
import AccountLayoutComponent from './components/AccountLayoutComponent';
import MessagesLayoutComponent from './components/MessagesLayoutComponent';
import PublicChatLayoutComponent from './components/PublicChatLayoutComponent';
import PrivateChatLayoutComponent from './components/PrivateChatLayoutComponent';
import SimpleChatComponent from './components/SimpleChatComponent';
import DisplayNameComponent from './components/DisplayNameComponent';
import PublicKeyDisplayComponent from './components/PublicKeyDisplayComponent';
//import ChatPanel from './components/TestChatComponent';
import LoginComponent from './components/LoginComponent';
import ForgotComponent from './components/ForgotComponent';
import bus from './bus';
//<component :is="currentView" ></component>
export default {
data() {
return {
navname:"Login",
currentView:null,
blogin:false,
bforgotpassphrase:false,
elappcontent:null,
elcontent:null,
navmenus:[],
}
},
components:{
LoginComponent,
ForgotComponent,
DisplayNameComponent,
PublicKeyDisplayComponent,
//ChatPanel,
},
created(){
this.$on('action', this.action);
//this.currentView = ChatPanel;
//this.currentView = AccountLayoutComponent;
this.currentView = HomeLayoutComponent;
this.navmenus.push({name:"Home",context:"home",comp:HomeLayoutComponent});
this.navmenus.push({name:"Account",context:"account",comp:AccountLayoutComponent});
this.navmenus.push({name:"Messages",context:"messages",comp:MessagesLayoutComponent});
this.navmenus.push({name:"Public Chat",context:"publicchat",comp:PublicChatLayoutComponent});
this.navmenus.push({name:"Private Chat",context:"privatechat",comp:PrivateChatLayoutComponent});
this.navmenus.push({name:"Simple Chat",context:"simplechat",comp:SimpleChatComponent});
},
mounted(){
console.log("mount!");
this.elappcontent = document.getElementById('app');
this.elcontent = document.getElementById('content');
window.addEventListener("resize", this.resize.bind(this));
},
beforeDestroy() {
window.removeEventListener("resize", this.resize.bind(this));
},
methods: {
action:function(event){
if(event == "loginpass"){
this.blogin=true;
}
if(event == "accessforgot"){
this.bforgotpassphrase=true;
this.navname="Forgot";
}
if(event == "accesslogin"){
this.bforgotpassphrase=false;
this.navname="Login";
}
},
setViewComponent:function(_view){
//console.log(_view);
let menus = this.navmenus;
for (let i =0;i < menus.length;i++){
if(menus[i].context == _view){
this.currentView = menus[i].comp;
}
}
},
btnforgot:function(){
this.bforgotpassphrase=true;
},
resize:function(){
//console.log(this.elappcontent);
if(this.elappcontent == null) return;
this.elcontent.style.height = (this.elappcontent.clientHeight - 2*24) + "px";
this.elcontent.style.width = (this.elappcontent.clientWidth) + "px";
},
}
}
</script>
<style>
#app{
height: 100%;
width: 100%;
}
</style>