Explorar el Código

统一登陆接入

linqilong hace 4 meses
padre
commit
12178a8356

+ 0 - 1
src/components/TypicalChart.vue

@@ -90,7 +90,6 @@ onMounted(async () => {
 })
 
 watch(() => props.name, async (name) => {
-  debugger
   const data = await getTypicalData(props.stcd, name)
   reloadChart(data)
 })

+ 10 - 9
src/components/Video/video.ts

@@ -18,7 +18,7 @@ const videoCode = [
         "id": "0e873d77-3895-4156-81e9-b104bd4868f0",
         "pid": "06d3322e-eb7b-44e3-8371-a8712e40eee5",
         "name": "太师桥室外角球机",
-        "mark": "室外2",
+        "mark": "监控1",
         "code": "33048306531322000300",
       },
       {
@@ -32,7 +32,7 @@ const videoCode = [
         "id": "f4c33fc3-283c-457f-aec6-21b245c5f158",
         "pid": "06d3322e-eb7b-44e3-8371-a8712e40eee5",
         "name": "太师桥室外栈桥球机",
-        "mark": "室外",
+        "mark": "监控2",
         "code": "33048306531322000200",
       }
     ]
@@ -45,7 +45,7 @@ const videoCode = [
         "id": "df4a993b-a58d-4431-b3ca-4c3e5d68507f",
         "pid": "1c47a453-bde7-475a-8482-cadb4bc9c1b6",
         "name": "思源室外",
-        "mark": "室外",
+        "mark": "监控1",
         "code": "32050906531322002200",
       },
       {
@@ -60,12 +60,13 @@ const videoCode = [
 ]
 
 export function getVideoCodeByMark(stcd: string, mark: string) {
-  // const videos = videoCode.find(v => v.stcd === stcd)
-  // const video = videos?.children.find(v => v.mark === mark)
-  // return video?.code || null
-  const index = Math.floor(Math.random() * 4)
-  console.log(index)
-  return ['33042106531322001000', '33041106531322000100', '32050906531322002500', '33041106531322000300'][index]
+  const videos = videoCode.find(v => v.stcd === stcd)
+  const video = videos?.children.find(v => v.mark === mark)
+  return video?.code || null
+  // 随机视频(演示用的)
+  // const index = Math.floor(Math.random() * 4)
+  // console.log(index)
+  // return ['33042106531322001000', '33041106531322000100', '32050906531322002500', '33041106531322000300'][index]
 }
 
 function encryptPwd() {

+ 2 - 5
src/main.ts

@@ -7,10 +7,10 @@ import {VueSvgIconPlugin} from '@yzfe/vue-svgicon'
 import '@yzfe/svgicon/lib/svgicon.css'
 import ElementPlus from 'element-plus'
 import '@/assets/styles/element/index.scss'
-
-// @ts-ignore
 import App from './App.vue'
 import router from './router'
+import "./permission"; // permission control
+
 
 const app = createApp(App)
 
@@ -20,7 +20,4 @@ app.use(VueCookies)
 app.use(VueSvgIconPlugin, {tagName: 'icon'})
 app.use(ElementPlus)
 
-// 添加到vue对象上,可以在全局通过 this.$cookies来调用
-app.config.globalProperties.$cookies = VueCookies
-
 app.mount('#app')

+ 23 - 0
src/permission.ts

@@ -0,0 +1,23 @@
+import router from "./router";
+import {getToken} from "@/utils/auth";
+
+const whiteList = [
+  "/check",
+];
+
+router.beforeEach((to, from, next) => {
+  // 验证 TOKEN
+  if (getToken()) {
+    /* 登录成功 */
+    next();
+  } else {
+    /* 未登录 */
+    if (whiteList.indexOf(to.path) !== -1) {
+      // 在免登录白名单,直接进入
+      next();
+    } else {
+      // 否则全部重定向到登录页
+      window.location.href = 'http://10.8.11.123:8089/cas/login?service=http://localhost/check'
+    }
+  }
+});

+ 5 - 0
src/router/index.ts

@@ -9,6 +9,11 @@ const router = createRouter({
       redirect: '/index',
       component: layout,
       children: [
+        {
+          path: 'check',
+          name: 'check',
+          component: () => import('@/views/check.vue'),
+        },
         {
           path: 'index',
           name: 'home',

+ 2 - 1
src/utils/auth.ts

@@ -8,7 +8,8 @@ export function getToken() {
 }
 
 export function setToken(token: string) {
-  cookies.set(TokenKey, token)
+  // 12小时过期
+  cookies.set(TokenKey, token, 60 * 60 * 12)
 }
 
 export function removeToken() {

+ 2 - 4
src/views/Device.vue

@@ -28,7 +28,7 @@ const deviceType = computed(() => getDeviceTypeByName(route.params.deviceid))
 // 视频图片
 const videoImageSrc = new URL('@/assets/images/tmp/jiankong.png', import.meta.url).href
 // 获取视频CODE
-const videoCode = ref(getVideoCodeByMark(route.params.stcd + '', '室外'))
+const videoCode = ref(getVideoCodeByMark(route.params.stcd + '', route.params.deviceid + ""))
 
 
 const deviceStatusColumns = [
@@ -54,9 +54,7 @@ const accessoriesColumns = [
       return outday.diff(curday, 'days') + '天'
     }
   },
-  {
-    label: '到期时间', prop: 'warranty'
-  }
+  {label: '到期时间', prop: 'warranty'}
 ]
 const accessoriesData = ref([])
 // const accessoriesData = [

+ 1 - 1
src/views/Station.vue

@@ -24,7 +24,7 @@ const introduces = ref(station.value.detail?.split('\n'))
 const introduceImg = new URL(station.value.img, import.meta.url).href
 
 // 获取视频CODE
-const videoCode = ref(getVideoCodeByMark(route.params.stcd + '', "室外"))
+const videoCode = ref(getVideoCodeByMark(route.params.stcd + '', "监控1"))
 // 典型事件
 const typicalEvents = ref(getTypicalEvents(route.params.stcd))
 const typicalEventOptions = computed(() => typicalEvents.value.map(t => t.name))

+ 11 - 0
src/views/check.vue

@@ -0,0 +1,11 @@
+<script lang="ts" setup>
+import {useRoute, useRouter} from "vue-router";
+import {setToken} from "@/utils/auth";
+
+const route = useRoute()
+const router = useRouter()
+const ticket = route.query.ticket
+
+setToken('true')
+router.push('/')
+</script>