From f90651585890a1140fb5e40a339fb2f54a087be5 Mon Sep 17 00:00:00 2001
From: zjc <1034206993@qq.com>
Date: Fri, 27 Dec 2024 16:17:07 +0800
Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E5=B7=A6?=
=?UTF-8?q?=E5=8F=B3=E4=B8=A4=E4=BE=A7=E5=92=8C=E9=A1=B6=E9=83=A8=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Header/index.vue | 147 ++++++++++++++++++++++++--------
src/layout/index.vue | 37 ++++++++
src/router/index.js | 66 ++++++++------
src/views/home/index.vue | 6 +-
src/views/monitor/index.vue | 59 ++-----------
src/views/scenic/index.vue | 10 ---
src/views/sentiment/index.vue | 3 -
src/views/traffic/index.vue | 20 ++---
src/views/workOrder/index.vue | 3 -
9 files changed, 202 insertions(+), 149 deletions(-)
create mode 100644 src/layout/index.vue
diff --git a/src/components/Header/index.vue b/src/components/Header/index.vue
index 8bff1d1..e938010 100644
--- a/src/components/Header/index.vue
+++ b/src/components/Header/index.vue
@@ -14,7 +14,7 @@
- {{ name }}
+ {{ title }}
- []
- },
- navRight: {
- type: Array,
- default: () => []
- },
- current: {
- type: Number,
- default: 0
- },
- isSkip: {
- type: Boolean,
- default: false
- },
- isBack: {
- type: Boolean,
- default: false
- }
- })
const emit = defineEmits(['change'])
+
const router = useRouter()
+ const currentRoute = router.currentRoute.value
+
let currentDate = ref('')
let weatherData = ref({})
+ let title = ref('')
+ let navLeft = ref([])
+ let navRight = ref([])
+ let isSkip = ref(true)
+ let isBack = ref(false)
+ let current = ref(0)
- const name = computed(() => {
- if (!props.isSkip && props.navLeft.length > 0) {
- return props.navLeft[props.current].name
- }
- return props.title
- })
-
+ // 补零
const fillZero = (value) => {
return value < 10 ? `0${value}` : value
}
+
+ // 获取当前日期
const getCurrentDate = () => {
var time = new Date()
var year = time.getFullYear()
@@ -101,21 +80,117 @@
minute
)}:${fillZero(second)}`
}
+
+ // 返回上一页
const handleBack = () => {
router.go(-1)
}
+
+ // 点击导航
const handleNav = (item, index) => {
- if (props.isSkip) {
+ if (isSkip.value) {
router.push(item.path)
} else {
emit('on-change', index)
}
}
+
+ // 获取天气数据
const getWeather = async () => {
let res = await getWeatherApi()
weatherData.value = res.data
- console.log(res, '====')
}
+
+ // 设置当前路由导航栏
+ const setNav = () => {
+ switch (router.currentRoute.value.path) {
+ case '/home':
+ title.value = '奉节县旅游指挥调度中心'
+ navLeft.value = [
+ { name: '安全', path: '/monitor' },
+ { name: '景区', path: '/scenic' },
+ { name: '交通', path: '/traffic' }
+ ]
+ navRight.value = [
+ { name: '停车' },
+ { name: '工单', path: '/workOrder' },
+ { name: '舆情', path: '/sentiment' },
+ { name: '酒店' }
+ ]
+ break
+ case '/scenic':
+ title.value = '景区'
+ navLeft.value = []
+ navRight.value = []
+ isBack.value = true
+ break
+ case '/sentiment':
+ title.value = '舆情检测'
+ navLeft.value = []
+ navRight.value = []
+ isBack.value = true
+ break
+ case '/workOrder':
+ title.value = '工单消息'
+ navLeft.value = []
+ navRight.value = []
+ isBack.value = true
+ break
+ case '/traffic':
+ title.value = '交通大屏'
+ navLeft.value = []
+ navRight.value = []
+ isBack.value = true
+ break
+ case '/monitor':
+ title.value = '监控大屏'
+ navLeft.value = [
+ {
+ name: '奉节县',
+ path: '/sceneTesting'
+ },
+ {
+ name: '三峡之巅',
+ path: '/sceneTesting'
+ },
+ {
+ name: '白帝城',
+ path: '/sceneTesting'
+ },
+ {
+ name: '龙河桥',
+ path: '/sceneTesting'
+ }
+ ]
+ navRight.value = [
+ {
+ name: '路段',
+ path: '/roadTesting'
+ },
+ {
+ name: '路段',
+ path: '/roadTesting'
+ },
+ {
+ name: '路段',
+ path: '/roadTesting'
+ },
+ {
+ name: '路段',
+ path: '/roadTesting'
+ }
+ ]
+ isBack.value = true
+ break
+ }
+ }
+ watch(
+ () => router.currentRoute.value,
+ () => {
+ setNav()
+ },
+ { immediate: true }
+ )
onMounted(() => {
getWeather()
getCurrentDate()
diff --git a/src/layout/index.vue b/src/layout/index.vue
new file mode 100644
index 0000000..51baf18
--- /dev/null
+++ b/src/layout/index.vue
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
diff --git a/src/router/index.js b/src/router/index.js
index 44041c6..626ba80 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,18 +1,50 @@
import { createRouter, createWebHistory } from 'vue-router'
import NotFound from '@/views/404/index.vue'
+import Layout from '@/layout/index.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
- name: 'home',
- component: () => import('@/views/home/index.vue')
- },
- {
- path: '/monitor',
- name: 'monitor',
- component: () => import('@/views/monitor/index.vue')
+ component: Layout,
+ redirect: '/home',
+ props(route) {
+ return route.query
+ },
+ children: [
+ {
+ path: 'home',
+ name: 'home',
+ meta: { title: '奉节县旅游指挥调度中心' },
+ component: () => import('@/views/home/index.vue')
+ },
+ {
+ path: '/monitor',
+ name: 'monitor',
+ component: () => import('@/views/monitor/index.vue')
+ },
+ {
+ path: '/scenic',
+ name: 'scenic',
+ component: () => import('@/views/scenic/index.vue')
+ },
+ {
+ path: 'sentiment',
+ name: 'sentiment',
+ component: () => import('@/views/sentiment/index.vue')
+ },
+ {
+ path: '/workOrder',
+ name: 'workOrder',
+ component: () => import('@/views/workOrder/index.vue')
+ },
+ {
+ path: '/traffic',
+ name: 'traffic',
+ component: () => import('@/views/traffic/index.vue')
+ }
+ ]
},
{
path: '/sceneTesting',
@@ -24,26 +56,6 @@ const router = createRouter({
name: 'roadTesting',
component: () => import('@/views/testing/road.vue')
},
- {
- path: '/scenic',
- name: 'scenic',
- component: () => import('@/views/scenic/index.vue')
- },
- {
- path: '/traffic',
- name: 'traffic',
- component: () => import('@/views/traffic/index.vue')
- },
- {
- path: '/sentiment',
- name: 'sentiment',
- component: () => import('@/views/sentiment/index.vue')
- },
- {
- path: '/workOrder',
- name: 'workOrder',
- component: () => import('@/views/workOrder/index.vue')
- },
{
path: '/404',
name: 'NotFound',
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 2deed68..ef23ee1 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -1,10 +1,10 @@
-
-
+
-
+
+ import box3 from './components/box-3.vue'
+ import box2 from './components/box-2.vue'
-
\ No newline at end of file
+ onMounted(() => {})
+
diff --git a/src/views/scenic/index.vue b/src/views/scenic/index.vue
index ec8dafb..24803c2 100644
--- a/src/views/scenic/index.vue
+++ b/src/views/scenic/index.vue
@@ -1,21 +1,11 @@
-
-
-
diff --git a/src/views/sentiment/index.vue b/src/views/sentiment/index.vue
index 559c9fb..502ec72 100644
--- a/src/views/sentiment/index.vue
+++ b/src/views/sentiment/index.vue
@@ -1,6 +1,4 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/views/workOrder/index.vue b/src/views/workOrder/index.vue
index caa89bd..5ee06e3 100644
--- a/src/views/workOrder/index.vue
+++ b/src/views/workOrder/index.vue
@@ -1,10 +1,7 @@
-
-
-