路由更新,crosrToken接口增加
This commit is contained in:
parent
733e548068
commit
b80c991378
|
@ -10,6 +10,7 @@ import UserList from '@/html/UserList.vue';
|
||||||
import Home from '@/html/Home.vue';
|
import Home from '@/html/Home.vue';
|
||||||
import DataStatistics from '@/html/DataStatistics.vue';
|
import DataStatistics from '@/html/DataStatistics.vue';
|
||||||
import Cameras from '@/components/Cameras.vue';
|
import Cameras from '@/components/Cameras.vue';
|
||||||
|
import Settings from '@/components/Settings.vue';
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
|
@ -65,6 +66,12 @@ const routes = [
|
||||||
name: 'Cameras',
|
name: 'Cameras',
|
||||||
component: Cameras,
|
component: Cameras,
|
||||||
meta: { requiresAuth: true }
|
meta: { requiresAuth: true }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path:'/settings',
|
||||||
|
name: 'Settings',
|
||||||
|
component: Settings,
|
||||||
|
meta: { requiresAuth: true }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -382,17 +382,24 @@ class BoxApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _authHeader(token: string | null = null): object {
|
private _authHeader(token: string | null = null): object {
|
||||||
// const access_token = token === "" ? this.token : token;
|
const accessToken = token || this.token || localStorage.getItem('alertToken') || "";
|
||||||
const alertToken = localStorage.getItem(`alertToken`) || token || this.token || "" || "";
|
|
||||||
return {
|
return {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Authorization': `Bearer ${alertToken}`,
|
'Authorization': `Bearer ${accessToken}`,
|
||||||
// 'Cookie': `jwt=${access_token}`
|
// 'X-CSRFToken': this.getCsrfToken()
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
private getCsrfToken(): string {
|
||||||
|
const cookie = document.cookie.split(';').find(cookie => cookie.trim().startsWith('csrftoken='));
|
||||||
|
if (cookie) {
|
||||||
|
return cookie.split('=')[1];
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private _boxAddr() {
|
private _boxAddr() {
|
||||||
return window.location.host.replace(/:\d+/, "");
|
return window.location.host.replace(/:\d+/, "");
|
||||||
|
|
Loading…
Reference in New Issue