|
|
@@ -1,7 +1,10 @@
|
|
|
import axios from 'axios'
|
|
|
import { useGlobalStore } from '@/stores/modules/global'
|
|
|
+import { getServerTime } from './api/common'
|
|
|
+import moment from 'moment'
|
|
|
|
|
|
-const { getSystemConfig } = useGlobalStore()
|
|
|
+const { getSystemConfig, $toRefs } = useGlobalStore()
|
|
|
+const { dateDiff } = $toRefs()
|
|
|
|
|
|
export default new (class {
|
|
|
constructor() {
|
|
|
@@ -96,6 +99,11 @@ export default new (class {
|
|
|
axios(res.apiUrl).then((res) => {
|
|
|
this.config = res.data.data
|
|
|
this.isReady = true
|
|
|
+ // 同步服务器时间
|
|
|
+ getServerTime().then((res) => {
|
|
|
+ const serverTime = moment(res.data)
|
|
|
+ dateDiff.value = moment().diff(serverTime)
|
|
|
+ })
|
|
|
resolve(this.config)
|
|
|
}).catch(() => {
|
|
|
const result = this.tryinit()
|