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
0253ebcc
Commit
0253ebcc
authored
Apr 22, 2017
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small tweaks
parent
ad310a94
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
21 deletions
+15
-21
webpack.base.config.js
build/webpack.base.config.js
+4
-3
webpack.client.config.js
build/webpack.client.config.js
+0
-6
entry-client.js
src/entry-client.js
+1
-1
entry-server.js
src/entry-server.js
+3
-4
CreateListView.js
src/views/CreateListView.js
+1
-1
ItemView.vue
src/views/ItemView.vue
+3
-3
UserView.vue
src/views/UserView.vue
+3
-3
No files found.
build/webpack.base.config.js
View file @
0253ebcc
const
path
=
require
(
'path'
)
const
webpack
=
require
(
'webpack'
)
const
vueConfig
=
require
(
'./vue-loader.config'
)
const
FriendlyErrorsPlugin
=
require
(
'friendly-errors-webpack-plugin'
)
...
...
@@ -48,7 +49,7 @@ module.exports = {
maxEntrypointSize
:
300000
,
hints
:
isProd
?
'warning'
:
false
},
plugins
:
isProd
?
[]
:
[
new
FriendlyErrorsPlugin
()
]
plugins
:
isProd
?
[
new
webpack
.
optimize
.
UglifyJsPlugin
({
compress
:
{
warnings
:
false
}})]
:
[
new
FriendlyErrorsPlugin
()
]
}
build/webpack.client.config.js
View file @
0253ebcc
...
...
@@ -39,12 +39,6 @@ const config = merge(base, {
if
(
process
.
env
.
NODE_ENV
===
'production'
)
{
config
.
plugins
.
push
(
// minify JS
new
webpack
.
optimize
.
UglifyJsPlugin
({
compress
:
{
warnings
:
false
}
}),
// auto generate service worker
new
SWPrecachePlugin
({
cacheId
:
'vue-hn'
,
...
...
src/entry-client.js
View file @
0253ebcc
...
...
@@ -9,7 +9,7 @@ Vue.mixin({
if
(
fetchData
)
{
this
.
dataPromise
=
fetchData
(
this
.
$store
,
this
.
$route
.
params
this
.
$route
)
}
}
...
...
src/entry-server.js
View file @
0253ebcc
...
...
@@ -8,11 +8,10 @@ const isDev = process.env.NODE_ENV !== 'production'
// Since data fetching is async, this function is expected to
// return a Promise that resolves to the app instance.
export
default
context
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
s
=
isDev
&&
Date
.
now
()
const
{
app
,
router
,
store
}
=
createApp
()
return
new
Promise
((
resolve
,
reject
)
=>
{
// set router's location
router
.
push
(
context
.
url
)
...
...
@@ -30,7 +29,7 @@ export default context => {
Promise
.
all
(
matchedComponents
.
map
(
component
=>
{
return
component
.
fetchData
&&
component
.
fetchData
(
store
,
router
.
currentRoute
.
params
,
router
.
currentRoute
,
context
)
})).
then
(()
=>
{
...
...
@@ -44,6 +43,6 @@ export default context => {
context
.
state
=
store
.
state
resolve
(
app
)
}).
catch
(
reject
)
})
}
,
reject
)
})
}
src/views/CreateListView.js
View file @
0253ebcc
...
...
@@ -10,7 +10,7 @@ export default function createListView (type) {
return
{
name
:
`
${
type
}
-stories-view`
,
fetchData
(
store
,
params
,
context
)
{
fetchData
(
store
,
route
,
context
)
{
return
store
.
dispatch
(
'FETCH_LIST_DATA'
,
{
type
}).
then
(()
=>
{
setTitle
(
camelize
(
type
),
context
)
})
...
...
src/views/ItemView.vue
View file @
0253ebcc
...
...
@@ -46,9 +46,9 @@ export default {
}
},
fetchData
(
store
,
params
,
context
)
{
return
store
.
dispatch
(
'FETCH_ITEMS'
,
{
ids
:
[
params
.
id
]
}).
then
(()
=>
{
const
item
=
store
.
state
.
items
[
params
.
id
]
fetchData
(
store
,
{
params
:
{
id
}}
,
context
)
{
return
store
.
dispatch
(
'FETCH_ITEMS'
,
{
ids
:
[
id
]
}).
then
(()
=>
{
const
item
=
store
.
state
.
items
[
id
]
setTitle
(
item
.
title
,
context
)
})
},
...
...
src/views/UserView.vue
View file @
0253ebcc
...
...
@@ -30,9 +30,9 @@ export default {
}
},
fetchData
(
store
,
params
,
context
)
{
return
store
.
dispatch
(
'FETCH_USER'
,
{
id
:
params
.
id
}).
then
(()
=>
{
const
user
=
store
.
state
.
users
[
params
.
id
]
fetchData
(
store
,
{
params
:
{
id
}}
,
context
)
{
return
store
.
dispatch
(
'FETCH_USER'
,
{
id
}).
then
(()
=>
{
const
user
=
store
.
state
.
users
[
id
]
setTitle
(
user
.
id
,
context
)
})
}
...
...
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