li.shaoyi 1 год назад
Родитель
Сommit
5dce255b33

+ 1 - 1
app/package.json

@@ -1,6 +1,6 @@
 {
   "name": "trading",
-  "version": "1.0.13",
+  "version": "1.0.14",
   "main": "main.js",
   "dependencies": {
     "electron-updater": "^6.1.4",

+ 2 - 2
oem/gcszt/config/appconfig.json

@@ -1,8 +1,8 @@
 {
   "appId": "com.muchinfo.gcszt",
   "appName": "贵茶数字通",
-  "version": "1.0.13",
-  "versionCode": "100013",
+  "version": "1.0.14",
+  "versionCode": "100014",
   "apiUrl": "http://192.168.31.204:8080/cfg?key=test_204",
   "tradeChannel": "ws",
   "modules": [

+ 2 - 2
oem/zrwyt/config/appconfig.json

@@ -1,8 +1,8 @@
 {
   "appId": "com.muchinfo.zrwyt",
   "appName": "中融文遗通",
-  "version": "1.0.31",
-  "versionCode": "100031",
+  "version": "1.0.32",
+  "versionCode": "100032",
   "apiUrl": "http://192.168.31.204:8080/cfg?key=test_204",
   "tradeChannel": "ws",
   "modules": [

+ 0 - 1
src/packages/pc/views/auth/components/layout/index.vue

@@ -38,7 +38,6 @@ const meta = document.getElementsByTagName('meta')
 const version = meta.namedItem('revised')?.content ?? '0'
 
 globalStore.getSystemConfig().then((res) => {
-  console.log(res)
   slogan.value = res.slogan
 })
 </script>

+ 1 - 1
src/services/http/index.ts

@@ -27,7 +27,7 @@ export default new (class {
                 //设置请求头
                 if (globalStore.getSystemInfo('tradeChannel') === 'ws') {
                     const key = 'dZChvstdjmqIt5fP'
-                    const timestamp = new Date().getTime()
+                    const timestamp = globalStore.getTimestamp()
                     const verification = cryptojs.HmacSHA256(loginStore.token + timestamp, key)
 
                     config.headers = {

+ 9 - 1
src/services/index.ts

@@ -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()

+ 8 - 0
src/stores/modules/global.ts

@@ -23,6 +23,7 @@ export const useGlobalStore = defineStore(() => {
     const androidPermissions = localData.getRef('androidPermissions')
 
     const state = reactive({
+        dateDiff: 0, // 服务器和本地的时间差(毫秒数)
         showGoodsListing: false, // 是否显示订单交易挂牌
         showTransferListing: false, // 是否显示定金转让挂牌
         clientWidth: 0, // 客户端宽度
@@ -41,6 +42,12 @@ export const useGlobalStore = defineStore(() => {
         }
     })
 
+    // 获取时间戳
+    const getTimestamp = () => {
+        const ts = new Date().getTime()
+        return ts - state.dateDiff
+    }
+
     // 获取系统配置项
     const getSystemConfig = async () => {
         const filePath = './config/appconfig.json'
@@ -180,6 +187,7 @@ export const useGlobalStore = defineStore(() => {
     return {
         ...toRefs(state),
         appTheme,
+        getTimestamp,
         getSystemConfig,
         getSystemInfo,
         hasSystemModule,