Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohoblk-wap
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
陈峰
2018-01-18 21:06:56 +0800
Commit
36f814fe94dddff27c789e63666c62a3fb7b1959
2 parents
26a4c7b4
b9bc87a0
Merge branch 'master' into 'gray'
Master See merge request
!64
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
36 deletions
create-app.js
doraemon/middleware/ssr.js
package.json
process.json
public/vue/product/shop/shop-box.vue
yarn.lock
create-app.js
View file @
36f814f
...
...
@@ -35,7 +35,7 @@ yohoLib.global(config);
global
.
utils
=
path
.
resolve
(
'./utils'
);
global
.
doraemon
=
path
.
resolve
(
'./doraemon'
);
exports
.
createApp
=
(
app
)
=>
{
exports
.
createApp
=
async
(
app
)
=>
{
// 向模板注入变量
app
.
locals
.
devEnv
=
app
.
get
(
'env'
)
===
'development'
;
app
.
locals
.
proEnv
=
app
.
get
(
'env'
)
===
'production'
;
...
...
@@ -112,19 +112,24 @@ exports.createApp = (app) => {
app
.
use
(
ssrApi
());
app
.
use
(
layoutTools
());
require
(
'./doraemon/middleware/ssr'
)(
app
);
await
require
(
'./doraemon/middleware/ssr'
)(
app
);
require
(
'./dispatch'
)(
app
);
app
.
all
(
'*'
,
errorHanlder
.
notFound
());
// 404
// YOHO 后置中间件
app
.
use
(
errorHanlder
.
serverError
());
}
catch
(
err
)
{
logger
.
error
(
err
);
}
// listener
app
.
listen
(
config
.
port
,
function
()
{
logger
.
info
(
`
worker
is
started
at
$
{
config
.
port
}
`
);
});
}
catch
(
err
)
{
if
(
err
.
code
===
9999
)
{
logger
.
error
(
err
);
process
.
abort
();
}
logger
.
error
(
err
);
}
};
...
...
doraemon/middleware/ssr.js
View file @
36f814f
...
...
@@ -58,9 +58,15 @@ const render = (req, res, next) => {
return
res
.
send
(
html
);
});
};
if
(
!
isDev
)
{
Promise
.
all
([
const
loadBundle
=
async
(
errorCount
=
0
)
=>
{
if
(
!
isDev
)
{
if
(
errorCount
>
5
)
{
throw
{
code
:
9999
,
message
:
'ssr bundle download faild 5!'
};
}
await
Promise
.
all
([
rp
(
`
http
:
//cdn.yoho.cn/yohoblk-wap/bundle/yoho-ssr-server-${pkg.version}.json`, {json: true}),
rp
(
`
http
:
//cdn.yoho.cn/yohoblk-wap/bundle/yoho-ssr-client-${pkg.version}.json`, {json: true}),
]).
then
(
results
=>
{
...
...
@@ -70,6 +76,8 @@ if (!isDev) {
template
,
clientManifest
:
results
[
1
]
});
}).
catch
(()
=>
{
return
loadBundle
(
errorCount
+
1
);
});
// const serverBundle = require(`../../public/dist/yohoblk-wap/bundle/yoho-ssr-server-${pkg.version}.json`);
...
...
@@ -80,7 +88,9 @@ if (!isDev) {
// template,
// clientManifest
// });
}
}
};
const
ssrRender
=
isDev
?
(
req
,
res
,
next
)
=>
{
let
context
=
getContext
(
req
);
...
...
@@ -120,6 +130,7 @@ const routes = [
'/about'
];
module
.
exports
=
app
=>
{
module
.
exports
=
async
(
app
)
=>
{
await
loadBundle
();
_
.
each
(
routes
,
r
=>
app
.
get
(
r
,
ssrRender
));
};
...
...
package.json
View file @
36f814f
{
"name"
:
"yohoblk-wap"
,
"version"
:
"
92.0.22
"
,
"version"
:
"
2.0.28
"
,
"private"
:
true
,
"description"
:
"A New Yohobuy Project With Express"
,
"repository"
:
{
...
...
@@ -55,6 +55,20 @@
"yoho-md5"
:
"^2.0.0"
,
"yoho-node-lib"
:
"=0.5.21"
,
"yoho-qs"
:
"1.0.1"
,
"vue"
:
"^2.5.13"
,
"vue-server-renderer"
:
"^2.5.13"
,
"vue-awesome-swiper"
:
"^3.0.6"
,
"vue-hot-reload-api"
:
"^1.2.0"
,
"vue-html-loader"
:
"^1.2.4"
,
"vue-infinite-scroll"
:
"^2.0.1"
,
"vue-lazyload"
:
"^1.0.6"
,
"vue-loader"
:
"^13.7.0"
,
"vue-router"
:
"^3.0.1"
,
"vue-style-loader"
:
"^3.0.3"
,
"vue-swipe"
:
"^2.0.3"
,
"vue-template-compiler"
:
"^2.5.13"
,
"vue-touch"
:
"2.0.0-beta.3"
,
"vuex"
:
"^3.0.1"
,
"yoho-store"
:
"^1.3.20"
},
"devDependencies"
:
{
...
...
@@ -114,20 +128,6 @@
"stylelint-processor-html"
:
"^1.0.0"
,
"uglifyjs-webpack-plugin"
:
"^0.4.6"
,
"url-loader"
:
"^0.5.9"
,
"vue"
:
"^2.5.13"
,
"vue-awesome-swiper"
:
"^3.0.6"
,
"vue-hot-reload-api"
:
"^1.2.0"
,
"vue-html-loader"
:
"^1.2.4"
,
"vue-infinite-scroll"
:
"^2.0.1"
,
"vue-lazyload"
:
"^1.0.6"
,
"vue-loader"
:
"^13.7.0"
,
"vue-router"
:
"^3.0.1"
,
"vue-server-renderer"
:
"^2.5.13"
,
"vue-style-loader"
:
"^3.0.3"
,
"vue-swipe"
:
"^2.0.3"
,
"vue-template-compiler"
:
"^2.5.13"
,
"vue-touch"
:
"2.0.0-beta.3"
,
"vuex"
:
"^3.0.1"
,
"webpack"
:
"3.3"
,
"webpack-bundle-analyzer"
:
"^2.9.1"
,
"webpack-dashboard"
:
"^0.1.8"
,
...
...
process.json
View file @
36f814f
...
...
@@ -3,7 +3,7 @@
{
"name"
:
"yohoblk-wap"
,
"script"
:
"app.js"
,
"instances"
:
"
max
"
,
"instances"
:
"
4
"
,
"exec_mode"
:
"cluster"
,
"merge_logs"
:
true
,
"log_date_format"
:
"YYYY-MM-DD HH:mm:ss Z"
,
...
...
public/vue/product/shop/shop-box.vue
View file @
36f814f
...
...
@@ -89,7 +89,7 @@
productList: [],
inSearching: false,
enableOrder: false,
order: '',
order: '
s_t_desc
',
cartCount: 0
};
},
...
...
yarn.lock
View file @
36f814f
...
...
@@ -8908,7 +8908,7 @@ vue-router@^3.0.1:
vue-server-renderer@^2.5.13:
version "2.5.13"
resolved "http
s://registry.yarnpkg
.com/vue-server-renderer/-/vue-server-renderer-2.5.13.tgz#6a0d421a0fd3e2b7357b59495d744b7e9279d68e"
resolved "http
://npm.yohops
.com/vue-server-renderer/-/vue-server-renderer-2.5.13.tgz#6a0d421a0fd3e2b7357b59495d744b7e9279d68e"
dependencies:
chalk "^1.1.3"
hash-sum "^1.0.2"
...
...
@@ -8919,20 +8919,13 @@ vue-server-renderer@^2.5.13:
serialize-javascript "^1.3.0"
source-map "0.5.6"
vue-style-loader@^3.0.0:
vue-style-loader@^3.0.0
, vue-style-loader@^3.0.3
:
version "3.0.3"
resolved "http://npm.yoho.cn/vue-style-loader/-/vue-style-loader-3.0.3.tgz#623658f81506aef9d121cdc113a4f5c9cac32df7"
dependencies:
hash-sum "^1.0.2"
loader-utils "^1.0.2"
vue-style-loader@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/vue-style-loader/-/vue-style-loader-3.0.3.tgz#623658f81506aef9d121cdc113a4f5c9cac32df7"
dependencies:
hash-sum "^1.0.2"
loader-utils "^1.0.2"
vue-swipe@^0.2.7:
version "0.2.7"
resolved "http://npm.yoho.cn/vue-swipe/-/vue-swipe-0.2.7.tgz#4c23ee982953a2c7e96dace55b1fafde518ab719"
...
...
Please
register
or
login
to post a comment