Browse Source

修复频道历史无法打开的问题,修改route

vothin 1 năm trước cách đây
mục cha
commit
14258a9909
4 tập tin đã thay đổi với 255 bổ sung112 xóa
  1. 124 0
      src/color/colorChange.js
  2. 3 0
      src/color/elementUiCSS.js
  3. 127 111
      src/router/index.js
  4. 1 1
      src/store/modules/permission.js

+ 124 - 0
src/color/colorChange.js

@@ -0,0 +1,124 @@
+/**
+ * 获取一系列 主题色
+ * 入参:67c23a
+ * 结果:['67c23a', '103,194,58', '#76c84e', '#85ce61', '#95d475', '#a4da89', '#b3e19d', '#c2e7b0', '#d1edc4', '#e1f3d8', '#f0f9eb', '#5daf34']
+ */
+function getThemeCluster(theme, type = '') {
+  const tintColor = (color, tint) => {
+    let red = parseInt(color.slice(0, 2), 16)
+    let green = parseInt(color.slice(2, 4), 16)
+    let blue = parseInt(color.slice(4, 6), 16)
+
+    if (tint === 0) {
+      // when primary color is in its rgb space
+      return [red, green, blue].join(',')
+    } else {
+      red += Math.round(tint * (255 - red))
+      green += Math.round(tint * (255 - green))
+      blue += Math.round(tint * (255 - blue))
+
+      red = red.toString(16)
+      green = green.toString(16)
+      blue = blue.toString(16)
+
+      return `#${red}${green}${blue}`
+    }
+  }
+
+  const shadeColor = (color, shade) => {
+    let red = parseInt(color.slice(0, 2), 16)
+    let green = parseInt(color.slice(2, 4), 16)
+    let blue = parseInt(color.slice(4, 6), 16)
+
+    red = Math.round((1 - shade) * red)
+    green = Math.round((1 - shade) * green)
+    blue = Math.round((1 - shade) * blue)
+
+    red = red.toString(16)
+    green = green.toString(16)
+    blue = blue.toString(16)
+
+    return `#${red}${green}${blue}`
+  }
+
+  const clusters = [theme]
+  for (let i = 0; i <= 9; i++) {
+    clusters.push(tintColor(theme, Number((i / 10).toFixed(2))))
+  }
+  clusters.push(shadeColor(theme, 0.1))
+  // 这行代码是我自己后面的其他优化所需,可删
+  if (type && type === 'new' && clusters.length) {
+    clusters.forEach((theme, index) => {
+      if (index > 1) {
+        document.body.style.setProperty(`--theme-weaken-color-${index}`, clusters[index]) // 逐渐淡化颜色
+      }
+    })
+    console.log('主题色系-------------------', clusters)
+  }
+  return clusters
+}
+
+/**
+ * @param style 老的css样式代码
+ * @param oldCluster 老的一些列主题色  待替换
+ * @param newCluster 新的一系列主题色  替换成
+ *
+ * @returns newStyle 新的 css样式代码 替换后的
+ */
+function updateStyle(style, oldCluster, newCluster) {
+  let newStyle = style
+  oldCluster.forEach((color, index) => {
+    // 将老颜色替换成新颜色
+    newStyle = newStyle.replace(new RegExp(color, 'ig'), newCluster[index].trim()) // 全局替换 不区分大小写 去掉多余空格
+  })
+  return newStyle
+}
+
+/**
+ * main
+ */
+import ElementUiCSS from './elementUiCSS.js' // 就是上文说的默认样式 index.css; (字符串)
+export const updateThemeColor = function(val) {
+  if (typeof val !== 'string' || val.length === 0) return
+  const ORIGINAL_THEME = '#409EFF' // default color (element ui的默认主题色,所有我们根据这个去改)
+  const ThemeCode = ElementUiCSS
+    .replace(/@font-face{[^}]+}/g, '') // 去掉字体样式
+    .replace(/.el-icon-[a-zA-Z0-9-:^]+before{content:"[^}]+}/g, '') // 去掉图标样式
+    // require('element-ui/lib/theme-chalk/index.css')
+
+  console.log('updateThemeColor ------------------------ in')
+  console.log('ORIGINAL_THEME', ORIGINAL_THEME)
+  // try {
+  //   console.log('ThemeCode', ThemeCode)
+  //   console.log('ThemeCode', String(ThemeCode))
+  //   console.log('ThemeCode', ThemeCode.innerText)
+  // } catch (error) {
+  //   console.log(error)
+  // }
+  // 得到一系列 主题色颜色 (我们需要的颜色 '产出')
+  const themeCluster = getThemeCluster(val.replace('#', ''), 'new')
+  /**
+     * 入参:'chalk'(旧css代码), 'chalk-style'(style的id)
+     * 直接 将老的 css 代码里 待改的旧颜色改成 新颜色 然后将新的样式 插入到head标签里
+     */
+  const getHandler = id => {
+    return () => {
+      // 得到一系列 主题色颜色 (原始的一些列颜色  待改)
+      const originalCluster = getThemeCluster(ORIGINAL_THEME.replace('#', ''))
+      const newStyle = updateStyle(ThemeCode, originalCluster, themeCluster)
+      // console.log('newStyle', newStyle)
+
+      let styleTag = document.getElementById(id)
+      if (!styleTag) {
+        styleTag = document.createElement('style')
+        styleTag.setAttribute('id', id)
+        document.head.appendChild(styleTag)
+      }
+      styleTag.innerText = newStyle
+    }
+  }
+  const chalkHandler = getHandler('chalk-style')
+  chalkHandler()
+
+  console.log('updateThemeColor ------------------------ end')
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 3 - 0
src/color/elementUiCSS.js


+ 127 - 111
src/router/index.js

@@ -93,95 +93,100 @@ export const partRoutes = [
       component: () => import('@/views/ncs-clerk-frame-manage/index'),
       name: 'clerk-frame-manage',
       meta: { title: i18n.t('tab.staffManageFrames'), icon: 'frame_manage', noCache: true }
-    }, {
-      path: 'device',
-      name: 'part-device',
-      component: () => import('@/views/ncs-device/index'),
-      redirect: '/frame/device/list',
-      meta: {
-        title: i18n.t('deviceManage.deviceManage'),
-        icon: 'devices'
-      },
-      children: [
-        {
-          path: 'list',
-          component: () => import('@/views/ncs-device/deviceManagement'),
-          name: 'device-list',
-          meta: { title: i18n.t('tab.deviceManage'), icon: 'component', noCache: true } // 所有设备
-        },
-        {
-          path: 'mobile',
-          component: () => import('@/views/ncs-device/nurse_watch'),
-          name: 'device-mobile',
-          hidden: !enableMobile,
-          meta: { title: i18n.t('tab.mobileDeviceManage'), icon: 'el-icon-watch', noCache: true } // 移动设备
-        },
-        {
-          path: 'user_watch',
-          component: () => import('@/views/ncs-device/user_watch'),
-          name: 'user-watch',
-          hidden: !enableCustomerDevice,
-          meta: { title: i18n.t('tab.userLocationManage'), icon: 'el-icon-watch-1', noCache: true } // 用户设备
-        },
-        {
-          path: 'sos',
-          component: () => import('@/views/ncs-sos-device-setting/sos_device_setting'),
-          name: 'sos-device',
-          hidden: !enableSosDevice,
-          meta: { title: i18n.t('tab.sosDeviceSettingManage'), icon: 'el-icon-s-help', noCache: true } // 报警设备
-        },
-        {
-          path: 'map',
-          component: () => import('@/views/customer/myMapHtml'),
-          name: 'device-map',
-          meta: { title: i18n.t('customerManage.footprint'), icon: 'area', noCache: true }, // 足迹
-          hidden: true
-        },
-        {
-          path: 'nbdevice_condition',
-          component: () => import('@/views/ncs-device/nbDeviceCondition'),
-          name: 'nbdevice-condition',
-          meta: { title: i18n.t('tab.nbiotDeviceStatus'), icon: 'iot', noCache: true },
-          hidden: !enableNBiot
-        },
-        {
-          path: 'information_board',
-          component: () => import('@/views/calling-board/index'),
-          name: 'information-board',
-          meta: { title: i18n.t('tab.boardManage'), icon: 'infomation_board', noCache: true },
-          hidden: uiVersion === 2
-        },
-        {
-          path: 'custom_infoboard',
-          component: () => import('@/views/custom-infoboard/board-title'),
-          name: 'board-title',
-          meta: { title: i18n.t('tab.customBoardManage'), icon: 'designer', noCache: true },
-          hidden: uiVersion === 2
-        },
-        {
-          path: 'device_menu',
-          component: () => import('@/views/ncs-device-menu/index'),
-          name: 'device-menu',
-          meta: { title: i18n.t('tab.deviceMenuManager'), icon: 'el-icon-menu', noCache: true }
-        },
-        // {
-        //   path: 'led',
-        //   component: () => import('@/views/ncs-led/ledDeviceManagement'),
-        //   name: 'led-manager',
-        //   meta: { title: i18n.t('tab.ledDeviceManager'), icon: 'led', noCache: true },
-        //   hidden: uiVersion === 2
-        // },
-        {
-          path: 'led-control',
-          component: () => import('@/views/ncs-led/ledControl'),
-          name: 'led-control',
-          meta: { title: i18n.t('tab.ledDevice'), icon: 'el-icon-message-solid', noCache: true }, // LED点阵屏
-          hidden: true
-        }
-      ]
     }
     ]
   },
+  {
+    path: '/device',
+    name: 'part-device',
+    component: Layout,
+    redirect: '/device/list',
+    meta: { title: i18n.t('deviceManage.deviceManage'), icon: 'devices' },
+    children: [
+      {
+        path: 'list',
+        component: () => import('@/views/ncs-device/deviceManagement'),
+        name: 'device-list',
+        meta: { title: i18n.t('tab.deviceManage'), icon: 'component', noCache: true } // 所有设备
+      },
+      {
+        path: 'mobile',
+        component: () => import('@/views/ncs-device/nurse_watch'),
+        name: 'device-mobile',
+        hidden: !enableMobile,
+        meta: { title: i18n.t('tab.mobileDeviceManage'), icon: 'el-icon-watch', noCache: true } // 移动设备
+      },
+      {
+        path: 'user_watch',
+        component: () => import('@/views/ncs-device/user_watch'),
+        name: 'user-watch',
+        hidden: !enableCustomerDevice,
+        meta: { title: i18n.t('tab.userLocationManage'), icon: 'el-icon-watch-1', noCache: true } // 用户设备
+      },
+      {
+        path: 'sos',
+        component: () => import('@/views/ncs-sos-device-setting/sos_device_setting'),
+        name: 'sos-device',
+        hidden: !enableSosDevice,
+        meta: { title: i18n.t('tab.sosDeviceSettingManage'), icon: 'el-icon-s-help', noCache: true } // 报警设备
+      },
+      {
+        path: 'map',
+        component: () => import('@/views/customer/myMapHtml'),
+        name: 'device-map',
+        meta: { title: i18n.t('customerManage.footprint'), icon: 'area', noCache: true }, // 足迹
+        hidden: true
+      },
+      {
+        path: 'nbdevice_condition',
+        component: () => import('@/views/ncs-device/nbDeviceCondition'),
+        name: 'nbdevice-condition',
+        meta: { title: i18n.t('tab.nbiotDeviceStatus'), icon: 'iot', noCache: true },
+        hidden: !enableNBiot
+      },
+      {
+        path: 'information_board',
+        component: () => import('@/views/calling-board/index'),
+        name: 'information-board',
+        meta: { title: i18n.t('tab.boardManage'), icon: 'infomation_board', noCache: true },
+        hidden: uiVersion === 2
+      },
+      {
+        path: 'custom_infoboard',
+        component: () => import('@/views/custom-infoboard/board-title'),
+        name: 'board-title',
+        meta: { title: i18n.t('tab.customBoardManage'), icon: 'designer', noCache: true },
+        hidden: uiVersion === 2
+      },
+      {
+        path: 'index/:id?',
+        component: () => import('@/views/custom-infoboard/infoboard-designer'), // 自定义看板 component: () => import('@/views/custom-infoboard/infoboard-designer'),资阳 component: () => import('@/views/custom-infoboard/screen-designer')
+        name: 'infoboard-designer-manager',
+        meta: { title: i18n.t('tab.customBoardDesigner'), icon: 'el-icon-data-board', noCache: true },
+        hidden: true
+      },
+      {
+        path: 'device_menu',
+        component: () => import('@/views/ncs-device-menu/index'),
+        name: 'device-menu',
+        meta: { title: i18n.t('tab.deviceMenuManager'), icon: 'el-icon-menu', noCache: true }
+      },
+      // {
+      //   path: 'led',
+      //   component: () => import('@/views/ncs-led/ledDeviceManagement'),
+      //   name: 'led-manager',
+      //   meta: { title: i18n.t('tab.ledDeviceManager'), icon: 'led', noCache: true },
+      //   hidden: uiVersion === 2
+      // },
+      {
+        path: 'led-control',
+        component: () => import('@/views/ncs-led/ledControl'),
+        name: 'led-control',
+        meta: { title: i18n.t('tab.ledDevice'), icon: 'el-icon-message-solid', noCache: true }, // LED点阵屏
+        hidden: true
+      }
+    ]
+  },
   // 职员相关
   {
     path: '/clerk',
@@ -327,20 +332,22 @@ export const partRoutes = [
         hidden: true
       }
     ]
-  }, {
-    path: '/infoboard_designer',
-    component: Layout,
-    name: 'infoboard-designer',
-    children: [
-      {
-        path: 'index/:id?',
-        component: () => import('@/views/custom-infoboard/infoboard-designer'), // 自定义看板 component: () => import('@/views/custom-infoboard/infoboard-designer'),资阳 component: () => import('@/views/custom-infoboard/screen-designer')
-        name: 'infoboard-designer-manager',
-        meta: { title: i18n.t('tab.customBoardDesigner'), icon: 'el-icon-data-board', noCache: true }
-      }
-    ],
-    hidden: true
-  }, {
+  },
+  // {
+  //   path: '/infoboard_designer',
+  //   component: Layout,
+  //   name: 'infoboard-designer',
+  //   children: [
+  //     {
+  //       path: 'index/:id?',
+  //       component: () => import('@/views/custom-infoboard/infoboard-designer'), // 自定义看板 component: () => import('@/views/custom-infoboard/infoboard-designer'),资阳 component: () => import('@/views/custom-infoboard/screen-designer')
+  //       name: 'infoboard-designer-manager',
+  //       meta: { title: i18n.t('tab.customBoardDesigner'), icon: 'el-icon-data-board', noCache: true }
+  //     }
+  //   ],
+  //   hidden: true
+  // },
+  {
     path: '/settings',
     component: Layout,
     redirect: '/settings/index',
@@ -361,18 +368,27 @@ export const partRoutes = [
         name: 'nurse-config',
         meta: { title: i18n.t('tab.nurseConfig'), icon: 'care1', noCache: true }, // 护理参数
         hidden: uiVersion !== 1
-      }, {
+      },
+      {
         path: 'channel',
-        component: () => import('@/views/ncs-channel/index'),
+        component: () => import('@/views/hospitalFrame/index'),
         name: 'channel',
+        redirect: '/settings/channel/index',
         meta: { title: i18n.t('tab.channelManage'), icon: 'el-icon-mobile-phone', noCache: true },
-        children: [{
-          path: 'history/:id?',
-          component: () => import('@/views/ncs-channel/channelImHistory'),
-          name: 'channel-im-history',
-          meta: { title: i18n.t('tab.channelImHistory'), icon: 'area', noCache: true },
-          hidden: true
-        }
+        children: [
+          {
+            path: 'index',
+            component: () => import('@/views/ncs-channel/index'),
+            name: 'channel-im',
+            meta: { title: i18n.t('tab.channelManage'), icon: 'el-icon-mobile-phone', noCache: true }
+          },
+          {
+            path: 'history/:id?',
+            component: () => import('@/views/ncs-channel/channelImHistory'),
+            name: 'channel-im-history',
+            meta: { title: i18n.t('tab.channelImHistory'), icon: 'area', noCache: true },
+            hidden: true
+          }
         ]
       }, {
         path: 'event_list',
@@ -673,7 +689,7 @@ export const adminRoutes = [
         meta: { title: i18n.t('tab.systemConfig'), icon: 'nested', noCache: true }
       }
     ]
-  },{
+  }, {
     path: '/menu',
     component: Layout,
     redirect: '/menu/index',
@@ -696,7 +712,7 @@ export const adminRoutes = [
         component: () => import('@/views/ncs-orginazition/index'),
         name: 'admin-organization',
         meta: { title: i18n.t('tab.organization'), icon: 'tree', noCache: true }
-      },{
+      }, {
         path: 'index/:id?',
         component: () => import('@/views/ncs-orginazition/partInfoSetting'),
         name: 'admin-part-settings',

+ 1 - 1
src/store/modules/permission.js

@@ -83,7 +83,7 @@ const actions = {
               commit('SET_ROUTES', lastRoutes)
               resolve(lastRoutes)
             })
-          }          
+          }
         }
       }
     })