li.shaoyi před 5 měsíci
rodič
revize
deb5d12f8c

+ 3 - 3
src/constants/language.ts

@@ -6,7 +6,7 @@ export enum Language {
     Traditional = 'zh-TW',
     English = 'en-US',
     Thai = 'th',
-    VIVN = 'vi'
+    Vietnamese = 'vi'
 }
 
 /**
@@ -19,7 +19,7 @@ export function getClientLanguage() {
         { result: Language.Traditional, code: ['zh-TW'] },
         { result: Language.English, code: ['en', 'en-US'] },
         { result: Language.Thai, code: ['th', 'th-TH'] },
-        { result: Language.VIVN, code: ['vi', 'vi'] },
+        { result: Language.Vietnamese, code: ['vi', 'vi-VN'] },
     ]
     const lang = rules.find(rule => rule.code.includes(navigator.language))
     return lang ? lang.result : Language.English
@@ -35,6 +35,6 @@ export function getLanguageList() {
         { label: '繁体中文', value: Language.Traditional },
         { label: 'English', value: Language.English },
         { label: 'ภาษาไทย', value: Language.Thai },
-        { label: 'Việt nam', value: Language.VIVN },
+        { label: 'Việt nam', value: Language.Vietnamese },
     ]
 }

+ 1 - 1
src/filters/index.ts

@@ -281,7 +281,7 @@ export function formatMsgDate(value?: string) {
     } else if (moment(value).isSame(moment().subtract(1, 'day'), "day")) {
         return formatDate(value, '昨日 ' + 'HH:mm:ss')
     } else {
-        return formatDate(value, 'YYYY-MM-DDs')
+        return formatDate(value, 'YYYY-MM-DD')
     }
 }
 

+ 104 - 28
src/packages/mobile/App.vue

@@ -1,46 +1,106 @@
 <template>
   <router-view />
   <Notify v-model:show="notify.show" :title="notify.title" :content="notify.content" />
+  <Dialog class="g-dialog-message" v-model:show="message.show" theme="round-button" confirm-button-text="关闭">
+    <template #title>
+      <div class="g-dialog-message__header">
+        <h4>{{ currentMessage?.title }}</h4>
+        <span>{{ formatDate(currentMessage?.createtime) }}</span>
+      </div>
+    </template>
+    <div class="g-dialog-message__content" v-html="currentMessage?.content"></div>
+    <div class="g-dialog-message__footer" v-if="messageList.length > 1">
+      <span :class="{ disabled: message.index === 0 }" @click="changeMessage(-1)">上一条</span>
+      <span :class="{ disabled: message.index === (messageList.length - 1) }" @click="changeMessage(1)">下一条</span>
+    </div>
+  </Dialog>
 </template>
 
 <script lang="ts" setup>
-import { reactive } from 'vue'
-import { useNavigation } from './router/navigation'
+import { reactive, computed, onMounted, PropType, watch } from 'vue'
+import { Locale, Dialog } from 'vant'
 import { dialog } from '@/utils/vant'
+import { formatDate } from '@/filters'
 import { useLogin } from '@/business/login'
-import { i18n } from "@/stores"
+import { Language } from '@/constants/language'
+import { useNavigation } from './router/navigation'
+import { i18n, useNoticeStore } from '@/stores'
 import eventBus from '@/services/bus'
+import plus from '@/utils/h5plus'
 import Notify from '@mobile/components/base/notify/index.vue'
-import { Locale } from 'vant'
 import enUS from 'vant/es/locale/lang/en-US'
 import zhCN from 'vant/es/locale/lang/zh-CN'
 import thTH from 'vant/es/locale/lang/th-TH'
 import zhTW from 'vant/es/locale/lang/zh-TW'
+import viVN from 'vant/es/locale/lang/vi-VN'
+
+const props = defineProps({
+  statusBarStyle: {
+    type: String as PropType<'dark' | 'light'>,
+    default: 'light'
+  },
+  // 是否弹出未读消息
+  showUnread: {
+    type: Boolean,
+    default: true
+  }
+})
 
 const { userLogout } = useLogin()
 const { backHome } = useNavigation()
 
-const languageMap = {
-  'zh-CN': zhCN,
-  'en-US': enUS,
-  'zh-TW': zhTW,
-  'th': thTH
-}
+const noticeStore = useNoticeStore()
 
-const language = i18n.global.locale
+// 消息弹窗
+const message = reactive({
+  show: false,
+  index: 0
+})
 
-if (language in languageMap) {
-  Locale.use(language, languageMap[language])
-}else{
-  Locale.use('en-US', enUS)
+// 消息列表
+const messageList = computed(() => {
+  const today = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
+  const readDay = localStorage.getItem('readDay')
+  const showUnread = props.showUnread && today !== readDay // 未读消息一天内只会弹框一次
+
+  return noticeStore.noticeList.filter((e) => (showUnread && !e.readed) || e.isforcedisplay)
+})
+
+// 当前消息
+const currentMessage = computed(() => messageList.value[message.index])
+
+// 切换消息
+const changeMessage = (value: number) => {
+  const i = message.index + value
+  if (i > -1 && i < messageList.value.length) {
+    message.index = i
+    noticeStore.updateNoticeReaded(currentMessage.value.autoid)
+  }
 }
 
+// 顶部通知
 const notify = reactive({
   show: false,
   title: '',
   content: ''
 })
 
+// 接收风控通知
+eventBus.$on('RiskToWebNtf', (msg, type) => {
+  const res = msg as { title: string, content: string }
+  if (type === 1) {
+    notify.title = res.title
+    notify.content = res.content
+    notify.show = true
+  } else {
+    dialog({
+      title: res.title,
+      message: res.content,
+      confirmButtonText: '确定'
+    })
+  }
+})
+
 // 接收用户登出通知
 eventBus.$on('LogoutNotify', (msg) => {
   userLogout(() => {
@@ -57,19 +117,35 @@ eventBus.$on('LogoutNotify', (msg) => {
   })
 })
 
-// 接收风控通知
-eventBus.$on('RiskToWebNtf', (msg, type) => {
-  const res = msg as { title: string, content: string }
-  if (type === 1) {
-    notify.title = res.title
-    notify.content = res.content
-    notify.show = true
-  } else {
-    dialog({
-      title: res.title,
-      message: res.content,
-      confirmButtonText: '确定'
-    })
+// 多语言列表
+const languageMap = {
+  [Language.Simplified]: zhCN,
+  [Language.English]: enUS,
+  [Language.Traditional]: zhTW,
+  [Language.Thai]: thTH,
+  [Language.Vietnamese]: viVN
+}
+
+// 当前语言
+const language = i18n.global.locale
+
+if (language in languageMap) {
+  Locale.use(language, languageMap[language])
+} else {
+  Locale.use('en-US', enUS)
+}
+
+watch(() => noticeStore.isInitialized, () => {
+  const [firstMessage] = messageList.value
+
+  if (firstMessage) {
+    const today = formatDate(new Date().toISOString(), 'YYYY-MM-DD')
+    localStorage.setItem('readDay', today) // 记录当前日期
+    message.index = 0
+    message.show = true
+    noticeStore.updateNoticeReaded(firstMessage.autoid)
   }
 })
+
+onMounted(() => plus.setStatusBarStyle(props.statusBarStyle))
 </script>

+ 43 - 0
src/packages/mobile/assets/themes/global/global.less

@@ -628,6 +628,49 @@
     }
 }
 
+.g-dialog-message {
+    line-height: 1.6;
+
+    &__header {
+        text-align: left;
+        padding: 0 15px;
+        margin-bottom: 10px;
+
+        h4 {
+            font-weight: bold;
+        }
+
+        span {
+            display: block;
+            font-size: 12px;
+            font-weight: normal;
+            color: #999;
+        }
+    }
+
+    &__content {
+        max-height: 50vh;
+        overflow-y: auto;
+        padding: 0 15px;
+    }
+
+    &__footer {
+        display: flex;
+        justify-content: center;
+        padding: 10px;
+
+        span {
+            &:not(:first-child) {
+                margin-left: 10px;
+            }
+
+            &.disabled {
+                color: #999;
+            }
+        }
+    }
+}
+
 .van {
     &-dialog {
         &__message {

+ 2 - 2
src/packages/mobile/components/modules/luanguage/index.vue

@@ -38,7 +38,7 @@ const languageMap: { [key: string]: string } = {
     'en': Language.English,
     'zh-TW': Language.Traditional,
     'th': Language.Thai,
-    'vi': Language.VIVN
+    'vi': Language.Vietnamese
 }
 
 const vantlocaleMap = {
@@ -46,7 +46,7 @@ const vantlocaleMap = {
     [Language.Traditional]: zhTW,
     [Language.English]: enUS,
     [Language.Thai]: thTH,
-    [Language.VIVN]: viVN,
+    [Language.Vietnamese]: viVN,
 }
 
 // 当前语言

+ 1 - 2
src/packages/mobile/router/index.ts

@@ -27,12 +27,11 @@ const routes: RouteRecordRaw[] = [
   },
   {
     path: '/register',
-    name: 'register',
     component: Page,
     children: [
       {
         path: '',
-        name: '',
+        name: 'register',
         component: () => import('../views/user/register/home.vue'),
         meta: {
           ignoreAuth: true,

+ 0 - 7
src/packages/mobile/router/navigation.ts

@@ -27,12 +27,6 @@ export function useNavigation() {
         }
     }
 
-    // 获取参数字符串----废弃待优化
-    const getParamString = (name: string) => {
-        // https://github.com/vuejs/router/releases/tag/v4.1.0
-        return route.params[name] ?? ''
-    }
-
     // 获取查询字符串
     const getQueryString = (name: string) => {
         const qs = route.query[name]
@@ -116,7 +110,6 @@ export function useNavigation() {
         hasHistory,
         setGlobalUrlParams,
         getGlobalUrlParams,
-        getParamString,
         getQueryString,
         getQueryStringToNumber,
         backHome,

+ 1 - 1
src/packages/mobile/views/home/main/Index.vue

@@ -8,7 +8,7 @@
       <app-block>
         <Cell :value="$t('common.more')" :to="{ name: 'notice-list' }" icon="volume" is-link>
           <template #title>
-            <Badge :offset="[10, 8]" :dot="noticeStore.unreadList.length > 0">{{ $t('routes.notice') }}</Badge>
+            <Badge :offset="[10, 8]" :dot="noticeStore.unreadCount > 0">{{ $t('routes.notice') }}</Badge>
           </template>
         </Cell>
       </app-block>

+ 1 - 1
src/packages/pc/components/layouts/header/index.vue

@@ -7,7 +7,7 @@
         <div class="app-header__right">
             <slot name="right"></slot>
             <div class="iconbar">
-                <el-badge type="danger" :is-dot="noticeStore.unreadList.length > 0">
+                <el-badge type="danger" :is-dot="noticeStore.unreadCount > 0">
                     <app-icon icon="g-icon-notice" @click="openComponent('notice')" />
                 </el-badge>
                 <app-icon icon="Tickets" @click="openComponent('report')" />

+ 2 - 83
src/packages/sbyj/App.vue

@@ -1,88 +1,7 @@
 <template>
-  <router-view />
-  <Notify v-model:show="notify.show" :title="notify.title" :content="notify.content" />
-  <Dialog class="g-dialog-tips" v-model:show="tips.show" :title="currentTipts?.title" theme="round-button"
-    confirm-button-text="关闭">
-    <div class="g-dialog-tips__content" v-html="currentTipts?.content"></div>
-    <div class="g-dialog-tips__footer" v-if="noticeStore.tipsList.length > 1">
-      <span :class="{ disabled: tips.index === 0 }" @click="changeTips(-1)">上一条</span>
-      <span :class="{ disabled: tips.index === (noticeStore.tipsList.length - 1) }" @click="changeTips(1)">下一条</span>
-    </div>
-  </Dialog>
+  <app-view />
 </template>
 
 <script lang="ts" setup>
-import { reactive, watch, computed } from 'vue'
-import { Dialog } from 'vant'
-import { useNavigation } from '@mobile/router/navigation'
-import { dialog } from '@/utils/vant'
-import { useLogin } from '@/business/login'
-import { useNoticeStore } from '@/stores'
-import eventBus from '@/services/bus'
-import Notify from '@mobile/components/base/notify/index.vue'
-
-const { userLogout } = useLogin()
-const { backHome } = useNavigation()
-const noticeStore = useNoticeStore()
-
-// 当前提示信息
-const currentTipts = computed(() => noticeStore.tipsList[tips.index])
-
-// 通知
-const notify = reactive({
-  show: false,
-  title: '',
-  content: ''
-})
-
-// 提示
-const tips = reactive({
-  show: false,
-  index: 0
-})
-
-// 切换提示
-const changeTips = (value: number) => {
-  const i = tips.index + value
-  if (i > -1 && i < noticeStore.tipsList.length) {
-    tips.index = i
-  }
-}
-
-watch(() => noticeStore.tipsList.length, (val) => {
-  tips.index = 0
-  tips.show = !!val
-})
-
-// 接收用户登出通知
-eventBus.$on('LogoutNotify', (msg) => {
-  userLogout(() => {
-    if (msg) {
-      dialog({
-        message: msg as string,
-        confirmButtonText: '确定'
-      }).then(() => {
-        backHome()
-      })
-    } else {
-      backHome()
-    }
-  })
-})
-
-// 接收风控通知
-eventBus.$on('RiskToWebNtf', (msg, type) => {
-  const res = msg as { title: string, content: string }
-  if (type === 1) {
-    notify.title = res.title
-    notify.content = res.content
-    notify.show = true
-  } else {
-    dialog({
-      title: res.title,
-      message: res.content,
-      confirmButtonText: '确定'
-    })
-  }
-})
+import AppView from '@mobile/App.vue'
 </script>

+ 21 - 3
src/packages/sbyj/assets/themes/global/global.less

@@ -450,12 +450,30 @@
     }
 }
 
-.g-dialog-tips {
+.g-dialog-message {
+    line-height: 1.6;
+
+    &__header {
+        text-align: left;
+        padding: 0 15px;
+        margin-bottom: 10px;
+
+        h4 {
+            font-weight: bold;
+        }
+
+        span {
+            display: block;
+            font-size: 12px;
+            font-weight: normal;
+            color: #999;
+        }
+    }
+
     &__content {
         max-height: 50vh;
         overflow-y: auto;
-        line-height: 1.6;
-        padding: 15px;
+        padding: 0 15px;
     }
 
     &__footer {

+ 1 - 1
src/packages/sbyj/views/home/main/index.vue

@@ -16,7 +16,7 @@
         <Cell class="home-main__titlebar" title="通知公告" value="更多" :to="{ name: 'notice-list' }" icon="volume" is-link>
           <template #title>
             <span>{{ $t('routes.notice') }}</span>
-            <Badge :dot="noticeStore.unreadList.length > 0"></Badge>
+            <Badge :dot="noticeStore.unreadCount > 0"></Badge>
           </template>
         </Cell>
       </app-block>

+ 1 - 1
src/packages/sbyj/views/mine/index.vue

@@ -125,7 +125,7 @@
                 <Cell is-link :to="{ name: 'notice-list' }">
                     <template #title>
                         <Iconfont icon="g-icon-caution">公告通知</Iconfont>
-                        <Badge :dot="noticeStore.unreadList.length > 0" />
+                        <Badge :dot="noticeStore.unreadCount > 0" />
                     </template>
                 </Cell>
                 <Cell is-link :to="{ name: 'mine-setting' }">

+ 7 - 0
src/packages/sjgj/App.vue

@@ -0,0 +1,7 @@
+<template>
+  <app-view :show-unread="false" />
+</template>
+
+<script lang="ts" setup>
+import AppView from '@mobile/App.vue'
+</script>

+ 21 - 3
src/packages/sjgj/assets/themes/global/global.less

@@ -450,12 +450,30 @@
     }
 }
 
-.g-dialog-tips {
+.g-dialog-message {
+    line-height: 1.6;
+
+    &__header {
+        text-align: left;
+        padding: 0 15px;
+        margin-bottom: 10px;
+
+        h4 {
+            font-weight: bold;
+        }
+
+        span {
+            display: block;
+            font-size: 12px;
+            font-weight: normal;
+            color: #999;
+        }
+    }
+
     &__content {
         max-height: 50vh;
         overflow-y: auto;
-        line-height: 1.6;
-        padding: 15px;
+        padding: 0 15px;
     }
 
     &__footer {

+ 1 - 1
src/packages/sjgj/main.ts

@@ -1,7 +1,7 @@
 import 'core-js'
 import 'regenerator-runtime/runtime'
 import { createApp } from 'vue'
-import App from '../sbyj/App.vue'
+import App from './App.vue'
 import router from './router'
 import directives from '@/directives' // 自定义指令集
 //import 'default-passive-events'

+ 1 - 1
src/packages/sjgj/views/home/main/index.vue

@@ -25,7 +25,7 @@
         <Cell class="home-main__titlebar" title="通知公告" value="更多" :to="{ name: 'notice-list' }" icon="volume" is-link>
           <template #title>
             <span>{{ $t('routes.notice') }}</span>
-            <Badge :dot="noticeStore.unreadList.length > 0"></Badge>
+            <Badge :dot="noticeStore.unreadCount > 0"></Badge>
           </template>
         </Cell>
       </app-block>

+ 1 - 1
src/packages/sjgj/views/mine/index.vue

@@ -92,7 +92,7 @@
                 <Cell is-link :to="{ name: 'notice-list' }">
                     <template #title>
                         <Iconfont icon="g-icon-caution">公告通知</Iconfont>
-                        <Badge :dot="noticeStore.unreadList.length > 0" />
+                        <Badge :dot="noticeStore.unreadCount > 0" />
                     </template>
                 </Cell>
                 <Cell is-link :to="{ name: 'mine-setting' }">

+ 7 - 0
src/packages/tss-vi/App.vue

@@ -0,0 +1,7 @@
+<template>
+  <app-view status-bar-style="dark" />
+</template>
+
+<script lang="ts" setup>
+import AppView from '@mobile/App.vue'
+</script>

+ 1 - 1
src/packages/tss-vi/main.ts

@@ -1,7 +1,7 @@
 import 'core-js'
 import 'regenerator-runtime/runtime'
 import { createApp } from 'vue'
-import App from '../tss/App.vue'
+import App from './App.vue'
 import router from './router'
 import directives from '@/directives' // 自定义指令集
 //import 'default-passive-events'

+ 1 - 2
src/packages/tss-vi/router/index.ts

@@ -27,12 +27,11 @@ const routes: Array<RouteRecordRaw> = [
   },
   {
     path: '/register',
-    name: 'register',
     component: Page,
     children: [
       {
         path: '',
-        name: '',
+        name: 'register',
         component: () => import('@mobile/views/user/register/home.vue'),
         meta: {
           ignoreAuth: true,

+ 2 - 73
src/packages/tss/App.vue

@@ -1,78 +1,7 @@
 <template>
-  <router-view />
-  <Notify v-model:show="notify.show" :title="notify.title" :content="notify.content" />
+  <app-view status-bar-style="dark" />
 </template>
 
 <script lang="ts" setup>
-import { reactive, onMounted } from 'vue'
-import { Locale } from 'vant'
-import { useNavigation } from '@mobile/router/navigation'
-import { dialog } from '@/utils/vant'
-import { useLogin } from '@/business/login'
-import { i18n } from '@/stores'
-import eventBus from '@/services/bus'
-import plus from '@/utils/h5plus'
-import Notify from '@mobile/components/base/notify/index.vue'
-import enUS from 'vant/es/locale/lang/en-US'
-import zhCN from 'vant/es/locale/lang/zh-CN'
-import thTH from 'vant/es/locale/lang/th-TH'
-import zhTW from 'vant/es/locale/lang/zh-TW'
-
-const { userLogout } = useLogin()
-const { backHome } = useNavigation()
-
-const languageMap = {
-  'zh-CN': zhCN,
-  'en-US': enUS,
-  'zh-TW': zhTW,
-  'th': thTH
-}
-
-const language = i18n.global.locale
-
-if (language in languageMap) {
-  Locale.use(language, languageMap[language])
-}else{
-  Locale.use('en-US', enUS)
-}
-
-const notify = reactive({
-  show: false,
-  title: '',
-  content: ''
-})
-
-// 接收用户登出通知
-eventBus.$on('LogoutNotify', (msg) => {
-  userLogout(() => {
-    if (msg) {
-      dialog({
-        message: msg as string,
-        confirmButtonText: i18n.global.t('operation.confirm')
-      }).then(() => {
-        backHome()
-      })
-    } else {
-      backHome()
-    }
-  })
-})
-
-// 接收风控通知
-eventBus.$on('RiskToWebNtf', (msg, type) => {
-  const res = msg as { title: string, content: string }
-  if (type === 1) {
-    notify.title = res.title
-    notify.content = res.content
-    notify.show = true
-  } else {
-    dialog({
-      title: res.title,
-      message: res.content,
-      confirmButtonText: i18n.global.t('operation.confirm')
-    })
-  }
-})
-
-onMounted(() => plus.setStatusBarStyle('dark'))
+import AppView from '@mobile/App.vue'
 </script>

+ 43 - 0
src/packages/tss/assets/themes/global/global.less

@@ -655,6 +655,49 @@
     }
 }
 
+.g-dialog-message {
+    line-height: 1.6;
+
+    &__header {
+        text-align: left;
+        padding: 0 15px;
+        margin-bottom: 10px;
+
+        h4 {
+            font-weight: bold;
+        }
+
+        span {
+            display: block;
+            font-size: 12px;
+            font-weight: normal;
+            color: #999;
+        }
+    }
+
+    &__content {
+        max-height: 50vh;
+        overflow-y: auto;
+        padding: 0 15px;
+    }
+
+    &__footer {
+        display: flex;
+        justify-content: center;
+        padding: 10px;
+
+        span {
+            &:not(:first-child) {
+                margin-left: 10px;
+            }
+
+            &.disabled {
+                color: #999;
+            }
+        }
+    }
+}
+
 .van {
     &-dialog {
         &__message {

+ 1 - 2
src/packages/tss/router/index.ts

@@ -27,12 +27,11 @@ const routes: Array<RouteRecordRaw> = [
   },
   {
     path: '/register',
-    name: 'register',
     component: Page,
     children: [
       {
         path: '',
-        name: '',
+        name: 'register',
         component: () => import('@mobile/views/user/register/home.vue'),
         meta: {
           ignoreAuth: true,

+ 1 - 2
src/packages/tss/views/home/main/index.vue

@@ -7,8 +7,7 @@
           <img :src="'./logo/logo.svg'" />
           <Search shape="round" background="transparent" :placeholder="$t('tss.tips1')"
             @click="$router.push({ name: 'search' })" />
-          <Icon name="bullhorn-o" :dot="noticeStore.unreadList.length > 0"
-            @click="$router.push({ name: 'notice-list' })" />
+          <Icon name="bullhorn-o" :dot="noticeStore.unreadCount > 0" @click="$router.push({ name: 'notice-list' })" />
         </div>
       </app-statusbar>
     </template>

+ 20 - 36
src/services/worker/trade/index.ts

@@ -1,11 +1,9 @@
-import { Package50 } from '@/services/websocket/package'
 import { FunCode } from '@/constants/funcode'
-import { encodeProto, decodeProto } from '@/services/websocket/package/package50/proto'
 import Worker from 'worker-loader!./main'
 import Service from '../service'
 
 interface RequestParams {
-  data: unknown;
+  content: unknown;
   requestCode: keyof typeof FunCode;
   responseCode: keyof typeof FunCode;
 }
@@ -39,9 +37,8 @@ export default new (class {
             break
           }
           case 'response': {
-            console.log(message.data)
-            const { responseCode, content, error } = message.data
-            const queue = this.responseQueue.get(responseCode)
+            const { content, error } = message.result
+            const queue = this.responseQueue.get(message.id)
             if (queue) {
               const { resolve, reject } = queue
               error ? reject(error) : resolve(content)
@@ -49,7 +46,7 @@ export default new (class {
             break
           }
           case 'push': {
-            console.log(message.data)
+            console.log(message.result)
             break
           }
         }
@@ -57,43 +54,30 @@ export default new (class {
     }
   }
 
-  request<T>({ data, requestCode, responseCode }: RequestParams) {
+  request<T>(data: RequestParams) {
     return new Promise<T>((resolve, reject) => {
-      const requestId = FunCode[requestCode]
-      const responseId = FunCode[responseCode]
+      const run = () => {
+        const messageId = 1
+        this.responseQueue.set(messageId, { resolve, reject })
 
-      encodeProto(requestCode, data).then(async (uint8Array) => {
-        const run = () => {
-          const content = new Package50(requestId, uint8Array)
-          const queueId = new Date().getTime()
-
-          content.serialNumber = queueId
-          this.responseQueue.set(queueId, { resolve, reject })
-
-          this.worker.postMessage({
-            type: 'send',
-            data: {
-              messageId: responseId,
-              content // worker 不支持包含函数对象,content.data() 函数会丢失
-            }
-          })
-        }
-
-        if (this.isTokenValid || ['TokenCheckReq', 'LoginReq'].includes(requestCode)) {
-          run()
-        } else {
-          this.checkToken().then(() => run()).catch(reject)
-        }
-      }).catch(() => {
-        reject('构建失败')
-      })
+        this.worker.postMessage({
+          type: 'send',
+          id: messageId,
+          data
+        })
+      }
+      if (this.isTokenValid || ['TokenCheckReq', 'LoginReq'].includes(data.requestCode)) {
+        run()
+      } else {
+        this.checkToken().then(run).catch(reject)
+      }
     })
   }
 
   checkToken() {
     return new Promise<void>((resolve, reject) => {
       this.request({
-        data: {
+        content: {
           LoginID: '',
           Token: ''
         },

+ 19 - 21
src/services/worker/trade/main.ts

@@ -4,13 +4,11 @@ import { encodeProto, decodeProto } from '@/services/websocket/package/package50
 import { FunCode } from '@/constants/funcode'
 
 interface SendMessageEvent {
+    id: number; // 消息Id
     data: {
-        messageId: number; // 消息Id
-        content: {
-            data: unknown;
-            requestCode: keyof typeof FunCode;
-            responseCode: keyof typeof FunCode;
-        }; // 发送的数据内容
+        content: unknown;
+        requestCode: keyof typeof FunCode;
+        responseCode: keyof typeof FunCode;
     };
     onSuccess?: (res: Package50) => void; // 成功回调
     onFail?: (err: string) => void; // 失败回调
@@ -85,8 +83,7 @@ const initWebSocket = (url: string, protocols?: string | string[]) => {
                     } else if (queue) {
                         // 响应消息
                         const { data, onSuccess } = queue
-                        const { content } = data
-                        const responseId = FunCode[content.requestCode]
+                        const responseId = FunCode[data.responseCode]
 
                         // 可能会收到多个流水号相同的数据包,需判断是否正确的回复码
                         if (responseId === raw.funCode) {
@@ -121,26 +118,26 @@ const initWebSocket = (url: string, protocols?: string | string[]) => {
 }
 
 const sendMessage = (e: SendMessageEvent) => {
-    const { data, onSuccess, onFail } = e
-    const { messageId, content } = data
-    const requestId = FunCode[content.requestCode]
+    const { id, data, onSuccess, onFail } = e
+    const { content, requestCode } = data
+    const requestId = FunCode[requestCode]
 
-    encodeProto(content.requestCode, data).then(async (unit8) => {
+    encodeProto(requestCode, content).then(async (unit8) => {
         const pkg = new Package50(requestId, unit8)
 
         // 判断是否需要回调
         if (onSuccess || onFail) {
-            pkg.serialNumber = messageId
+            pkg.serialNumber = id
 
             const timerId = setTimeout(() => {
                 cancel() // 取消请求
-                messageQueue.delete(messageId)
-                timerQueue.delete(messageId)
+                messageQueue.delete(id)
+                timerQueue.delete(id)
                 onFail?.('请求超时')
             }, 30 * 1000)
 
-            messageQueue.set(messageId, e)
-            timerQueue.set(messageId, timerId)
+            messageQueue.set(id, e)
+            timerQueue.set(id, timerId)
         }
 
         const cancel = socket.connection({
@@ -164,12 +161,13 @@ self.onmessage = (e) => {
             }
             case 'send': {
                 sendMessage({
+                    id: message.id,
                     data: message.data,
                     onSuccess: (content) => {
                         self.postMessage({
                             type: 'response',
-                            data: {
-                                messageId: message.data.responseCode,
+                            id: message.id,
+                            result: {
                                 content
                             }
                         })
@@ -177,8 +175,8 @@ self.onmessage = (e) => {
                     onFail: (error) => {
                         self.postMessage({
                             type: 'response',
-                            data: {
-                                messageId: message.data.responseCode,
+                            id: message.id,
+                            result: {
                                 error
                             }
                         })

+ 1 - 1
src/stores/modules/errorInfo.ts

@@ -36,7 +36,7 @@ export const useErrorInfoStore = defineStore(() => {
                 return error?.descriptionth
             case Language.Traditional:
                 return error?.descriptionzh_tw
-            case Language.VIVN:
+            case Language.Vietnamese:
                 return error?.descriptionvi
             default:
                 return error?.descriptionen

+ 2 - 2
src/stores/modules/language.ts

@@ -16,7 +16,7 @@ export const i18n = createI18n({
         [Language.Traditional]: zhTW,
         [Language.English]: enUS,
         [Language.Thai]: thTH,
-        [Language.VIVN]: viVN,
+        [Language.Vietnamese]: viVN,
     }
 })
 
@@ -38,5 +38,5 @@ plus.getLocalFileContent('./locales/extras/th-TH.json').then((data) => {
 })
 
 plus.getLocalFileContent('./locales/extras/vi-VN.json').then((data) => {
-    i18n.global.mergeLocaleMessage(Language.VIVN, data)
+    i18n.global.mergeLocaleMessage(Language.Vietnamese, data)
 })

+ 7 - 10
src/stores/modules/notice.ts

@@ -11,16 +11,12 @@ export const useNoticeStore = defineStore(() => {
     const state = reactive({
         loading: false,
         noticeList: <Model.NoticeRsp[]>[], // 通知列表
+        isInitialized: false // 是否已初始化
     })
 
-    // 未读列表
-    const unreadList = computed(() => {
-        return state.noticeList.filter((e) => !e.readed)
-    })
-
-    // 强制显示列表
-    const tipsList = computed(() => {
-        return state.noticeList.filter((e) => e.isforcedisplay)
+    // 未读消息数
+    const unreadCount = computed(() => {
+        return state.noticeList.reduce((count, e) => e.readed ? count : count + 1, 0)
     })
 
     // 获取通知列表
@@ -32,6 +28,7 @@ export const useNoticeStore = defineStore(() => {
             state.noticeList = res.data
         } finally {
             state.loading = false
+            state.isInitialized = true
             // 轮询查询系统通知
             timerTask.setTimeout(() => {
                 getNoticeList()
@@ -62,12 +59,12 @@ export const useNoticeStore = defineStore(() => {
     eventBus.$on('LogoutNotify', () => {
         timerTask.clearTimeout('systemNotice')
         state.noticeList = []
+        state.isInitialized = false
     })
 
     return {
         ...toRefs(state),
-        unreadList,
-        tipsList,
+        unreadCount,
         getNoticeList,
         updateNoticeReaded,
     }