尚融宝13-后台管理系统前端架构梳理

目录

一、程序入口

(一)入口页面 index.html

(二) 入口js脚本:src/main.js

(三)顶层组件:src/App.vue

(四)路由:src/router/index.js 


一、程序入口

(一)入口页面 index.html

查看源代码

这正是srb-admin/public/index.html

 

 我们进入积分等级列表,查看源代码会发现仍然是index.html中的代码

 那么它是怎么实现页面的不同加载的呢?答案:通过脚本

(二) 入口js脚本:src/main.js

上面的脚本中的路径/static/js/app.js我们在文件目录中找不到,因为它是根据我们的vue文件、html文件、js文件等动态生成的,真正的文件是src/main.js

查看代码我们发现其导入了很多模块,就像我们后端创建springboot项目,使用某些功能需要导入对于的starter一样,即导入依赖

 这里挂载element-ui可以像我们前面做例子那样直接使用<script src="https://unpkg.com/element-ui/lib/index.js"></script>导入,但是这样只能使用简单的template定义

而无法使用vue文件式的template定义 

创建Vue对象,指定渲染的是入口index.html中id为app的div

(三)顶层组件:src/App.vue

 既然创建的Vue对象将我们的app组件进行渲染,我们就去看一下App.vue

(四)路由:src/router/index.js 

有一个router-view路由出口,是进行模板template展示的 ,在router/index.js中定义了大量的路由,当我们访问对应path就会跳到对应的组件同时显示到id为app的div中

import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  // 路由列表
  {
    //
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true,
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '首页', icon: 'dashboard' },
      },
    ],
  },

  {
    path: '/core/integral-grade',
    component: Layout,
    redirect: '/core/integral-grade/list',
    name: 'coreIntegralGrade',
    meta: { title: '积分等级管理', icon: 'el-icon-s-marketing' },
    //false(默认):当父节点下只有一个子节点时,不显示父节点,直接显示子节点
    //true:任何时候都显示父节点和子节点
    alwaysShow: true,
    children: [
      {
        path: 'list',
        name: 'coreIntegralGradeList', // 每个路由的name不能相同
        component: () => import('@/views/core/integral-grade/list'), // 指向的template模板
        meta: { title: '积分等级列表' }, // 定义导航的标题
      },
      {
        path: 'create',
        name: 'coreIntegralGradeCreate',
        component: () => import('@/views/core/integral-grade/form'),
        meta: { title: '新增积分等级' },
      },
      {
        path: 'edit/:id', // :id表示一个占位符,表示这一部分url会是任何一个id,是动态的
        name: 'coreIntegralGradeEdit',
        component: () => import('@/views/core/integral-grade/form'),
        meta: { title: '编辑积分等级' },
        hidden: true,
      },
    ],
  },

  {
    path: '/core',
    component: Layout,
    redirect: '/core/dict/list',
    name: 'coreDict',
    meta: { title: '系统设置', icon: 'el-icon-setting' },
    alwaysShow: true,
    children: [
      {
        path: 'dict/list',
        name: '数据字典',
        component: () => import('@/views/core/dict/list'),
        meta: { title: '数据字典' },
      },
    ],
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: '例子', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: '表格', icon: 'table' },
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: '树', icon: 'tree' },
      },
    ],
  },

  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: '表单', icon: 'form' },
      },
    ],
  },
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: 'Nested',
      icon: 'nested',
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: 'Menu1' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: 'Menu1-1' },
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'Menu1-2',
            meta: { title: 'Menu1-2' },
            children: [
              {
                path: 'menu1-2-1',
                component: () =>
                  import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                name: 'Menu1-2-1',
                meta: { title: 'Menu1-2-1' },
              },
              {
                path: 'menu1-2-2',
                component: () =>
                  import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                name: 'Menu1-2-2',
                meta: { title: 'Menu1-2-2' },
              },
            ],
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: { title: 'Menu1-3' },
          },
        ],
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        meta: { title: 'menu2' },
      },
    ],
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' },
      },
    ],
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true },
]

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes,
  })

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router

 以下面为例, 当我们访问http://localhost:9528/login,会找到/views/login/index.vue页面进行展示

  // 路由列表
  {
    //
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
  },

梳理到这里,我们可以知道最外层组件是App,在App中嵌套了其他组件,当我们访问不同页面,App中的组件会变换,比如我们在登录页面,App下是login组件

那么这些 侧边栏、导航栏和主页面是如何组成的呢?

 查看src/layout/index.vue我们可以发现是在这里组装起来的

<template>
  <div :class="classObj" class="app-wrapper">
    <div
      v-if="device === 'mobile' && sidebar.opened"
      class="drawer-bg"
      @click="handleClickOutside"
    />
    <!--侧边栏-->
    <sidebar class="sidebar-container" />
    <!-- <Sidebar/> 同理 -->
    <div class="main-container">
      <div :class="{ 'fixed-header': fixedHeader }">
        <!--导航栏-->
        <navbar />
        <!-- <Navbar />  实际上是这样写,直接使用组件,但是小写也支持,所以写成上一行的写法 -->
      </div>
      <!--主内容区-->
      <app-main />
      <!-- <AppMain/> 同理 -->
    </div>
  </div>
</template>

<script>
// 导入子组件
import { Navbar, Sidebar, AppMain } from './components'
import ResizeMixin from './mixin/ResizeHandler'

export default {
  name: 'Layout',
  components: {
    //注册子组件
    Navbar,
    Sidebar,
    AppMain,
  },
  mixins: [ResizeMixin],
  computed: {
    sidebar() {
      return this.$store.state.app.sidebar
    },
    device() {
      return this.$store.state.app.device
    },
    fixedHeader() {
      return this.$store.state.settings.fixedHeader
    },
    classObj() {
      return {
        hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened,
        withoutAnimation: this.sidebar.withoutAnimation,
        mobile: this.device === 'mobile',
      }
    },
  },
  methods: {
    handleClickOutside() {
      this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
    },
  },
}
</script>

<style lang="scss" scoped>
@import '~@/styles/mixin.scss';
@import '~@/styles/variables.scss';

.app-wrapper {
  @include clearfix;
  position: relative;
  height: 100%;
  width: 100%;
  &.mobile.openSidebar {
    position: fixed;
    top: 0;
  }
}
.drawer-bg {
  background: #000;
  opacity: 0.3;
  width: 100%;
  top: 0;
  height: 100%;
  position: absolute;
  z-index: 999;
}

.fixed-header {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 9;
  width: calc(100% - #{$sideBarWidth});
  transition: width 0.28s;
}

.hideSidebar .fixed-header {
  width: calc(100% - 54px);
}

.mobile .fixed-header {
  width: 100%;
}
</style>

总结:App组件下面有layout组件、layout组件下有Sidebar、Navbar、AppMain组件

 

 Appmain是怎么实现内容的变换的,又是一个子路由 

 总结:入口index.html中有一个id为app的div,App.vue里导入需要的模块,创建一个根组件App,App中有一个路由出口,根据router/index.html中定义的路由进行跳转。在主页面也就是layout/index.html中将侧边栏Sidebar,导航栏Navbar和主内容区AppMain结合,这三个也是组件,AppMain中有子路由出口,对应router中index.html中的children。

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论
CMS后台管理系统 使用必读: 1、安装:请仔细超博CMS帮助文档。 配置好站点后, 进入以下路径安装http://站点名(域名)/admins/Install/index.htm,详见帮助"自定义开发"部分。 2、管理:请仔细超博CMS帮助文档 >> 自定义开发 >>后台主要管理模块和设置区部分 后台管理登陆地址为:http://域名/admins/login.aspx,默认的帐号为:nncb ,默认密码为:nncb 3、注意:网站安装完成请将Admins文件夹里的Install文件夹及里面的文件删除,否则将会影响网站的安全。 超博CMS主要功能模块介绍: 1、功能自由组合安装,有基本信息、文章管理、文件下载、会员管理、产品管理、订购管理、招聘应聘、广告管理、权限分配、参数设置等。 2、网站管理系统管理用户区和系统设置区,用户区供管理网站内容之用,系统设置区供系统初始化和网站参数设置、权限分配之用。 3、管理用户区: (1)基本信息修改 (2)文章分类、文章信息添加、删除和修改。 (3)文件分类、文件信息添加、删除和修改。 (4)会员审核和删除。 (5)产品品牌、产品分类、产品信息添加、删除和修改。 (6)订购管理查看、处理和删除。 (7)招聘信息添加、删除和修改;应聘信息查看和删除。 (8)广告替换。 4、系统设置区: (1)管理员账号密码修改 (2)网站管理员权限分配 (3)网站参数设置:包括上传文件格式,留言过滤关键词,网站名称,网站LOGO,网站标题title,description,keyword关键词SEO优化设置,版权栏设置,系统自动复邮设置,ICP备案设置和安装、公司的联系交通地图绑定、在线支付方式和即时沟通交流工具的设置、统计分析等数十项设置。 (4)登陆日志 (5)模板管理 主要功能模块介绍 1. 基本信息:发布介绍企业的各类信息,如企业简介、组织机构、营销网络、企业荣誉、联系方式,并可随意增加新的栏目等。 2. 文章管理:发布企业新闻和业内资讯,从后台到前台真正实现无限级分类显示,并随意控制显示级数,大大增加信息发布的灵活 性。 3. 产品展示:发布企业产品,增加了产品权限,并可多选产品直接下订单询盘,无限级分类,大大增加信息发布的灵活性。 4. 下载 资源:发布供网站浏览者和客户下载的资料等,如使用手册、销售合同、软件等,无限级分类。 5. 其他信息:相当于无限扩展栏,并可进行无限分类,可以用于发布网站主栏目未归类的信息,如解决方案、成功案例、购买流程 等。 6. 会员中心:会员可任意设置级别 7. 留言反馈:以留言板的模式让有意见和建议的浏览者反馈回来。 8. 站内检索:可检索站内全部栏目内容。 9. 友情链接:可设文字和图片链接方 10. 网站导航:可随意开通、屏蔽网站模块,并可设置站外链接,让网站可大可小。 11. 系统管理管理密码修改、网站信息设置、 12.管理权限:可根据需要增设多个管理员帐户,并任意分配不同管理权限。
QueryWrapper是MyBatis-Plus框架中的一个查询条件封装类,用于构建复杂的查询条件。它可以方便地通过链式调用的方式添加多个条件。根据给出的引用内容,QueryWrapper可以通过in、le、orderByDesc、orderByAsc等方法来实现多条件查询。 比如,可以使用queryWrapper.in("id", 1, 2, 3)方法来查询id为1、2、3的记录;使用queryWrapper.le("id", 3)方法来查询id小于等于3的记录。 此外,QueryWrapper还可以实现多条件的排序。比如,可以使用queryWrapper.orderByDesc("age").orderByAsc("id")方法来按照年龄降序排序,如果年龄相同则按照id升序排序。 综上所述,QueryWrapper可以通过多个方法的组合来实现多条件查询,包括in、le、orderByDesc、orderByAsc等方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [尚融04-mybatis-plus插件和条件构造器](https://blog.csdn.net/m0_62946761/article/details/129614633)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Mybatis-plus条件构造器各种用法(三)](https://blog.csdn.net/slxysyka/article/details/122569373)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zoeil

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值