Kaynağa Gözat

fix: 删除无用代码

lvkun 2 yıl önce
ebeveyn
işleme
04b17bdd92

+ 0 - 2
src/components/CodeMirror/index.tsx

@@ -28,8 +28,6 @@ export const CodeMirrorTsx = defineComponent({
     const view = ref<EditorView>()
 
     const transDoc = () => {
-      console.log(' props.bodyType:', props.bodyType)
-
       return props.bodyType === 'javascript' ? props.bodyJson : JSON.stringify(JSON.parse(props.bodyJson), null, '\t')
     }
 

+ 0 - 5
src/components/FormPro/index.vue

@@ -129,9 +129,6 @@ const initFormPro = () => {
   }
 
   propsState.layout = props.layout ? props.layout : 'horizontal'
-  console.log('rulesRef:', rulesRef)
-
-  console.log('formProps:', formProps)
 }
 
 const modelRef = reactive<Record<string, any>>({})
@@ -141,7 +138,6 @@ const rulesRef = reactive<Record<string, any>>({})
 const formProps = reactive<FormItemProps[]>([])
 
 const onChange = (record: any, key: string) => {
-  console.log('form pro item change:', record)
   modelRef[key] = record
 }
 
@@ -159,7 +155,6 @@ const onSubmit = () => {
         resolve(modelRef)
       })
       .catch(err => {
-        console.log('error', err)
         reject(err)
       })
   })

+ 0 - 2
src/components/MicroComponents/index.tsx

@@ -76,8 +76,6 @@ export const IconTsx = defineComponent({
     }
   },
   setup (props, ctx) {
-    console.log('IconTsx:', props.name)
-
     return () => (
       <svg class="icon" aria-hidden="true" style={{ fill: '#fff' }} >
         <use style={{ fill: '#fff' }} xlinkHref={`#icon-${props.name}`}></use>

+ 0 - 1
src/layout/components/Sidebar/SidebarItem.vue

@@ -50,7 +50,6 @@ const changeRoute = (route: ROUTER.RoutesProps) => {
     window.open(route.path)
   } else {
     RootRouter.push(route.path)
-    appRouter.setCurrentRoute(route.path)
   }
 }
 

+ 22 - 21
src/layout/components/Sidebar/index.vue

@@ -11,14 +11,14 @@
           <img :src="logoPng" alt="">
         </div>
         <a-menu
-          v-model:selectedKeys="selectedKeys2"
+          v-model:selectedKeys="selectedKeys"
           :openKeys="openKeys"
           mode="inline"
           :style="{ borderRight: 0 }"
         >
           <sidebar-item
             :item="route"
-            v-for="route in appRouter.router.sider.route"
+            v-for="route in sidebarRoute"
             :key="route.path"
             :base-path="route.path"
           />
@@ -29,12 +29,10 @@
 
 <script lang="ts" setup >
 
-import { onMounted, ref, computed } from 'vue'
-import { useAppRouter } from '@/store/router'
+import { ref, computed, watch } from 'vue'
+
 import SidebarItem from './SidebarItem.vue'
 import { useRouter, useRoute } from 'vue-router'
-import { useEmitter } from '@/hooks'
-import { Emitter } from '@/enum'
 import { useDesignStore } from '@/store'
 
 const logoPng = require('@/assets/logo.png')
@@ -43,29 +41,32 @@ const designStore = useDesignStore()
 
 const bgColor = computed(() => designStore.theme ? '#141414' : '#fff')
 
-const appRouter = useAppRouter()
+const route = useRoute()
 
-const rootRouter = useRouter()
+const router = useRouter()
 
 const collapsed = ref<boolean>(false)
 
-const selectedKeys2 = ref<string[]>([appRouter.router.sider.selectPath])
-const openKeys = ref<string[]>(appRouter.router.sider!.openKeys)
-
-const emitter = useEmitter()
+const sidebarRoute = ref<any>()
 
-// 如果是产品类型这种 需要找到父节点 设置openKeys
-// 刷新后也需要打开openKeys
+const selectedKeys = ref<string[]>()
 
-emitter.on(Emitter.NAVBAR, () => {
-  selectedKeys2.value = [appRouter.router.sider.selectPath]
-})
+const openKeys = ref<string[]>()
 
-onMounted(() => {
-  selectedKeys2.value = [appRouter.currentRoute!]
+watch(
+  () => route.path,
+  () => {
+    sidebarRoute.value = router.getRoutes().find(item => item.path === route.matched[0].path)?.children
+    console.log('route.matched.', route.matched)
+    console.log(openKeys)
+    selectedKeys.value = [route.path]
+    openKeys.value = [route.matched[1].path]
+  },
+  {
+    immediate: true
+  }
+)
 
-  rootRouter.push(appRouter.currentRoute!)
-})
 </script>
 
 <style lang="less" scoped >

+ 5 - 45
src/layout/navbar.vue

@@ -31,28 +31,23 @@
 </template>
 
 <script lang="ts" setup >
-import { computed, onMounted, ref } from 'vue'
+import { computed, ref } from 'vue'
 import { useAppRouter } from '@/store/router'
 import user from './user.vue'
-import { useRouter, useRoute } from 'vue-router'
-import { routes } from '@/router/index'
+import { useRoute, useRouter } from 'vue-router'
 import { IconTsx } from '@/components/MicroComponents/index'
 import { useDesignStore } from '@/store'
 
-const logoPng = require('@/assets/logo.png')
+const route = useRoute()
 
 const router = useRouter()
 
-const route = useRoute()
-
 const appRouter = useAppRouter()
 
-const selectedKeys = ref<string[]>()
+const selectedKeys = ref<string[]>([route.matched[0].path])
 
 const designStore = useDesignStore()
 
-console.log('designStore:', !!designStore.theme, designStore.theme)
-
 const iconName = computed(() => designStore.theme ? 'sun' : 'moon')
 
 const headerBgColor = computed(() => designStore.theme ? '#141414' : '#fff')
@@ -66,48 +61,13 @@ const changeRouter = (route: ROUTER.RoutesProps) => {
     window.open(route.path)
   } else {
     selectedKeys.value = [route.path]
-    appRouter.changeNavbar(route.path, '')
+    router.push(route.path)
   }
 }
 
-const hasCurrentRourte = (children: ROUTER.RoutesProps[]): boolean => {
-  let r = false
-  children.forEach(item => {
-    if (item.path === route.path) {
-      r = true
-    }
-
-    if (item.children && item.children.length) {
-      item.children.forEach(_ => {
-        if (_.path === route.path) {
-          r = true
-        }
-      })
-    }
-  })
-
-  return r
-}
-
-onMounted(() => {
-  routes.forEach(item => {
-    if (item.children && hasCurrentRourte(item.children)) {
-      selectedKeys.value = [item.path]
-      appRouter.changeNavbar(item.path, 'init')
-      appRouter.changeSiderRoute()
-    }
-  })
-})
-
 </script>
 
 <style lang="less" scoped >
-.header {
-  // width: 100%;
-  // position: absolute;
-  // z-index: 2;
-  // background-color: #fff;
-}
 
 .df-center {
   display: flex;

+ 0 - 3
src/pages/Iot/dashboard/deviceAccess/index.vue

@@ -111,12 +111,10 @@ const sourceList = reactive([
 
 const getStatisList = async () => {
   ModelController.count().then(r => {
-    console.log('ModelController:', r.data)
     sourceList[0].value = r.data.TOTAL
   })
 
   DeviceContriller.count().then(r => {
-    console.log('DeviceContriller', r.data)
     sourceList[3].value = r.data.TOTAL
     sourceList[4].value = r.data.CONNECT
     sourceList[5].value = r.data.INIT
@@ -128,7 +126,6 @@ const getStatisList = async () => {
 
   RuleController.linkCount().then(r => {
     sourceList[2].value = r.data.TOTAL
-    console.log('RuleController:', r.data)
   })
 }
 

+ 5 - 51
src/store/router.ts

@@ -31,74 +31,28 @@ const initAppRouterState: ROUTER.RouterRecords = {
 export const useAppRouter = defineStore(ConstantStore.ROUTER, () => {
   const appRouter = reactive<ROUTER.RouterRecords>(initAppRouterState)
 
-  const [currentRoute, setCurrentRoute] = useSessionStorageState<string>('currentRoute', {
-    defaultValue: '/'
-  })
-
-  const siderRoutes = computed(() => RootRouter.getRoutes().find(item => item.path === appRouter.navbar!.selectPath)?.children)
-
   const initAppRouter = () => {
-    console.log('initAppRouter')
-
     appRouter.navbar.route = RootRouter.options.routes.map((route: any) => {
-      console.log(route.link, route.path)
-
       return {
         path: route.link ? route.path.substr(1) : route.path,
         name: route.name,
-        link: !!route.link
+        link: !!route.link,
+        redirect: route.redirect || ''
       }
     })
 
-    // appRouter.navbar.selectPath = RootRouter.options.routes[0].path
-    appRouter.navbar.selectPath = currentRoute.value!
-
-    appRouter.sider.route = siderRoutes.value!
-
-    appRouter.sider.selectPath = currentRoute.value!
+    appRouter.sider.route = RootRouter.options.routes[0].children!
   }
 
-  const changeNavbar = (path: string, key: 'init' | '' = '') => {
-    console.log('changeNavbar:', path, currentRoute.value)
-
+  const changeNavbar = (path: string) => {
     RootRouter.push(path)
-    appRouter.navbar.selectPath = path
-    setCurrentRoute(key === 'init' ? currentRoute.value! : siderRoutes.value![0].path)
-  }
-
-  watch(
-    () => RootRouter.currentRoute.value.path,
-    () => changeSiderRoute()
-  )
-
-  const changeSiderRoute = () => {
-    appRouter.sider = {
-      route: RootRouter.getRoutes().find(item => item.path === appRouter.navbar!.selectPath)?.children as ROUTER.RoutesProps[],
-      selectPath: RootRouter.currentRoute.value.path,
-      openKeys: RootRouter.currentRoute.value.matched.map(item => item.path)
-    }
-    emitter.emit(Emitter.NAVBAR)
   }
 
   if (appRouter.navbar.route.length === 0) {
     initAppRouter()
   }
 
-  const cancheCurrentRoute = () => {
-    appRouter.sider.selectPath = currentRoute.value!
-    // RootRouter.push(currentRoute.value!)
-  }
-
-  // 通过session store 保存当前的路由 防止刷新丢失路由
-  onMounted(() => {
-    cancheCurrentRoute()
-  })
-
   return {
-    router: appRouter,
-    currentRoute,
-    changeNavbar,
-    changeSiderRoute,
-    setCurrentRoute
+    router: appRouter
   }
 })

+ 1 - 0
vue.config.js

@@ -26,4 +26,5 @@ module.exports = defineConfig({
       }
     }
   }
+
 })

Dosya farkı çok büyük olduğundan ihmal edildi
+ 314 - 314
yarn.lock


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor