mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 03:01:12 +00:00
perf: 优化时间组件
This commit is contained in:
parent
912d229bdd
commit
f586938fe9
7
resources/assets/js/functions/common.js
vendored
7
resources/assets/js/functions/common.js
vendored
@ -1890,12 +1890,17 @@ const timezone = require("dayjs/plugin/timezone");
|
|||||||
/**
|
/**
|
||||||
* 设置时区
|
* 设置时区
|
||||||
* @param tz
|
* @param tz
|
||||||
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
setTimezone(tz) {
|
setTimezone(tz) {
|
||||||
const local = $A.dayjs().startOf('hour');
|
const local = $A.dayjs().startOf('hour');
|
||||||
const server = local.tz(tz);
|
const server = local.tz(tz);
|
||||||
$A.timezoneDifference = local.startOf('hour').diff(server.format("YYYY-MM-DD HH:mm:ss"), 'hour')
|
return $A.timezoneDifference = local.startOf('hour').diff(server.format("YYYY-MM-DD HH:mm:ss"), 'hour')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本地时间与服务器时间差(小时)
|
||||||
|
*/
|
||||||
timezoneDifference: 0,
|
timezoneDifference: 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
<div class="dashboard-hello">{{$L('欢迎您,' + userInfo.nickname)}}</div>
|
<div class="dashboard-hello">{{$L('欢迎您,' + userInfo.nickname)}}</div>
|
||||||
<div class="dashboard-desc">
|
<div class="dashboard-desc">
|
||||||
{{$L('以下是你当前的任务统计数据')}}
|
{{$L('以下是你当前的任务统计数据')}}
|
||||||
|
<template v-if="systemConfig.timezoneDifference">, {{$L('服务器时间')}}: {{$A.dayjs().subtract(systemConfig.timezoneDifference, 'hour').format('YYYY-MM-DD HH:mm:ss')}}</template>
|
||||||
<transition name="dashboard-load">
|
<transition name="dashboard-load">
|
||||||
<div v-if="loadDashboardTasks" class="dashboard-load"><Loading/></div>
|
<div v-if="loadDashboardTasks" class="dashboard-load"><Loading/></div>
|
||||||
</transition>
|
</transition>
|
||||||
@ -129,7 +130,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['userInfo', 'userIsAdmin', 'cacheTasks', 'taskCompleteTemps', 'loadDashboardTasks']),
|
...mapState(['systemConfig', 'userInfo', 'userIsAdmin', 'cacheTasks', 'taskCompleteTemps', 'loadDashboardTasks']),
|
||||||
|
|
||||||
...mapGetters(['dashboardTask', 'assistTask', 'transforTasks']),
|
...mapGetters(['dashboardTask', 'assistTask', 'transforTasks']),
|
||||||
|
|
||||||
@ -203,17 +204,23 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
scrollTo(type) {
|
scrollTo(type) {
|
||||||
let refs = this.$refs[`type_${type}`]
|
const refs = this.$refs[`type_${type}`]
|
||||||
if (refs) {
|
if (refs) {
|
||||||
$A.scrollToView(refs[0], {
|
const index = this.hiddenColumns.indexOf(type);
|
||||||
behavior: 'smooth',
|
if (index !== -1) {
|
||||||
inline: 'end',
|
this.hiddenColumns.splice(index, 1)
|
||||||
});
|
}
|
||||||
|
this.$nextTick(_ => {
|
||||||
|
$A.scrollToView(refs[0], {
|
||||||
|
behavior: 'smooth',
|
||||||
|
inline: 'end',
|
||||||
|
});
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onDashboardHidden(type) {
|
onDashboardHidden(type) {
|
||||||
let index = this.hiddenColumns.indexOf(type);
|
const index = this.hiddenColumns.indexOf(type);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
this.hiddenColumns.push(type)
|
this.hiddenColumns.push(type)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
2
resources/assets/js/store/actions.js
vendored
2
resources/assets/js/store/actions.js
vendored
@ -340,8 +340,8 @@ export default {
|
|||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: "system/setting",
|
url: "system/setting",
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
$A.setTimezone(data.server_timezone);
|
|
||||||
state.systemConfig = Object.assign(data, {
|
state.systemConfig = Object.assign(data, {
|
||||||
|
timezoneDifference: $A.setTimezone(data.server_timezone),
|
||||||
__state: "success",
|
__state: "success",
|
||||||
})
|
})
|
||||||
resolve(state.systemConfig)
|
resolve(state.systemConfig)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user