lvkun996 2 лет назад
Родитель
Сommit
98a2e8897e
4 измененных файлов с 180 добавлено и 183 удалено
  1. BIN
      cloudlink.zip
  2. 2 5
      src/main.ts
  3. 87 87
      src/pages/login/index.vue
  4. 91 91
      src/store/router.ts

+ 2 - 5
src/main.ts

@@ -41,7 +41,6 @@ window.Array.prototype.toMap = function (key: string, valueKey?: string): Map<st
   this.forEach(item => {
     _map.set(item[key], valueKey ? item[valueKey] : item)
   })
-
   return _map
 }
 
@@ -52,12 +51,10 @@ const render = (props: any = {}) => {
   const { container, data } = props
 
   if (window.__POWERED_BY_QIANKUN__) {
-    data.store.useJLYAppRouter().setChildrenSiderRoutes(routes.map(item => item.children).filter(_ => !!_))
+    data.store.useJLYAppRouter().setChildrenSiderRoutes(routes.map(item => item.children).filter(_ => !!_)[0])
   }
-  console.log('当前加载是qiankun么:', window.__POWERED_BY_QIANKUN__)
-  console.log('当前加载容器是否存在:', container)
+
   instance = createApp(App)
-  console.log('当前应用实例:', instance)
   instance.use(router)
     .use(pinia)
     .use(antd)

+ 87 - 87
src/pages/login/index.vue

@@ -1,87 +1,87 @@
-<template>
-  <a-row
-    style="width: 100vw; height: 100vh, overflow: hidden"
-    justify="center"
-  >
-    <a-col :span="16" style="height: 100vh;" >
-      <img
-        style="width: 100%; height: 100%; object-fit: cover"
-        :src='staticImg.loginBg'
-        alt=""
-      />
-    </a-col>
-    <a-col
-      :span="8"
-      style="display: flex; justify-content: center;align-items: center"
-      >
-      <a-row :gutter="[8, 8]" >
-        <a-col class="app-name" :span="24" style="display: flex;justify-content: center;">
-          蛟龙云联
-        </a-col>
-        <a-col :span="24" >
-          <a-form
-            name="basic"
-            :label-col="{ span: 8 }"
-            :wrapper-col="{ span: 16 }"
-            autocomplete="off"
-          >
-            <a-form-item
-              label="账号"
-              name="userAccount"
-              :rules="[{ required: true, message: '请填写账号' }]"
-            >
-              <a-input style="width: 328px;height: 42px;"  v-model:value="state.userAccount" />
-            </a-form-item>
-
-            <a-form-item
-              label="密码"
-              name="password"
-              :rules="[{ required: true, message: '请输入密码' }]"
-            >
-              <a-input-password  style="width: 328px;height: 42px;"   v-model:value="state.password" />
-            </a-form-item>
-          </a-form>
-        </a-col>
-        <a-col :span="24" style="display: flex;justify-content: center;">
-          <a-button @click="login" style="width: 200px;" type="primary" >登录</a-button>
-        </a-col>
-      </a-row>
-    </a-col>
-  </a-row>
-</template>
-<script lang='ts' setup >
-import { useUserStore } from '@/store/index'
-import { onUnmounted, reactive } from 'vue'
-import { useStaticImg } from '@/utils/static'
-
-// const { redirct_url } = useRoute().query
-
-const userStore = useUserStore()
-
-const staticImg = useStaticImg()
-
-window.addEventListener('keypress', event => {
-  if (event.key === 'Enter') login()
-})
-
-const state = reactive({
-  userAccount: '',
-  password: ''
-})
-
-const login = () => {
-  userStore.login(state)
-}
-
-onUnmounted(() => {
-  window.removeEventListener('keypress', () => {})
-})
-
-</script>
-<style lang='less' scoped >
-.app-name {
-  font: 40px 'Italiana', sans-serif;
-  text-transform: lowercase;
-  text-align: center;
-}
-</style>
+<template>
+  <a-row
+    style="width: 100vw; height: 100vh, overflow: hidden"
+    justify="center"
+  >
+    <a-col :span="16" style="height: 100vh;" >
+      <img
+        style="width: 100%; height: 100%; object-fit: cover"
+        :src='staticImg.loginBg'
+        alt=""
+      />
+    </a-col>
+    <a-col
+      :span="8"
+      style="display: flex; justify-content: center;align-items: center"
+      >
+      <a-row :gutter="[8, 8]" >
+        <a-col class="app-name" :span="24" style="display: flex;justify-content: center;">
+          蛟龙云联
+        </a-col>
+        <a-col :span="24" >
+          <a-form
+            name="basic"
+            :label-col="{ span: 8 }"
+            :wrapper-col="{ span: 16 }"
+            autocomplete="off"
+          >
+            <a-form-item
+              label="账号"
+              name="userAccount"
+              :rules="[{ required: true, message: '请填写账号' }]"
+            >
+              <a-input style="width: 328px;height: 42px;"  v-model:value="state.userAccount" />
+            </a-form-item>
+
+            <a-form-item
+              label="密码"
+              name="password"
+              :rules="[{ required: true, message: '请输入密码' }]"
+            >
+              <a-input-password  style="width: 328px;height: 42px;"   v-model:value="state.password" />
+            </a-form-item>
+          </a-form>
+        </a-col>
+        <a-col :span="24" style="display: flex;justify-content: center;">
+          <a-button @click="login" style="width: 200px;" type="primary" >登录</a-button>
+        </a-col>
+      </a-row>
+    </a-col>
+  </a-row>
+</template>
+<script lang='ts' setup >
+import { useUserStore } from '@/store/index'
+import { onUnmounted, reactive } from 'vue'
+import { useStaticImg } from '@/utils/static'
+
+// const { redirct_url } = useRoute().query
+
+const userStore = useUserStore()
+
+const staticImg = useStaticImg()
+
+window.addEventListener('keypress', event => {
+  if (event.key === 'Enter') login()
+})
+
+const state = reactive({
+  userAccount: '',
+  password: ''
+})
+
+const login = () => {
+  userStore.login(state)
+}
+
+onUnmounted(() => {
+  window.removeEventListener('keypress', () => {})
+})
+
+</script>
+<style lang='less' scoped >
+.app-name {
+  font: 40px 'Italiana', sans-serif;
+  text-transform: lowercase;
+  text-align: center;
+}
+</style>

+ 91 - 91
src/store/router.ts

@@ -1,91 +1,91 @@
-import { defineStore } from 'pinia'
-import { ConstantStore } from '@/enum/store'
-import { reactive, watch } from 'vue'
-import RootRouter from '@/router'
-import VueRouter, { RouteRecordRaw } from 'vue-router'
-
-const initAppRouterState: ROUTER.RouterRecords = {
-  navbar: {
-    route: [],
-    selectPath: []
-  },
-  sider: {
-    route: [],
-    selectPath: '',
-    openKeys: []
-  }
-}
-
-export const useAppRouter = defineStore(ConstantStore.ROUTER, () => {
-  const appRouter = reactive<ROUTER.RouterRecords>(initAppRouterState)
-
-  const routes = window.__POWERED_BY_QIANKUN__ ? RootRouter.options.routes[0].children : RootRouter.options.routes
-
-  const initAppRouter = () => {
-    appRouter.navbar.route = routes!.map((route: any) => {
-      return {
-        path: route.link ? route.path.substr(1) : route.path,
-        name: route.name,
-        link: !!route.link,
-        redirect: route.redirect || ''
-      }
-    }).filter(_ => _.path !== '/login')
-
-    appRouter.sider.route = routes![1].children!
-  }
-
-  if (appRouter.navbar.route.length === 0) {
-    initAppRouter()
-  }
-
-  const changeNavbarRoute = (route: ROUTER.RoutesProps) => {
-    if (route.link) {
-      window.open(route.path)
-    } else {
-      appRouter.navbar.selectPath = [route.path]
-      RootRouter.push(route.path)
-    }
-  }
-
-  // 根据当前子路由,逐级向上查找到根路由
-  function findRootRoute (data, path: string) {
-    const routes = RootRouter.options.routes as RouteRecordRaw[]
-
-    const getParentRouteByPath = (routes: RouteRecordRaw, path: string) => {
-      if (routes.children && routes.children.length > 0) {
-        const index = routes.children.findIndex(route => route.path === path)
-        return index >= 0
-      } else {
-        return false
-      }
-    }
-
-    const count = 0
-
-    const fn = (route: RouteRecordRaw) => {
-      const chidlren = route.children
-      if (!chidlren) {
-        console.log(route.path === path)
-        if (route.path === path) return true
-      } else {
-        for (let i = 0; i < chidlren.length; i++) {
-          fn(chidlren[i])
-        }
-      }
-    }
-
-    routes.forEach(route => {
-      console.log('fn(route):', fn(route))
-
-      if (fn(route)) {
-        console.log('寻找顶级及诶点:', route.path)
-      }
-    })
-  }
-
-  return {
-    router: appRouter,
-    changeNavbarRoute,
-    findRootRoute: (path) => findRootRoute(RootRouter.options.routes, path)
-  }
-})
+import { defineStore } from 'pinia'
+import { ConstantStore } from '@/enum/store'
+import { reactive, watch } from 'vue'
+import RootRouter from '@/router'
+import VueRouter, { RouteRecordRaw } from 'vue-router'
+
+const initAppRouterState: ROUTER.RouterRecords = {
+  navbar: {
+    route: [],
+    selectPath: []
+  },
+  sider: {
+    route: [],
+    selectPath: '',
+    openKeys: []
+  }
+}
+
+export const useAppRouter = defineStore(ConstantStore.ROUTER, () => {
+  const appRouter = reactive<ROUTER.RouterRecords>(initAppRouterState)
+
+  const routes = RootRouter.options.routes
+
+  const initAppRouter = () => {
+    appRouter.navbar.route = routes!.map((route: any) => {
+      return {
+        path: route.link ? route.path.substr(1) : route.path,
+        name: route.name,
+        link: !!route.link,
+        redirect: route.redirect || ''
+      }
+    }).filter(_ => _.path !== '/login')
+
+    appRouter.sider.route = routes as any
+  }
+
+  if (appRouter.navbar.route.length === 0) {
+    initAppRouter()
+  }
+
+  const changeNavbarRoute = (route: ROUTER.RoutesProps) => {
+    if (route.link) {
+      window.open(route.path)
+    } else {
+      appRouter.navbar.selectPath = [route.path]
+      RootRouter.push(route.path)
+    }
+  }
+
+  // 根据当前子路由,逐级向上查找到根路由
+  function findRootRoute (data, path: string) {
+    const routes = RootRouter.options.routes as RouteRecordRaw[]
+
+    const getParentRouteByPath = (routes: RouteRecordRaw, path: string) => {
+      if (routes.children && routes.children.length > 0) {
+        const index = routes.children.findIndex(route => route.path === path)
+        return index >= 0
+      } else {
+        return false
+      }
+    }
+
+    const count = 0
+
+    const fn = (route: RouteRecordRaw) => {
+      const chidlren = route.children
+      if (!chidlren) {
+        console.log(route.path === path)
+        if (route.path === path) return true
+      } else {
+        for (let i = 0; i < chidlren.length; i++) {
+          fn(chidlren[i])
+        }
+      }
+    }
+
+    routes.forEach(route => {
+      console.log('fn(route):', fn(route))
+
+      if (fn(route)) {
+        console.log('寻找顶级及诶点:', route.path)
+      }
+    })
+  }
+
+  return {
+    router: appRouter,
+    changeNavbarRoute,
+    findRootRoute: (path) => findRootRoute(RootRouter.options.routes, path)
+  }
+})