Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sample
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
周韬
node-sample
Commits
ee378d2c
Commit
ee378d2c
authored
Jun 04, 2017
by
Pooya Parsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add titles
parent
a8947de1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
45 deletions
+53
-45
_page.vue
pages/_type/_page.vue
+5
-0
_id.vue
pages/item/_id.vue
+16
-13
_id.vue
pages/user/_id.vue
+32
-32
No files found.
pages/_type/_page.vue
View file @
ee378d2c
...
@@ -33,6 +33,11 @@
...
@@ -33,6 +33,11 @@
components
:
{
components
:
{
Item
Item
},
},
head
()
{
return
{
title
:
camelize
(
this
.
$route
.
params
.
type
)
}
},
data
()
{
data
()
{
return
{
return
{
transition
:
'slide-right'
,
transition
:
'slide-right'
,
...
...
pages/item/_id.vue
View file @
ee378d2c
...
@@ -10,7 +10,8 @@
...
@@ -10,7 +10,8 @@
</span>
</span>
<p
class=
"meta"
>
<p
class=
"meta"
>
{{
item
.
score
}}
points
{{
item
.
score
}}
points
| by
<router-link
:to=
"'/user/' + item.by"
>
{{
item
.
by
}}
</router-link>
| by
<router-link
:to=
"'/user/' + item.by"
>
{{
item
.
by
}}
</router-link>
{{
item
.
time
|
timeAgo
}}
ago
{{
item
.
time
|
timeAgo
}}
ago
</p>
</p>
</div>
</div>
...
@@ -33,14 +34,20 @@
...
@@ -33,14 +34,20 @@
export
default
{
export
default
{
name
:
'item-view'
,
name
:
'item-view'
,
components
:
{
Spinner
,
Comment
},
components
:
{
Spinner
,
Comment
},
data
:
()
=>
({
data
:
()
=>
({
loading
:
true
loading
:
true
}),
}),
head
()
{
return
{
title
:
this
.
item
.
title
}
},
computed
:
{
computed
:
{
item
()
{
item
()
{
return
this
.
$store
.
state
.
items
[
this
.
$route
.
params
.
id
]
return
this
.
$store
.
state
.
items
[
this
.
$route
.
params
.
id
]
}
}
},
},
...
@@ -48,16 +55,12 @@
...
@@ -48,16 +55,12 @@
// We only fetch the item itself before entering the view, because
// We only fetch the item itself before entering the view, because
// it might take a long time to load threads with hundreds of comments
// it might take a long time to load threads with hundreds of comments
// due to how the HN Firebase API works.
// due to how the HN Firebase API works.
asyncData
({
store
,
route
:
{
params
:
{
id
}}})
{
asyncData
({
store
,
route
:
{
params
:
{
id
}}})
{
return
store
.
dispatch
(
'FETCH_ITEMS'
,
{
ids
:
[
id
]
})
return
store
.
dispatch
(
'FETCH_ITEMS'
,
{
ids
:
[
id
]})
},
title
()
{
return
this
.
item
.
title
},
},
// Fetch comments when mounted on the client
// Fetch comments when mounted on the client
beforeMount
()
{
beforeMount
()
{
this
.
fetchComments
()
this
.
fetchComments
()
},
},
...
@@ -67,7 +70,7 @@
...
@@ -67,7 +70,7 @@
},
},
methods
:
{
methods
:
{
fetchComments
()
{
fetchComments
()
{
this
.
loading
=
true
this
.
loading
=
true
fetchComments
(
this
.
$store
,
this
.
item
).
then
(()
=>
{
fetchComments
(
this
.
$store
,
this
.
item
).
then
(()
=>
{
this
.
loading
=
false
this
.
loading
=
false
...
@@ -77,7 +80,7 @@
...
@@ -77,7 +80,7 @@
}
}
// recursively fetch all descendent comments
// recursively fetch all descendent comments
function
fetchComments
(
store
,
item
)
{
function
fetchComments
(
store
,
item
)
{
if
(
item
&&
item
.
kids
)
{
if
(
item
&&
item
.
kids
)
{
return
store
.
dispatch
(
'FETCH_ITEMS'
,
{
return
store
.
dispatch
(
'FETCH_ITEMS'
,
{
ids
:
item
.
kids
ids
:
item
.
kids
...
@@ -92,7 +95,7 @@
...
@@ -92,7 +95,7 @@
.item-view-header
.item-view-header
background-color #fff
background-color #fff
padding 1.8em 2em 1em
padding 1.8em 2em 1em
box-shadow 0 1px 2px rgba(0,
0,0,
.1)
box-shadow 0 1px 2px rgba(0,
0, 0,
.1)
h1
h1
display inline
display inline
font-size 1.5em
font-size 1.5em
...
...
pages/user/_id.vue
View file @
ee378d2c
...
@@ -20,43 +20,43 @@
...
@@ -20,43 +20,43 @@
<
script
>
<
script
>
export
default
{
export
default
{
name
:
'user-view'
,
name
:
'user-view'
,
computed
:
{
computed
:
{
user
()
{
user
()
{
return
this
.
$store
.
state
.
users
[
this
.
$route
.
params
.
id
]
return
this
.
$store
.
state
.
users
[
this
.
$route
.
params
.
id
]
}
}
},
},
asyncData
({
store
,
route
:
{
params
:
{
id
}}})
{
head
()
{
return
store
.
dispatch
(
'FETCH_USER'
,
{
id
})
return
{
},
title
:
this
.
user
.
id
||
'User not found'
}
},
title
()
{
fetch
({
store
,
route
:
{
params
:
{
id
}}})
{
return
this
.
user
return
store
.
dispatch
(
'FETCH_USER'
,
{
id
})
?
this
.
user
.
id
},
:
'User not found'
}
}
}
</
script
>
</
script
>
<
style
lang=
"stylus"
>
<
style
lang=
"stylus"
>
.user-view
.user-view
background-color #fff
background-color #fff
box-sizing border-box
box-sizing border-box
padding 2em 3em
padding 2em 3em
h1
h1
margin 0
margin 0
font-size 1.5em
font-size 1.5em
.meta
.meta
list-style-type none
list-style-type none
padding 0
padding 0
.label
.label
display inline-block
display inline-block
min-width 4em
min-width 4em
.about
.about
margin 1em 0
margin 1em 0
.links a
.links a
text-decoration underline
text-decoration underline
</
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