|
@@ -45,10 +45,11 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
+import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import { getObjValue, isNullES, useClick } from 'js-fast-way'
|
|
|
import { HcSocket } from '~src/plugins/HcSocket'
|
|
|
+import { HcAnnouncement } from 'hc-vue3-ui'
|
|
|
import { useAppStore } from '~src/store'
|
|
|
import { initButtons } from '~sto/app'
|
|
|
import { useProject } from '~sto/useProject'
|
|
@@ -145,11 +146,8 @@ const cascaderSend = async ({ projectId, contractId }) => {
|
|
|
//链接webSocket
|
|
|
if (!isNullES(socket)) socket.close()
|
|
|
if (!website.localModel) {
|
|
|
- socket = new HcSocket({ projectId, contractId, userId: userId.value }, ({ data }) => {
|
|
|
- const res = getObjValue(data)
|
|
|
- if (res.type === 'msgRemind') {
|
|
|
- taskCount.value = res.data ?? 0
|
|
|
- }
|
|
|
+ socket = new HcSocket({ projectId, contractId, userId: userId.value }, (res) => {
|
|
|
+ socketData(res?.data)
|
|
|
})
|
|
|
}
|
|
|
//本地模式
|
|
@@ -160,6 +158,29 @@ const cascaderSend = async ({ projectId, contractId }) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//长链接消息
|
|
|
+const socketData = async (res) => {
|
|
|
+ console.log('socket:', res)
|
|
|
+ const { type, data } = getObjValue(res)
|
|
|
+ if (type === 'msgUpdateMsg') {
|
|
|
+ //更新公告
|
|
|
+ await HcAnnouncement({
|
|
|
+ type: 'update',
|
|
|
+ data: data,
|
|
|
+ //time: 'xxx年xx月xx日 xx:xx:xx',
|
|
|
+ })
|
|
|
+ } else if (type === 'msgSystemMsg') {
|
|
|
+ //普通公告
|
|
|
+ await HcAnnouncement({
|
|
|
+ type: 'system',
|
|
|
+ data: data,
|
|
|
+ })
|
|
|
+ } else if (type === 'msgRemind') {
|
|
|
+ taskCount.value = data ?? 0
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//用户信息
|
|
|
const userId = ref('')
|
|
|
const userInfoLoad = ({ user_id }) => {
|