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