5 files modified
1 files renamed
1 files added
| | |
| | | </template> |
| | | |
| | | |
| | | |
| | | <script setup> |
| | | import { useDownloadWs } from '@/page/index/useDownloadWs'; |
| | | useDownloadWs() |
| | | </script> |
| | | |
| | | <style> |
| New file |
| | |
| | | <template> |
| | | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { useGlobalWS } from '@/page/index/useGlobalWS'; |
| | | useGlobalWS() |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | |
| | | </style> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <GlobalWS /> |
| | | <!-- <wechat></wechat> --> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import index from '@/mixins/index' |
| | | import wechat from './wechat.vue' |
| | | import index from '@/mixins/index'; |
| | | import wechat from './wechat.vue'; |
| | | //import { validatenull } from 'utils/validate'; |
| | | import { mapGetters } from 'vuex' |
| | | import tags from './tags.vue' |
| | | import search from './search.vue' |
| | | import logo from './logo.vue' |
| | | import top from './top/index.vue' |
| | | import sidebar from './sidebar/index.vue' |
| | | import { mapGetters } from 'vuex'; |
| | | import tags from './tags.vue'; |
| | | import search from './search.vue'; |
| | | import logo from './logo.vue'; |
| | | import top from './top/index.vue'; |
| | | import sidebar from './sidebar/index.vue'; |
| | | import GlobalWS from '@/page/index/GlobalWS.vue'; |
| | | |
| | | export default { |
| | | mixins: [index], |
| | | components: { |
| | | GlobalWS, |
| | | top, |
| | | logo, |
| | | tags, |
| | |
| | | provide () { |
| | | return { |
| | | index: this, |
| | | } |
| | | }; |
| | | }, |
| | | computed: { |
| | | ...mapGetters([ |
| | |
| | | validSidebar () { |
| | | return !( |
| | | (this.$route.meta || {}).menu === false || (this.$route.query || {}).menu === 'false' |
| | | ) |
| | | ); |
| | | }, |
| | | }, |
| | | props: [], |
| | |
| | | openMenu (item = {}) { |
| | | this.$store.dispatch('GetMenu', item.id).then(data => { |
| | | if (data.length !== 0) { |
| | | this.$router.$avueRouter.formatRoutes(data, true) |
| | | this.$router.$avueRouter.formatRoutes(data, true); |
| | | |
| | | // 获取url里面的redirect |
| | | const redirect = decodeURIComponent(this.$route.query.redirect || '') |
| | | const redirect = decodeURIComponent(this.$route.query.redirect || ''); |
| | | if (redirect) { |
| | | console.log('redirect', redirect) |
| | | const [path, queryString] = redirect.split('?') |
| | | const query = queryString ? Object.fromEntries(new URLSearchParams(queryString)) : {} |
| | | this.$router.push({ path, query }) |
| | | console.log('redirect', redirect); |
| | | const [path, queryString] = redirect.split('?'); |
| | | const query = queryString ? Object.fromEntries(new URLSearchParams(queryString)) : {}; |
| | | this.$router.push({ path, query }); |
| | | } |
| | | } |
| | | //当点击顶部菜单后默认打开第一个菜单 |
| | |
| | | }, itemActive.meta) |
| | | }); |
| | | }*/ |
| | | }) |
| | | }); |
| | | }, |
| | | }, |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| File was renamed from src/page/index/useDownloadWs.js |
| | |
| | | import { computed, onBeforeUnmount, onMounted } from 'vue'; |
| | | import { getWebsocketUrl } from '@/utils/websocket/config' |
| | | import { useConnectWebSocket } from '@/utils/websocket/connect-websocket' |
| | | import { useStore } from 'vuex' |
| | | import dayjs from 'dayjs' |
| | | import { aLinkDownloadUtil } from '@/utils/util' |
| | | import EventBus from '@/utils/eventBus' |
| | | import { computed, onBeforeUnmount, onMounted } from 'vue'; |
| | | import { setStore,getStore } from '@/utils/store'; |
| | | import { getDownloadStatusApi } from '@/api/dataCenter/dataCenter'; |
| | | import { getStore, setStore } from '@/utils/store' |
| | | |
| | | export const useDownloadWs = () => { |
| | | export const useGlobalWS = () => { |
| | | const store = useStore() |
| | | const loginUserInfo = computed(() => store.state.user.userInfo) |
| | | const downloadProgress = computed(() => store.state.common.downloadProgress) |
| | | let currentWebSocket = null |
| | | function messageHandler(payload) { |
| | | const {type,status,progress,download_url} = payload |
| | | |
| | | // 下载进度处理 |
| | | function downloadProcessing(payload) { |
| | | const {type,status,progress,download_url} = payload?.data || {} |
| | | let setProgress = 0 |
| | | if (status === 'PENDING'){ |
| | | setProgress = 1 |
| | |
| | | ...downloadProgress.value, |
| | | [type]: setProgress, |
| | | }) |
| | | if (status === 'COMPLETED' && ['htsjzx','htlsrwxq'].includes(type)) { |
| | | if (status === 'COMPLETED' && ['dpsjzx','dplsrwxq'].includes(type)) { |
| | | const name = `数据中心-${dayjs().format('YYYYMMDDHHmmss')}.zip` |
| | | const currentUrl = getStore({name: 'downloadUrl'}) |
| | | if (currentUrl === download_url && download_url!== undefined) return |
| | |
| | | } |
| | | } |
| | | |
| | | const logOut = () => { |
| | | store.commit('SET_THEME_NAME', '') |
| | | store.dispatch('LogOut').then(() => { |
| | | router.push({ path: '/login' }) |
| | | setTimeout(() => location.reload()) |
| | | }) |
| | | } |
| | | function messageHandler(payload) { |
| | | switch (payload.biz_code) { |
| | | case 'JOB_ISREFRESH': |
| | | store.commit('jobUpdateKeyAdd') |
| | | break |
| | | case 'DEVICE_ISREFRESH': |
| | | store.commit('deviceUpdateKeyAdd') |
| | | break |
| | | case 'DOWNLOAD_PROGRESS': |
| | | downloadProcessing(payload) |
| | | break |
| | | case 'LOGOUT_USER': |
| | | logOut() |
| | | break |
| | | } |
| | | } |
| | | |
| | | onMounted(() => { |
| | | let webSocketUrl = getWebsocketUrl() + `&model_type=3&workspace-id=${loginUserInfo.value.user_id}` |
| | | currentWebSocket = useConnectWebSocket((result)=>{ |
| | | const payload = JSON.parse(result) |
| | | messageHandler(payload.data) |
| | | messageHandler(payload) |
| | | }, webSocketUrl) |
| | | EventBus.on('useDownloadWs-messageHandler',messageHandler) |
| | | EventBus.on('useGlobalWS-messageHandler',messageHandler) |
| | | }) |
| | | |
| | | onBeforeUnmount(() => { |
| | | currentWebSocket?.close() |
| | | EventBus.off('useDownloadWs-messageHandler',messageHandler) |
| | | EventBus.off('useGlobalWS-messageHandler',messageHandler) |
| | | }) |
| | | return {} |
| | | } |
| | |
| | | lockPasswd: getStore({ name: 'lockPasswd' }) || '', |
| | | website: website, |
| | | setting: website.setting, |
| | | deviceUpdateKey: 0, //设备刷新key |
| | | jobUpdateKey: 0, //任务刷新key |
| | | downloadProgress:{ |
| | | htsjzx: 100, //数据中心 |
| | | htlsrwxq: 100, //历史任务详情 |
| | |
| | | setDownloadProgress(state, data) { |
| | | state.downloadProgress = data |
| | | }, |
| | | deviceUpdateKeyAdd(state, data) { |
| | | state.deviceUpdateKey = state.deviceUpdateKey + 1 |
| | | }, |
| | | jobUpdateKeyAdd(state, data) { |
| | | state.jobUpdateKey = state.jobUpdateKey + 1 |
| | | }, |
| | | SET_LANGUAGE: (state, language) => { |
| | | state.language = language; |
| | | setStore({ |
| | |
| | | requestDockInfo(); |
| | | getDownloadStatusApi({type: 'htsjzx'}).then(res =>{ |
| | | if (!['CANCELLED','COMPLETED'].includes(res.data.data?.status || 'COMPLETED')){ |
| | | EventBus.emit('useDownloadWs-messageHandler',res.data.data) |
| | | EventBus.emit('useGlobalWS-messageHandler',res.data.data) |
| | | } |
| | | }) |
| | | }); |
| | |
| | | |
| | | |
| | | const changeKey = inject('changeKey') |
| | | // 轮询查询是否刷新 |
| | | const polling = setInterval(async () => { |
| | | const res = await statusChangedApi() |
| | | if (res.data.data.DEVICE_REFRESH || res.data.data.JOB_REFRESH) { |
| | | const jobUpdateKey = computed(() => store.state.common.jobUpdateKey) |
| | | const deviceUpdateKey = computed(() => store.state.common.deviceUpdateKey) |
| | | |
| | | watch([jobUpdateKey,deviceUpdateKey],()=>{ |
| | | getJobList() |
| | | changeKey.value++ |
| | | } |
| | | }, 4000) |
| | | }) |
| | | |
| | | onBeforeUnmount(() => { |
| | | clearInterval(polling) |