Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-community-web
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
yyq
6 years ago
Commit
0cf5aa61cfbd453d93cbd29e3cb8c10b1143602b
1 parent
c68a2743
fix init header top height
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
27 deletions
apps/app.js
apps/entry-client.js
apps/store/index.js
apps/store/yoho/index.js
apps/utils/init-client.js
apps/app.js
View file @
0cf5aa6
...
...
@@ -20,10 +20,9 @@ Vue.mixin(titleMixin);
dayjs
.
locale
(
'zh-cn'
);
dayjs
.
extend
(
relativeTime
);
export
function
createApp
(
context
)
{
export
function
createApp
(
context
,
state
=
{}
)
{
const
router
=
createRouter
();
const
store
=
createStore
(
context
);
const
store
=
createStore
(
context
,
state
);
const
app
=
new
Vue
({
router
,
...
...
apps/entry-client.js
View file @
0cf5aa6
...
...
@@ -13,7 +13,7 @@ import Lazy from 'vue-lazyload';
import
yoho
from
'common/yoho'
;
import
sdk
from
'common/sdk'
;
import
links
from
'utils/links'
;
import
InitClient
from
'utils/init-client'
;
import
{
initClient
,
getYohoState
}
from
'utils/init-client'
;
import
'statics/scss/common.scss'
;
import
'statics/scss/grass-prompt.scss'
;
import
'statics/font/iconfont.css'
;
...
...
@@ -22,7 +22,7 @@ const $app = document.getElementById('app');
const
isDegrade
=
Boolean
(
!
(
$app
&&
$app
.
attributes
[
'data-server-rendered'
]));
const
context
=
get
(
window
,
'__INITIAL_STATE__.yoho.context'
);
const
{
app
,
router
,
store
}
=
createApp
(
context
);
const
{
app
,
router
,
store
}
=
createApp
(
context
,
{
yoho
:
getYohoState
()}
);
if
(
window
.
__INITIAL_STATE__
)
{
store
.
replaceState
(
window
.
__INITIAL_STATE__
);
...
...
@@ -51,7 +51,7 @@ Vue.use(ActionSheet);
Vue
.
prop
(
'api'
,
createApi
(
context
,
store
));
Vue
.
use
(
Lazy
,
{
error
:
''
});
I
nitClient
(
store
);
i
nitClient
(
store
);
const
trackPage
=
(
path
)
=>
{
if
(
window
.
_hmt
)
{
...
...
apps/store/index.js
View file @
0cf5aa6
...
...
@@ -9,11 +9,11 @@ import storeProduct from './product';
Vue
.
use
(
Vuex
);
export
function
createStore
(
context
)
{
export
function
createStore
(
context
,
state
=
{}
)
{
const
store
=
new
Vuex
.
Store
({
namespaced
:
true
,
modules
:
{
yoho
:
storeYoho
(),
yoho
:
storeYoho
(
state
.
yoho
),
article
:
storeArticle
(),
user
:
storeUser
(),
comment
:
storeComment
(),
...
...
apps/store/yoho/index.js
View file @
0cf5aa6
import
*
as
Types
from
'./types'
;
import
cookie
from
'yoho-cookie'
;
import
{
merge
}
from
'lodash'
;
export
default
function
()
{
export
default
function
(
state
=
{}
)
{
return
{
state
:
{
state
:
merge
(
{
context
:
{
title
:
''
,
env
:
{
...
...
@@ -29,7 +30,7 @@ export default function() {
historys
:
[],
direction
:
'forword'
,
homePage
:
true
},
},
state
),
mutations
:
{
[
Types
.
SET_SERVER_INFO
](
state
,
{
context
})
{
state
.
context
.
title
=
context
.
title
;
...
...
apps/utils/init-client.js
View file @
0cf5aa6
...
...
@@ -3,11 +3,34 @@ import cookie from 'yoho-cookie';
import
yoho
from
'common/yoho'
;
import
version
from
'utils/version'
;
export
default
store
=>
{
const
setStatusBar
=
(
width
,
height
,
store
)
=>
{
const
statusBar
=
{
statusBarStatus
:
false
,
statusBarHeight
:
0
,
};
// 仅支持ios
if
(
yoho
.
isYohoBuy
&&
yoho
.
isiOS
)
{
statusBar
.
statusBarHeight
=
(
height
/
width
)
>
2.1
?
44
:
22
;
store
&&
store
.
commit
(
'SET_STATUS_BAR_HEIGHT'
,
{
height
:
statusBar
.
statusBarHeight
});
if
(
version
(
cookie
.
get
(
'app_version'
),
' 6.9.2'
)
>=
0
)
{
statusBar
.
statusBarStatus
=
true
;
store
&&
store
.
commit
(
'SET_STATUS_BAR_STATUS'
,
{
status
:
true
});
}
}
return
statusBar
;
};
const
initClient
=
(
store
)
=>
{
window
.
onresize
=
()
=>
{
const
{
clientWidth
,
clientHeight
}
=
document
.
body
;
store
.
commit
(
'SET_WINDOW_SIZE'
,
{
clientWidth
,
clientHeight
});
setStatusBar
(
clientWidth
,
clientHeight
);
setStatusBar
(
clientWidth
,
clientHeight
,
store
);
};
const
{
clientWidth
,
clientHeight
}
=
document
.
body
;
...
...
@@ -34,20 +57,7 @@ export default store => {
}
});
function
setStatusBar
(
width
,
height
)
{
// 仅支持ios
if
(
yoho
.
isYohoBuy
&&
yoho
.
isiOS
)
{
store
.
commit
(
'SET_STATUS_BAR_HEIGHT'
,
{
height
:
(
height
/
width
)
>
2.1
?
44
:
22
});
if
(
version
(
cookie
.
get
(
'app_version'
),
' 6.9.2'
)
>=
0
)
{
store
.
commit
(
'SET_STATUS_BAR_STATUS'
,
{
status
:
true
});
}
}
}
setStatusBar
(
clientWidth
,
clientHeight
);
setStatusBar
(
clientWidth
,
clientHeight
,
store
);
if
(
/yoho/i
.
test
(
navigator
.
userAgent
)
&&
/supportWebp/i
.
test
(
navigator
.
userAgent
))
{
store
.
commit
(
'SET_SUPPORT_WEBP'
,
{
supportWebp
:
true
});
...
...
@@ -74,3 +84,24 @@ export default store => {
});
});
};
const
getYohoState
=
()
=>
{
const
{
clientWidth
,
clientHeight
}
=
document
.
body
;
return
{
context
:
{
env
:
{
isApp
:
yoho
.
isApp
,
isiOS
:
yoho
.
isiOS
,
isAndroid
:
yoho
.
isAndroid
,
isYohoBuy
:
yoho
.
isYohoBuy
}
},
window
:
setStatusBar
(
clientWidth
,
clientHeight
)
}
};
export
{
initClient
,
getYohoState
};
...
...
Please
register
or
login
to post a comment