Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
quantum-blocks-h5
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
quantum-blocks-h5
Commits
b427abc1
Commit
b427abc1
authored
Oct 18, 2022
by
Xuguangxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 处理时区偏移问题
parent
01de9870
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
14 deletions
+8
-14
activity.ts
app/controller/activity.ts
+2
-8
app.ts
app/web/framework/app.ts
+1
-1
index.ts
app/web/page/activity/view/activity/index.ts
+3
-2
index.vue
app/web/page/activity/view/activity/index.vue
+0
-1
index.ts
app/web/page/store/index.ts
+2
-2
No files found.
app/controller/activity.ts
View file @
b427abc1
...
@@ -6,14 +6,8 @@ export default class ActivityController extends Controller {
...
@@ -6,14 +6,8 @@ export default class ActivityController extends Controller {
// 开发环境不走redis缓存
// 开发环境不走redis缓存
const
apollo
=
ctx
.
app
.
config
.
apollo
||
{};
const
apollo
=
ctx
.
app
.
config
.
apollo
||
{};
let
body
=
''
;
let
body
=
''
;
// 获取服务器端当前时间,用于与页面有效期做对比
const
currentTime
=
new
Date
().
getTime
();
const
offsetTime
=
new
Date
(
currentTime
).
getTimezoneOffset
()
*
60
*
1000
;
// console.log(currentTime, offsetTime);
const
serverTimeStamp
=
currentTime
-
offsetTime
;
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
body
=
await
ctx
.
renderToHtml
(
'
activity.js
'
,
{
url
:
ctx
.
url
,
apollo
,
serverTimeStamp
});
body
=
await
ctx
.
renderToHtml
(
'
activity.js
'
,
{
url
:
ctx
.
url
,
apollo
});
}
else
{
}
else
{
const
redisKey
=
`quantum-blocks:page:
${
ctx
.
params
.
id
}
`
;
const
redisKey
=
`quantum-blocks:page:
${
ctx
.
params
.
id
}
`
;
body
=
await
ctx
.
service
.
redis
.
get
(
redisKey
);
body
=
await
ctx
.
service
.
redis
.
get
(
redisKey
);
...
@@ -21,7 +15,7 @@ export default class ActivityController extends Controller {
...
@@ -21,7 +15,7 @@ export default class ActivityController extends Controller {
ctx
.
logger
.
info
(
'
请求redis成功 key: %j
'
,
redisKey
);
ctx
.
logger
.
info
(
'
请求redis成功 key: %j
'
,
redisKey
);
}
}
if
(
!
body
)
{
if
(
!
body
)
{
body
=
await
ctx
.
renderToHtml
(
'
activity.js
'
,
{
url
:
ctx
.
url
,
apollo
,
serverTimeStamp
});
body
=
await
ctx
.
renderToHtml
(
'
activity.js
'
,
{
url
:
ctx
.
url
,
apollo
});
await
ctx
.
service
.
redis
.
set
(
redisKey
,
body
);
await
ctx
.
service
.
redis
.
set
(
redisKey
,
body
);
}
}
}
}
...
...
app/web/framework/app.ts
View file @
b427abc1
...
@@ -93,7 +93,7 @@ export default class App {
...
@@ -93,7 +93,7 @@ export default class App {
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
router
.
onReady
(()
=>
{
router
.
onReady
(()
=>
{
this
.
fetch
(
vm
).
then
(()
=>
{
this
.
fetch
(
vm
).
then
(()
=>
{
context
.
state
=
{...
store
.
state
,
apollo
:
context
.
state
.
apollo
||
{}
,
serverTimestamp
:
context
.
state
.
serverTimeStamp
};
context
.
state
=
{...
store
.
state
,
apollo
:
context
.
state
.
apollo
||
{}};
return
resolve
(
new
Vue
(
vm
));
return
resolve
(
new
Vue
(
vm
));
});
});
});
});
...
...
app/web/page/activity/view/activity/index.ts
View file @
b427abc1
...
@@ -31,7 +31,6 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle
...
@@ -31,7 +31,6 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle
@
State
(
state
=>
state
.
activity
.
pageInfo
.
appLoginState
)
appLoginState
;
@
State
(
state
=>
state
.
activity
.
pageInfo
.
appLoginState
)
appLoginState
;
@
State
(
state
=>
state
.
activity
.
pageInfo
.
tenantId
)
tenantId
;
@
State
(
state
=>
state
.
activity
.
pageInfo
.
tenantId
)
tenantId
;
@
State
(
state
=>
state
.
activity
.
gridLayout
.
rowHeight
)
rowHeight
;
@
State
(
state
=>
state
.
activity
.
gridLayout
.
rowHeight
)
rowHeight
;
@
State
(
state
=>
state
.
serverTimestamp
)
serverTimestamp
;
@
Mutation
(
'
SET_PAGE_ELEMENTS
'
)
setPageElement
;
@
Mutation
(
'
SET_PAGE_ELEMENTS
'
)
setPageElement
;
@
Mutation
(
'
UPDATE_APP_LOGIN_STATE
'
)
updateAppLoginState
;
@
Mutation
(
'
UPDATE_APP_LOGIN_STATE
'
)
updateAppLoginState
;
...
@@ -154,11 +153,13 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle
...
@@ -154,11 +153,13 @@ export default class Activity extends Mixins(TransformStyleMixin, BottomNavStyle
}
}
comparePageTime
()
{
comparePageTime
()
{
const
{
validStartTime
,
validEndTime
}
=
this
.
pageInfo
;
const
{
validStartTime
,
validEndTime
}
=
this
.
pageInfo
;
// 获取服务器端当前时间,用于与页面有效期做对比
const
currentTime
=
new
Date
().
getTime
();
if
(
validStartTime
&&
validEndTime
)
{
if
(
validStartTime
&&
validEndTime
)
{
// todo 当设置了页面的有效时间起止,用当前服务器返回的时间作对比,判断页面是否在有效期内
// todo 当设置了页面的有效时间起止,用当前服务器返回的时间作对比,判断页面是否在有效期内
const
startTime
=
new
Date
(
validStartTime
).
getTime
();
const
startTime
=
new
Date
(
validStartTime
).
getTime
();
const
endTime
=
new
Date
(
validEndTime
).
getTime
();
const
endTime
=
new
Date
(
validEndTime
).
getTime
();
if
(
this
.
serverTimestamp
<
startTime
||
this
.
serverTimestamp
>
endTime
)
{
if
(
currentTime
<
startTime
||
currentTime
>
endTime
)
{
this
.
pageInvalid
=
true
;
this
.
pageInvalid
=
true
;
}
}
}
}
...
...
app/web/page/activity/view/activity/index.vue
View file @
b427abc1
<
template
>
<
template
>
<div
class=
"pageContent"
>
<div
class=
"pageContent"
>
{{
serverTimestamp
}}
<div
class=
"activity"
:class=
"
{hasBottomNav: navigatorConfig}" :style="transformStyle(pageData.commonStyle)">
<div
class=
"activity"
:class=
"
{hasBottomNav: navigatorConfig}" :style="transformStyle(pageData.commonStyle)">
<template
v-if=
"!noPageData && tenantIdCorrect"
>
<template
v-if=
"!noPageData && tenantIdCorrect"
>
<div
class=
"layout"
>
<div
class=
"layout"
>
...
...
app/web/page/store/index.ts
View file @
b427abc1
...
@@ -7,8 +7,8 @@ import Activity from './modules/activity';
...
@@ -7,8 +7,8 @@ import Activity from './modules/activity';
Vue
.
use
(
Vuex
);
Vue
.
use
(
Vuex
);
export
default
function
createStore
(
initState
:
any
=
{})
{
export
default
function
createStore
(
initState
:
any
=
{})
{
const
{
title
,
url
,
origin
,
locale
,
csrf
,
activity
,
serverTimestamp
}
=
initState
;
const
{
title
,
url
,
origin
,
locale
,
csrf
,
activity
}
=
initState
;
const
state
=
{
title
,
url
,
origin
,
locale
,
csrf
,
serverTimestamp
};
const
state
=
{
title
,
url
,
origin
,
locale
,
csrf
};
return
new
Vuex
.
Store
<
RootState
>
({
return
new
Vuex
.
Store
<
RootState
>
({
state
,
state
,
modules
:
{
modules
:
{
...
...
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