• TP6框架--CRMEB学习笔记:布置后台管理框架+配置路由


    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助

    最近在研究一个基于TP6的框架CRMEB,这里分享下我的开发心得

    首先在上篇文章中,我们安装了CRMEBphp接口项目,需要可以看这一篇

    TP6框架--CRMEB学习笔记:项目初始化+环境配置

    1.获取项目

    这里是git地址

    https://gitee.com/ZhongBangKeJi/CRMEB-Min.git
    

    下载后用WebStorm打开

     2.依赖安装+项目运行

    先打开终端,运行

    npm install
    

    全局安装依赖

    然后在代码上修改后台接口地址,改为上篇中安装好的后台接口地址

    然后根据运行文件

     运行以下代码运行项目

    npm run serve
    

     打开网站看效果

     登录成功后的效果

     3.创建路由

    现在,给大家说说创建新页面,新路由的过程,首先,打开设置,点击管理权限,打开权限规则,我们要先新建一个规则

     设置好参数

     打开代码,先创建好文件夹和文件

     再去router中创建test文件

     内容如下,可做参考:

    1. import BasicLayout from '@/components/main'
    2. const pre = 'test_'
    3. export default {
    4. path: '/admin/test',
    5. name: 'test',
    6. header: 'test',
    7. redirect: {
    8. name: `${pre}wechatMenus`
    9. },
    10. meta: {
    11. auth: ['admin-app']
    12. },
    13. component: BasicLayout,
    14. children: [
    15. {
    16. path: 'index',
    17. name: `${pre}Index`,
    18. meta: {
    19. auth: ['test-view'],
    20. title: '测试页面'
    21. },
    22. component: () => import('@/pages/test/index')
    23. }
    24. ]
    25. }

    再在router.js中导入test,代码如下:

    1. import index from './modules/index'
    2. import product from './modules/product'
    3. import order from './modules/order'
    4. import user from './modules/user'
    5. // import echarts from './modules/echarts'
    6. import setting from './modules/setting'
    7. import finance from './modules/finance'
    8. import cms from './modules/cms'
    9. import marketing from './modules/marketing'
    10. import app from './modules/app'
    11. import system from './modules/system'
    12. import BasicLayout from '@/components/main'
    13. import frameOut from './modules/frameOut'
    14. import test from './modules/test'
    15. /**
    16. * 在主框架内显示
    17. */
    18. const frameIn = [
    19. {
    20. path: '/admin/',
    21. meta: {
    22. title: 'CRMEB'
    23. },
    24. redirect: {
    25. name: 'home_index'
    26. },
    27. component: BasicLayout,
    28. children: [
    29. // {
    30. // path: '/admin/system/log',
    31. // name: 'log',
    32. // meta: {
    33. // title: '前端日志',
    34. // auth: true
    35. // },
    36. // component: () => import('@/pages/system/log')
    37. // },
    38. {
    39. path: '/admin/system/user',
    40. name: `systemUser`,
    41. meta: {
    42. auth: true,
    43. title: '个人中心'
    44. },
    45. component: () => import('@/pages/setting/user/index')
    46. },
    47. // 刷新页面 必须保留
    48. {
    49. path: 'refresh',
    50. name: 'refresh',
    51. hidden: true,
    52. component: {
    53. beforeRouteEnter (to, from, next) {
    54. next(instance => instance.$router.replace(from.fullPath))
    55. },
    56. render: h => h()
    57. }
    58. },
    59. // 页面重定向 必须保留
    60. {
    61. path: 'redirect/:route*',
    62. name: 'redirect',
    63. hidden: true,
    64. component: {
    65. beforeRouteEnter (to, from, next) {
    66. // console.log(rom.params.route)
    67. next(instance => instance.$router.replace(JSON.parse(from.params.route)))
    68. },
    69. render: h => h()
    70. }
    71. }
    72. ]
    73. },
    74. {
    75. path: '/admin/widget.images/index.html',
    76. name: `images`,
    77. meta: {
    78. auth: ['admin-user-user-index'],
    79. title: '上传图片'
    80. },
    81. component: () => import('@/components/uploadPictures/widgetImg')
    82. },
    83. {
    84. path: '/admin/widget.widgets/icon.html',
    85. name: `imagesIcon`,
    86. meta: {
    87. auth: ['admin-user-user-index'],
    88. title: '上传图标'
    89. },
    90. component: () => import('@/components/iconFrom/index')
    91. },
    92. {
    93. path: '/admin/store.StoreProduct/index.html',
    94. name: `storeProduct`,
    95. meta: {
    96. title: '选择商品'
    97. },
    98. component: () => import('@/components/goodsList/index')
    99. },
    100. {
    101. path: '/admin/system.User/list.html',
    102. name: `changeUser`,
    103. meta: {
    104. title: '选择用户'
    105. },
    106. component: () => import('@/components/customerInfo/index')
    107. },
    108. {
    109. path: '/admin/widget.video/index.html',
    110. name: `video`,
    111. meta: {
    112. title: '上传视频'
    113. },
    114. component: () => import('@/components/uploadVideo/index')
    115. },
    116. index,
    117. cms,
    118. product,
    119. marketing,
    120. order,
    121. user,
    122. finance,
    123. setting,
    124. system,
    125. app,
    126. test
    127. ]
    128. /**
    129. * 在主框架之外显示
    130. */
    131. const frameOuts = frameOut
    132. /**
    133. * 错误页面
    134. */
    135. const errorPage = [
    136. {
    137. path: '/admin/403',
    138. name: '403',
    139. meta: {
    140. title: '403'
    141. },
    142. component: () => import('@/pages/system/error/403')
    143. },
    144. {
    145. path: '/admin/500',
    146. name: '500',
    147. meta: {
    148. title: '500'
    149. },
    150. component: () => import('@/pages/system/error/500')
    151. },
    152. {
    153. path: '/admin/*',
    154. name: '404',
    155. meta: {
    156. title: '404'
    157. },
    158. component: () => import('@/pages/system/error/404')
    159. }
    160. ]
    161. // 导出需要显示菜单的
    162. export const frameInRoutes = frameIn
    163. // 重新组织后导出
    164. export default [
    165. ...frameIn,
    166. ...frameOuts,
    167. ...errorPage
    168. ]

    之后还需要一步,因为路由是缓存下来的,需要清除了环境才能查看

    如果对您有所帮助,欢迎您点个关注,我会定时更新技术文档,大家一起讨论学习,一起进路,下一篇写如何解决各个模块文件问题,和大家一起解析下各个模块。

     

  • 相关阅读:
    Redis查找并删除key
    二十五、Java 封装
    每日一练——快速合并2个有序数组
    cookie、localStorage 和sessionStorage
    Web 安全之时序攻击 Timing Attack 详解
    Rust学习日记(二)变量的使用--结合--温度换算/斐波那契数列--实例
    AE调试(非人脸场景)
    JMeter 如何实现 Elasticsearch 8.X 性能测试?
    PPT的使用技巧(一):对齐、文字填充、柱状图填充
    Wolfram语言之父:ChatGPT到底能做什么? | 阿Q送书第六期
  • 原文地址:https://blog.csdn.net/qq_40716795/article/details/126957892