|
@@ -166,7 +166,7 @@
|
|
|
<a class="nav-link active btn-login" aria-current="page" href="login.html" set-lan="html:login">登入</a>
|
|
|
</li>
|
|
|
<li class="nav-item">
|
|
|
- <a class="nav-link btn-userProfile" aria-current="page" href="user_profile2.html" set-lan="html:user_profile">會員資料</a>
|
|
|
+ <a class="nav-link btn-userProfile" aria-current="page" href="user_profile2.html" set-lan="html:user_profile" style="color:blue;">會員資料</a>
|
|
|
</li>
|
|
|
<li class="nav-item">
|
|
|
<a class="nav-link btn-logout" aria-current="page" set-lan="html:logout">登出</a>
|
|
@@ -269,25 +269,27 @@
|
|
|
<script type="text/javascript" src="static/lan.js"></script>
|
|
|
<script src="static/common.js"></script>
|
|
|
<script>
|
|
|
- const btnLoginPage = document.querySelector('.btn-login');
|
|
|
- const btnUserProfile = document.querySelector('.btn-userProfile');
|
|
|
- const btnLogout = document.querySelector('.btn-logout');
|
|
|
- btnLoginPage.style.display = 'none';
|
|
|
- btnLogout.style.display = 'none';
|
|
|
- btnUserProfile.style.display = 'none';
|
|
|
+ $('.btn-login').hide();
|
|
|
+ $('.btn-userProfile').hide();
|
|
|
+ $('.btn-logout').hide();
|
|
|
function get_jwt_token(){
|
|
|
if(!document.cookie) {
|
|
|
return
|
|
|
}
|
|
|
- jwt_raw = document.cookie.split(';').filter(s=>s.includes('jwt_token'))[0]
|
|
|
- return jwt_raw.split('=')[1]
|
|
|
+ try {
|
|
|
+ jwt_raw = document.cookie.split(';').filter(s=>s.includes('jwt_token'))[0];
|
|
|
+ return jwt_raw.split('=')[1];
|
|
|
+ } catch (e) {
|
|
|
+ return undefined;
|
|
|
+ }
|
|
|
}
|
|
|
function checkRoute() {
|
|
|
let jwt_token = get_jwt_token();
|
|
|
if(jwt_token == undefined) {
|
|
|
- btnLoginPage.style.display = 'block';
|
|
|
- btnLogout.style.display = 'none';
|
|
|
- btnUserProfile.style.display = 'none';
|
|
|
+ console.log(jwt_token); // test
|
|
|
+ $('.btn-login').show();
|
|
|
+ $('.btn-userProfile').hide();
|
|
|
+ $('.btn-logout').hide();
|
|
|
return;
|
|
|
}
|
|
|
axios({
|
|
@@ -300,13 +302,13 @@
|
|
|
}).then(res => {
|
|
|
console.log(res.data);
|
|
|
if(res.status !== 200) {
|
|
|
- btnLoginPage.style.display = 'block';
|
|
|
- btnLogout.style.display = 'none';
|
|
|
- btnUserProfile.style.display = 'none';
|
|
|
+ $('.btn-login').show();
|
|
|
+ $('.btn-userProfile').hide();
|
|
|
+ $('.btn-logout').hide();
|
|
|
}
|
|
|
- btnLoginPage.style.display = 'none';
|
|
|
- btnLogout.style.display = 'block';
|
|
|
- btnUserProfile.style.display = 'block';
|
|
|
+ $('.btn-login').hide();
|
|
|
+ $('.btn-userProfile').show();
|
|
|
+ $('.btn-logout').show();
|
|
|
}).catch(err => {
|
|
|
console.log(err);
|
|
|
});
|