gongjinbao
2025-01-08 68710587304644b9abf3e2de34d13e4dadaad9d6
Merge branch 'main' of http://120.76.84.145:10101/gitblit/r/H5/americanContainer
1个文件已删除
3个文件已修改
2个文件已添加
141 ■■■■ 已修改文件
src/App.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layouts/components/AppContent.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layouts/index.vue 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/routers.js 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/view/Login.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/App.vue
@@ -1,6 +1,6 @@
<template>
  <div id="app">
    <<router-view />
    <router-view />
  </div>
</template>
@@ -14,7 +14,7 @@
    return {
    };
  },
  created() {},
  created() { },
  mounted() {
  },
  methods: {},
src/layouts/components/AppContent.vue
New file
@@ -0,0 +1,5 @@
<template>
  <div>
    <router-view />
  </div>
</template>
src/layouts/index.vue
New file
@@ -0,0 +1,52 @@
<template>
  <div style="height: 100%;">
    <!-- 判断是否在空白页打开 -->
    <template v-if="!isOneself">
      <div class="app-wrapper">
      </div>
    </template>
    <!-- 如果在空白页打开则不显示框架 -->
    <template v-else>
      <AppContent />
    </template>
  </div>
</template>
<script>
import AppContent from './components/AppContent.vue'
export default {
  data() {
    return {
      // 默认页面在框架内显示
      isOneself: false,
      // 获取当前页面名称
      nowRouteName: '',
    }
  },
  components: {
    AppContent,
  },
  mounted() {
    // 设置标题
    this.setNowRouteName(this.$route)
    // 初始化加载一次判断是否在空白页打开
    this.isOneself = this.$route.meta.oneself
  },
  methods: {
    // 获取当前页面标题
    setNowRouteName(route) {
      this.nowRouteName = route.meta.title
    },
  },
  watch: {
    // 监听route变化
    $route: function (newVal) {
      this.setNowRouteName(newVal)
      // 判断页面是否在空白页打开
      this.isOneself = newVal.meta.oneself
    },
  },
}
</script>
<style lang="less" scoped></style>
src/router/index.js
@@ -1,26 +1,49 @@
import Vue from 'vue'
import Router from 'vue-router'
import routers from './routers';
import Vue from "vue";
import VueRouter from "vue-router";
import Layouts from "../layouts";
const changePush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return changePush.call(this, location).catch((err) => err);
};
Vue.use(Router);
const createRouter = () => new Router({
  mode: 'hash', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes: routers
})
const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router
/**
 *  path: "/login",   ------页面地址
    component: () => import("../views/login"),  ------组件地址
    meta: {
      title: "登录",    ------页面标题
      icon: "el-icon-user-solid",  ------菜单图标
      oneself: true,  ------是否在单独页面打开
      hide: true,  ------是否隐藏改菜单
    }
 */
const routes = [
  {
    path: "",
    redirect: "login",
    component: Layouts,
    children: [
      {
        path: "/login",
        meta: {
          title: "登录",
          oneself: true,
          hide: true,
          privilege: 'login'
        },
        component: () => import("../view/login"),
      },
    ]
  }
];
const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});
export default router;
src/router/routers.js
File was deleted
src/view/Login.vue
@@ -1,5 +1,6 @@
<template>
    <div class="content">
        1
    </div>
</template>