Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
K
kiaisoft_tuananh_nuxt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TTS Tran Viet Anh
kiaisoft_tuananh_nuxt
Commits
a1ee6e9e
Commit
a1ee6e9e
authored
Jan 03, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add middleware home
parent
d1a55c84
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
11 deletions
+14
-11
nav.vue
components/nav.vue
+3
-1
web.js
middleware/web.js
+6
-7
nuxt.config.js
nuxt.config.js
+3
-3
index.vue
pages/home/index.vue
+2
-0
No files found.
components/nav.vue
View file @
a1ee6e9e
...
...
@@ -54,8 +54,10 @@ export default {
token
:
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
),
}),
});
localStorage
.
removeItem
(
"
token
"
);
localStorage
.
setItem
(
"
token
"
,
''
);
this
.
$auth
.
$storage
.
setUniversal
(
"
loggedIn
"
,
'
false
'
);
this
.
$auth
.
$storage
.
setUniversal
(
"
token
"
,
''
);
this
.
$auth
.
$storage
.
setUniversal
(
"
userName
"
,
''
);
this
.
$router
.
push
(
"
/
"
);
},
},
...
...
middleware/web.js
View file @
a1ee6e9e
const
token_access
=
localStorage
.
getItem
(
'
token
'
);
export
default
function
({
redirect
})
{
if
(
!
token_access
)
{
// this.$router.push('/')
console
.
log
(
'
[LOG]: running ...
'
);
}
export
default
({
redirect
})
=>
{
console
.
log
(
'
[LOG]: middleware is running ...
'
)
if
(
localStorage
.
getItem
(
"
token
"
)
==
""
)
{
return
redirect
(
'
/
'
)
}
};
\ No newline at end of file
nuxt.config.js
View file @
a1ee6e9e
...
...
@@ -57,7 +57,7 @@ export default {
// Build Configuration: https://go.nuxtjs.dev/config-build
build
:
{
},
router
:
{
middleware
:
'
web
'
}
//
router: {
//
middleware: 'web'
//
}
}
pages/home/index.vue
View file @
a1ee6e9e
...
...
@@ -22,8 +22,10 @@ import Footer from "@/components/footer";
export
default
{
components
:
{
Nav
},
components
:
{
Footer
},
middleware
:
[
'
web
'
],
};
</
script
>
<
style
></
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment