mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +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
|
||||
* @returns {number}
|
||||
*/
|
||||
setTimezone(tz) {
|
||||
const local = $A.dayjs().startOf('hour');
|
||||
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,
|
||||
|
||||
/**
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
<div class="dashboard-hello">{{$L('欢迎您,' + userInfo.nickname)}}</div>
|
||||
<div class="dashboard-desc">
|
||||
{{$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">
|
||||
<div v-if="loadDashboardTasks" class="dashboard-load"><Loading/></div>
|
||||
</transition>
|
||||
@ -129,7 +130,7 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['userInfo', 'userIsAdmin', 'cacheTasks', 'taskCompleteTemps', 'loadDashboardTasks']),
|
||||
...mapState(['systemConfig', 'userInfo', 'userIsAdmin', 'cacheTasks', 'taskCompleteTemps', 'loadDashboardTasks']),
|
||||
|
||||
...mapGetters(['dashboardTask', 'assistTask', 'transforTasks']),
|
||||
|
||||
@ -203,17 +204,23 @@ export default {
|
||||
},
|
||||
|
||||
scrollTo(type) {
|
||||
let refs = this.$refs[`type_${type}`]
|
||||
const refs = this.$refs[`type_${type}`]
|
||||
if (refs) {
|
||||
$A.scrollToView(refs[0], {
|
||||
behavior: 'smooth',
|
||||
inline: 'end',
|
||||
});
|
||||
const index = this.hiddenColumns.indexOf(type);
|
||||
if (index !== -1) {
|
||||
this.hiddenColumns.splice(index, 1)
|
||||
}
|
||||
this.$nextTick(_ => {
|
||||
$A.scrollToView(refs[0], {
|
||||
behavior: 'smooth',
|
||||
inline: 'end',
|
||||
});
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onDashboardHidden(type) {
|
||||
let index = this.hiddenColumns.indexOf(type);
|
||||
const index = this.hiddenColumns.indexOf(type);
|
||||
if (index === -1) {
|
||||
this.hiddenColumns.push(type)
|
||||
} 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", {
|
||||
url: "system/setting",
|
||||
}).then(({data}) => {
|
||||
$A.setTimezone(data.server_timezone);
|
||||
state.systemConfig = Object.assign(data, {
|
||||
timezoneDifference: $A.setTimezone(data.server_timezone),
|
||||
__state: "success",
|
||||
})
|
||||
resolve(state.systemConfig)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user