Commit 245ae1f3 by 周田

Merge branch 'liucan' into 'main'

fix:数据展示页面添加引导导出提示

See merge request !36
parents 9a983b47 bcb85867
<script setup lang="ts"> <script setup lang="ts">
import { ElNotification } from "element-plus"; import { ElNotification } from 'element-plus'
import { Manager, Socket } from "socket.io-client"; import { Manager, Socket } from 'socket.io-client'
import { computed, onMounted, onUnmounted, ref } from "vue"; import { computed, h, onMounted, onUnmounted, ref } from 'vue'
import { useRoute } from "vue-router"; import { useRoute } from 'vue-router'
const route = useRoute(); const route = useRoute()
const key = computed(() => route.path); const key = computed(() => route.path)
const socket = ref<Socket | null>(null); const socket = ref<Socket | null>(null)
//错误消息通知 //错误消息通知
const handleErrorMsgNotify = () => { const handleErrorMsgNotify = () => {
//websocket连接 //websocket连接
const manager = new Manager(import.meta.env.VITE_WEBSOCKET_API); const manager = new Manager(import.meta.env.VITE_WEBSOCKET_API)
socket.value = manager.socket("/"); socket.value = manager.socket('/')
//收到错误通知 //收到错误通知
socket.value.on("error_message", onErrorMsg); socket.value.on('error_message', onErrorMsg)
}; }
//错误消息处理 //错误消息处理
const onErrorMsg = ({ message }: { message: any }) => { const onErrorMsg = ({ message }: { message: any }) => {
ElNotification({ ElNotification({
title: "爬虫错误提示", title: '爬虫错误提示',
message, message: h('i', { style: 'color: red' }, message),
type: "error", type: 'error'
}); })
}; }
onMounted(() => { onMounted(() => {
handleErrorMsgNotify(); handleErrorMsgNotify()
}); })
onUnmounted(() => { onUnmounted(() => {
if (socket.value) { if (socket.value) {
socket.value.disconnect(); socket.value.disconnect()
} }
}); })
</script> </script>
<template> <template>
...@@ -51,7 +51,7 @@ onUnmounted(() => { ...@@ -51,7 +51,7 @@ onUnmounted(() => {
<style scoped> <style scoped>
.app-main { .app-main {
/*50 = navbar */ /*50 = navbar */
background-image: url("@/assets/picture/background1.png"); background-image: url('@/assets/picture/background1.png');
background-size: 100% 100%; background-size: 100% 100%;
background-repeat: no-repeat; background-repeat: no-repeat;
min-height: calc(100vh - 50px); min-height: calc(100vh - 50px);
......
...@@ -28,58 +28,73 @@ ...@@ -28,58 +28,73 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, watch } from "vue"; import { ref, onMounted, watch, h, onUnmounted } from 'vue'
import { useRoute } from "vue-router"; import { useRoute } from 'vue-router'
import { useRouter } from "vue-router"; import { useRouter } from 'vue-router'
import ituDataTab from "./components/ituDataTab.vue"; import ituDataTab from './components/ituDataTab.vue'
import stDataTab from "./components/stDataTab.vue"; import stDataTab from './components/stDataTab.vue'
import dsnDataTab from "./components/dsnData/dsnTab.vue"; import dsnDataTab from './components/dsnData/dsnTab.vue'
import esDataTab from "./components/esDataTab.vue"; import esDataTab from './components/esDataTab.vue'
import exportDialog from "@/components/Export/index.vue"; import exportDialog from '@/components/Export/index.vue'
import MenuTitle from "@/components/MenuTitle.vue"; import MenuTitle from '@/components/MenuTitle.vue'
import exportRecord from "./components/exportRecord.vue"; import exportRecord from './components/exportRecord.vue'
import { ElNotification } from 'element-plus'
const mode = ref(sessionStorage.getItem("dataDisplayMode") || "DSN数据"); const mode = ref(sessionStorage.getItem('dataDisplayMode') || 'DSN数据')
const showDeleteDialog = ref(false); const showDeleteDialog = ref(false)
const sizeOptions = ["DSN数据", "ITU数据", "ST数据", "ESA数据"]; const sizeOptions = ['DSN数据', 'ITU数据', 'ST数据', 'ESA数据']
const route = useRoute(); const route = useRoute()
const router = useRouter(); const router = useRouter()
const modeValue = ref<any>("数据展示"); const modeValue = ref<any>('数据展示')
//导出记录组件引用 //导出记录组件引用
const expRec = ref<any>(null); const expRec = ref<any>(null)
const goToStatus = () => { const goToStatus = () => {
router.push({ router.push({
path: "/osStatus/list", path: '/osStatus/list'
}); })
}; }
const handleExport = () => { const handleExport = () => {
showDeleteDialog.value = true; showDeleteDialog.value = true
}; }
const handleExportConfirm = () => {};
const noticeImpl = ref()
const handleExportConfirm = () => {}
onMounted(() => { onMounted(() => {
if (route.query.mode) { if (route.query.mode) {
modeValue.value = route.query.mode; modeValue.value = route.query.mode
mode.value = modeValue.value; mode.value = modeValue.value
} }
});
noticeImpl.value = ElNotification({
title: '温馨提示',
message: h('i', { style: 'color: teal' }, '爬虫数据可导出至本地,请点击【导出】按钮执行数据导出'),
duration: 0
})
})
//导出记录 //导出记录
const handleExportRecord = () => { const handleExportRecord = () => {
expRec.value.openDialog(); expRec.value.openDialog()
}; }
watch( watch(
mode, mode,
(newVal) => { (newVal) => {
sessionStorage.setItem("dataDisplayMode", newVal); sessionStorage.setItem('dataDisplayMode', newVal)
modeValue.value = sessionStorage.getItem("dataDisplayMode") || "DSN数据"; modeValue.value = sessionStorage.getItem('dataDisplayMode') || 'DSN数据'
}, },
{ {
immediate: true, immediate: true
}
)
onUnmounted(() => {
if (noticeImpl.value) {
noticeImpl.value.close()
} }
); })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -109,7 +124,7 @@ watch( ...@@ -109,7 +124,7 @@ watch(
} }
.backStyle { .backStyle {
background-image: url("@/assets/picture/back.png"); background-image: url('@/assets/picture/back.png');
background-size: 100% 100%; background-size: 100% 100%;
background-repeat: no-repeat; background-repeat: no-repeat;
height: 5vh; height: 5vh;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment