diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index cc78429c8..73ed1ff1c 100755 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -141,6 +141,7 @@ export default { windowActive(active) { if (active) { this.autoTheme() + $A.updateTimezone() this.__windowTimer && clearTimeout(this.__windowTimer) this.__windowTimer = setTimeout(_ => { this.$store.dispatch("call", { @@ -313,6 +314,7 @@ export default { // APP进入前台 window.__onAppActive = () => { this.autoTheme() + $A.updateTimezone() $A.IDBTest() } // 页面失活 diff --git a/resources/assets/js/functions/common.js b/resources/assets/js/functions/common.js index 55afa7a62..bf118e855 100755 --- a/resources/assets/js/functions/common.js +++ b/resources/assets/js/functions/common.js @@ -1888,19 +1888,35 @@ const timezone = require("dayjs/plugin/timezone"); }, /** - * 设置时区 - * @param tz - * @returns {number} + * 时间对象(减去时区差) + * @param v + * @returns {*|dayjs.Dayjs} */ - setTimezone(tz) { - const local = $A.dayjs().startOf('hour'); - const server = local.tz(tz); - return $A.timezoneDifference = local.startOf('hour').diff(server.format("YYYY-MM-DD HH:mm:ss"), 'hour') + daytz(v = undefined) { + const t = $A.dayjs(v) + if ($A.timezoneDifference) { + return t.subtract($A.timezoneDifference, "hour") + } + return t; }, /** - * 本地时间与服务器时间差(小时) + * 更新时区 + * @param tz + * @returns {number} */ + updateTimezone(tz = undefined) { + if (typeof tz !== "undefined") { + $A.timezoneName = tz; + } + if (!$A.timezoneName) { + return $A.timezoneDifference = 0; + } + const local = $A.dayjs().startOf('hour'); + const server = local.tz($A.timezoneName); + return $A.timezoneDifference = local.startOf('hour').diff(server.format("YYYY-MM-DD HH:mm:ss"), 'hour') + }, + timezoneName: null, timezoneDifference: 0, /** @@ -2000,7 +2016,7 @@ const timezone = require("dayjs/plugin/timezone"); * @returns {string} */ timeFormat(date) { - const local = $A.dayjs().subtract($A.timezoneDifference, "hour"), + const local = $A.daytz(), time = $A.dayjs(date); if (local.format("YYYY-MM-DD") === time.format("YYYY-MM-DD")) { return time.format("HH:mm") @@ -2021,7 +2037,7 @@ const timezone = require("dayjs/plugin/timezone"); * @returns {string} */ countDownFormat(s, e) { - s = $A.dayjs(s).subtract($A.timezoneDifference, "hour") + s = $A.daytz(s) e = $A.dayjs(e) const diff = e.diff(s, 'second'); if (diff == 0) { diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index d80d85b22..388890f30 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -1395,7 +1395,7 @@ export default { windowScrollY(val) { if ($A.isIos() && !this.$slots.head) { - this.$refs.nav.style.marginTop = `${val}px` + this.$refs.nav.style.marginTop = `${Math.max(0, val)}px` } }, diff --git a/resources/assets/js/pages/manage/dashboard.vue b/resources/assets/js/pages/manage/dashboard.vue index ba1253cc0..f5d57d2f4 100644 --- a/resources/assets/js/pages/manage/dashboard.vue +++ b/resources/assets/js/pages/manage/dashboard.vue @@ -7,8 +7,11 @@
{{$L('欢迎您,' + userInfo.nickname)}}
- {{$L('以下是你当前的任务统计数据')}} - + {{$L('以下是你当前的任务统计数据')}} +
diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 13bb484b5..192c4a4db 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -341,7 +341,7 @@ export default { url: "system/setting", }).then(({data}) => { state.systemConfig = Object.assign(data, { - timezoneDifference: $A.setTimezone(data.server_timezone), + timezoneDifference: $A.updateTimezone(data.server_timezone), __state: "success", }) resolve(state.systemConfig) diff --git a/resources/assets/sass/pages/page-dashboard.scss b/resources/assets/sass/pages/page-dashboard.scss index eabc795da..16404b2e9 100644 --- a/resources/assets/sass/pages/page-dashboard.scss +++ b/resources/assets/sass/pages/page-dashboard.scss @@ -51,6 +51,9 @@ padding: 0 12px; color: #888888; font-size: 13px; + .dashboard-time { + padding-left: 4px; + } .dashboard-load { display: flex; align-items: center;