当前位置:   article > 正文

若依 vue前端 动态设置路由path不同参数 在页面容器里打开新页面(新路由),面包屑和标签页标题根据参数动态改变,面包屑多级标题,侧边栏对应菜单亮起_若依路由参数怎么使用

若依路由参数怎么使用

前言

因为是在vue源码的基础上进行修改,所以,就没有复制代码在文章上,采取的是截图对比源码和我修改的代码片段。要麻烦你们自己手敲了。

先来看看效果:

场景:在费用配置列表中,点击每一项的配置,都会在页面容器内部打开一个新页面,所以新页面的路径一样,根据传的参数不同,面包屑和标签页标题动态改变

二级路由效果(这是用菜单管理新建一条隐藏的路由做法,不推荐)

  1. http://localhost/feeManage/feeConfigDetail?id=4&metaTitle=3253的费用配置
  2. http://localhost/feeManage/feeConfigDetail?id=1&metaTitle=eww的费用配置

三级路由效果(推荐)

路由跳转方法:

  1. // 方法1
  2. this.$router.push({
  3. path: '/feeManage/feeConfig/feeConfigDetail',
  4. query: {
  5. id: row.id,},
  6. })
  7. // 方法2
  8. <router-link :to="'/system/dict-data/index/' + scope.row.dictId" class="link-type">
  9. <span>点击跳转</span>
  10. </router-link>

若依路由简单介绍:

若依vue前端能跳转到新页面路由的方法,我暂且知道这三种形式:

1 在若依的菜单项添加(不推荐)

缺点:因为路由暴露在外面,会发生被误删或者修改错误的情况,造成严重缺陷。

优点:不用写路由配置的代码,可以直接进行路由跳转了。

同时还要注意,这是详细页面,不应该在左侧菜单栏出现,所以要隐藏

2 在router的constantRoutes里添加路由(推荐)

 3 在router的dynamicRoutes里添加路由(推荐)

若依字典管理的动态路由配置(如果是想实现像若依字典这样的路由跳转效果,就可以直接参考若依的源码去做: 

 

如果需要权限,需要自己写权限标识(很麻烦,,对接很累)

先是后端写上。。。

 然后前端。。。

代码实现

路由配置

实现三级标题的路由怎么写?

  1. {
  2. path: '/feeManage',
  3. component: Layout, // 一级这个component: Layout必填,除非是不需要在页面容器里打开的页面
  4. hidden: true, // false:显示在侧边栏菜单
  5. redirect: 'noRedirect', // noRedirect:面包屑不可点击,不写这个,父级标题样式就和首页一样,黑字可点击跳转
  6. meta: { title: '费用管理'}, // 一级标题,写了才能显示在面包屑上
  7. children: [
  8. {
  9. path: '',
  10. component:{ render: (e) => e("router-view") }, // 如果你的'feeConfig'路径已经在系统菜单中设置过了,这里的path和component就写得和我一样就行,直接跳转三级路由
  11. hidden: true, // false:显示在侧边栏菜单
  12. redirect: 'noRedirect', // noRedirect:面包屑不可点击,不写这个,父级标题样式就和首页一样,黑字可点击跳转
  13. meta: { title: '费用配置'}, // 二级标题,写了才能显示在面包屑上
  14. // 如果你不需要二级的父级标题,那你就直接把第二个children的内容写在第一个children就行
  15. children: [
  16. {
  17. path: 'feeConfig/feeConfigDetail',
  18. component: () => import('@/views/feeManage/feeConfigDetail/index'),
  19. name: 'feeConfigDetail',
  20. meta: { title: '费用配置', activeMenu: '/feeManage/feeConfig' } // meta.title:三级标题,meta.activeMenu:侧边栏父级菜单高亮
  21. }
  22. ]
  23. }
  24. ]
  25. }

也可以这样写(这样写是建立在之前写的跳转路径不规范,如果不想改代码那么多,只能自己在路由这里改,就不用动业务代码里的跳转路径,当然我强迫症,我最后都改了)

  1. {
  2. path: '',
  3. component: Layout,
  4. hidden: true,
  5. redirect: 'noRedirect',
  6. meta: { title: '运营中心' },
  7. children: [
  8. {
  9. path: '/overseas-collocation',
  10. component:{ render: (e) => e("router-view") }, // 如果你的'merchant'路径已经在系统菜单中设置过了,这里的path和component就写得和我一样就行,直接跳转三级路由
  11. hidden: true, // false:显示在侧边栏菜单
  12. redirect: 'noRedirect', // noRedirect:面包屑不可点击,不写这个,父级标题样式就和首页一样,黑字可点击跳转
  13. meta: { title: '海外拼柜'}, // 二级标题,写了才能显示在面包屑上
  14. // 如果你不需要二级的父级标题,那你就直接把第二个children的内容写在第一个children就行
  15. children: [
  16. {
  17. path: 'detail/:id(\\d+)',
  18. component: () => import('@/views/operation-center/overseas-collocation/collocation-detail'),
  19. name: 'overseasCollocationDetail',
  20. meta: { title: '拼柜详情', activeMenu: '/operation-center/overseas-collocation/overseas-collocation' }
  21. }
  22. ]
  23. }
  24. ]
  25. }
  1. <router-link :to="'/overseas-collocation/detail/' + scope.row.id">
  2. <el-button type="text">查看</el-button>
  3. </router-link>

改后

面包屑和标签页动态标题配置

配置完路由后,就要讲,如何动态设置路由path不同参数 在页面容器里打开新页面,面包屑和标签页标题根据参数动态改变

 使用1方法创建好路由后,然后用$router.push设置传的参数,我们使用metaTitle来当页面标题

  1. this.$router.push({
  2. path: '/feeManage/feeConfigDetail',
  3. query: {
  4. id: row.id,
  5. metaTitle: row.chargeName + '的费用配置'
  6. },
  7. })

如果你只做到了这里,你就会发现,它确实跳转页面了,但是它是同一个页面进行了不同参数的刷新,然后页面的标题也没有动态改变,而是你之前菜单配置时写的标题,如图:

                  

 下面就需要改改若依的源码了:

1、先改面包屑

 2、在页面容器中,打开新的标签页,改标签页标题(把要修改文件和修改内容框出来,有个明显的对比,知道改哪里)

 

 最后在新页面取出参数

最后效果

有bug

也是写完上面的内容以后,才发现有bug,路径一样,参数不一样的标签,去单击的时候,没有刷新内容,而是保留第一次点击的标签的页面。。。如图

bug解决

原因:若依vue前端源码中用的<router-link>标签进行页面跳转,因为路径一样,参数不一样的页面本质上都是同一个vue,而这个vue已经加载出来就不会进行销毁重新加载了,所以我们要做的就是监听参数然后重新渲染,达到刷新页面的效果

在自己的跳转页面vue中监听路由参数:

二级路由效果

三级路由效果

ps: 找到更好的写法就又补充了一下,所以截图上有些不统一,记得看字看描述哈! 

修改过的若依代码

ruoyi 3.8.3

src\components\Breadcrumb\index.vue

  1. <template>
  2. <el-breadcrumb class="app-breadcrumb" separator="/">
  3. <transition-group name="breadcrumb">
  4. <el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path">
  5. <span v-if="item.redirect === 'noRedirect' || index == levelList.length - 1" class="no-redirect">
  6. <!-- {{ item.meta.title }} -->
  7. {{item.metaTitle ? item.metaTitle : item.meta.title }}
  8. </span>
  9. <a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
  10. </el-breadcrumb-item>
  11. </transition-group>
  12. </el-breadcrumb>
  13. </template>
  14. <script>
  15. export default {
  16. data() {
  17. return {
  18. levelList: null
  19. }
  20. },
  21. watch: {
  22. $route(route) {
  23. // if you go to the redirect page, do not update the breadcrumbs
  24. if (route.path.startsWith('/redirect/')) {
  25. return
  26. }
  27. this.getBreadcrumb()
  28. }
  29. },
  30. created() {
  31. this.getBreadcrumb()
  32. },
  33. methods: {
  34. getBreadcrumb() {
  35. // only show routes with meta.title
  36. let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
  37. matched.forEach(element => {
  38. if(element.path == this.$route.path ) {
  39. if(this.$route.query.metaTitle) {
  40. element.metaTitle = this.$route.query.metaTitle
  41. }
  42. }
  43. });
  44. const first = matched[0]
  45. if (!this.isDashboard(first)) {
  46. matched = [{ path: '/index', meta: { title: '首页' }}].concat(matched)
  47. }
  48. this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
  49. },
  50. isDashboard(route) {
  51. const name = route && route.name
  52. if (!name) {
  53. return false
  54. }
  55. return name.trim() === 'Index'
  56. },
  57. handleLink(item) {
  58. const { redirect, path } = item
  59. if (redirect) {
  60. this.$router.push(redirect)
  61. return
  62. }
  63. this.$router.push(path)
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .app-breadcrumb.el-breadcrumb {
  70. display: inline-block;
  71. font-size: 14px;
  72. line-height: 50px;
  73. margin-left: 8px;
  74. .no-redirect {
  75. color: #97a8be;
  76. cursor: text;
  77. }
  78. }
  79. </style>

src\layout\components\TagsView\index.vue

 

  1. <template>
  2. <div id="tags-view-container" class="tags-view-container">
  3. <scroll-pane ref="scrollPane" class="tags-view-wrapper" @scroll="handleScroll">
  4. <router-link
  5. v-for="tag in visitedViews"
  6. ref="tag"
  7. :key="tag.fullPath"
  8. :class="isActive(tag)?'active':''"
  9. :to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
  10. tag="span"
  11. class="tags-view-item"
  12. :style="activeStyle(tag)"
  13. @click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''"
  14. @contextmenu.prevent.native="openMenu(tag,$event)"
  15. >
  16. {{ tag.title }}
  17. <span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
  18. </router-link>
  19. </scroll-pane>
  20. <ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu">
  21. <li @click="refreshSelectedTag(selectedTag)"><i class="el-icon-refresh-right"></i> 刷新页面</li>
  22. <li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)"><i class="el-icon-close"></i> 关闭当前</li>
  23. <li @click="closeOthersTags"><i class="el-icon-circle-close"></i> 关闭其他</li>
  24. <li v-if="!isFirstView()" @click="closeLeftTags"><i class="el-icon-back"></i> 关闭左侧</li>
  25. <li v-if="!isLastView()" @click="closeRightTags"><i class="el-icon-right"></i> 关闭右侧</li>
  26. <li @click="closeAllTags(selectedTag)"><i class="el-icon-circle-close"></i> 全部关闭</li>
  27. </ul>
  28. </div>
  29. </template>
  30. <script>
  31. import ScrollPane from './ScrollPane'
  32. import path from 'path'
  33. export default {
  34. components: { ScrollPane },
  35. data() {
  36. return {
  37. visible: false,
  38. top: 0,
  39. left: 0,
  40. selectedTag: {},
  41. affixTags: []
  42. }
  43. },
  44. computed: {
  45. visitedViews() {
  46. return this.$store.state.tagsView.visitedViews
  47. },
  48. routes() {
  49. return this.$store.state.permission.routes
  50. },
  51. theme() {
  52. return this.$store.state.settings.theme;
  53. }
  54. },
  55. watch: {
  56. $route() {
  57. this.addTags()
  58. this.moveToCurrentTag()
  59. },
  60. visible(value) {
  61. if (value) {
  62. document.body.addEventListener('click', this.closeMenu)
  63. } else {
  64. document.body.removeEventListener('click', this.closeMenu)
  65. }
  66. }
  67. },
  68. mounted() {
  69. this.initTags()
  70. this.addTags()
  71. },
  72. methods: {
  73. isActive(route) {
  74. // return route.path === this.$route.path
  75. return route.fullPath === this.$route.fullPath
  76. },
  77. activeStyle(tag) {
  78. if (!this.isActive(tag)) return {};
  79. return {
  80. "background-color": this.theme,
  81. "border-color": this.theme
  82. };
  83. },
  84. isAffix(tag) {
  85. return tag.meta && tag.meta.affix
  86. },
  87. isFirstView() {
  88. try {
  89. return this.selectedTag.fullPath === this.visitedViews[1].fullPath || this.selectedTag.fullPath === '/index'
  90. } catch (err) {
  91. return false
  92. }
  93. },
  94. isLastView() {
  95. try {
  96. return this.selectedTag.fullPath === this.visitedViews[this.visitedViews.length - 1].fullPath
  97. } catch (err) {
  98. return false
  99. }
  100. },
  101. filterAffixTags(routes, basePath = '/') {
  102. let tags = []
  103. routes.forEach(route => {
  104. if (route.meta && route.meta.affix) {
  105. const tagPath = path.resolve(basePath, route.path)
  106. tags.push({
  107. fullPath: tagPath,
  108. path: tagPath,
  109. name: route.name,
  110. meta: { ...route.meta }
  111. })
  112. }
  113. if (route.children) {
  114. const tempTags = this.filterAffixTags(route.children, route.path)
  115. if (tempTags.length >= 1) {
  116. tags = [...tags, ...tempTags]
  117. }
  118. }
  119. })
  120. return tags
  121. },
  122. initTags() {
  123. const affixTags = this.affixTags = this.filterAffixTags(this.routes)
  124. for (const tag of affixTags) {
  125. // Must have tag name
  126. if (tag.name) {
  127. // this.$store.dispatch('tagsView/addVisitedView', tag)
  128. }
  129. }
  130. },
  131. addTags() {
  132. const { name } = this.$route
  133. if (name) {
  134. this.$store.dispatch('tagsView/addView', this.$route)
  135. }
  136. return false
  137. },
  138. moveToCurrentTag() {
  139. const tags = this.$refs.tag
  140. this.$nextTick(() => {
  141. for (const tag of tags) {
  142. if (tag.to.path === this.$route.path) {
  143. if(tag.to.query.metaTitle) {
  144. if(tag.to.query.metaTitle === this.$route.query.metaTitle) {
  145. this.$refs.scrollPane.moveToTarget(tag)
  146. // when query is different then update
  147. if (tag.to.fullPath !== this.$route.fullPath) {
  148. this.$store.dispatch('tagsView/updateVisitedView', this.$route)
  149. }
  150. }
  151. } else {
  152. this.$refs.scrollPane.moveToTarget(tag)
  153. // when query is different then update
  154. if (tag.to.fullPath !== this.$route.fullPath) {
  155. this.$store.dispatch('tagsView/updateVisitedView', this.$route)
  156. }
  157. }
  158. break
  159. }
  160. }
  161. })
  162. },
  163. refreshSelectedTag(view) {
  164. this.$tab.refreshPage(view);
  165. },
  166. closeSelectedTag(view) {
  167. this.$tab.closePage(view).then(({ visitedViews }) => {
  168. if (this.isActive(view)) {
  169. this.toLastView(visitedViews, view)
  170. }
  171. })
  172. },
  173. closeRightTags() {
  174. this.$tab.closeRightPage(this.selectedTag).then(visitedViews => {
  175. if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) {
  176. this.toLastView(visitedViews)
  177. }
  178. })
  179. },
  180. closeLeftTags() {
  181. this.$tab.closeLeftPage(this.selectedTag).then(visitedViews => {
  182. if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) {
  183. this.toLastView(visitedViews)
  184. }
  185. })
  186. },
  187. closeOthersTags() {
  188. this.$router.push(this.selectedTag).catch(()=>{});
  189. this.$tab.closeOtherPage(this.selectedTag).then(() => {
  190. this.moveToCurrentTag()
  191. })
  192. },
  193. closeAllTags(view) {
  194. this.$tab.closeAllPage().then(({ visitedViews }) => {
  195. if (this.affixTags.some(tag => tag.path === this.$route.path)) {
  196. return
  197. }
  198. this.toLastView(visitedViews, view)
  199. })
  200. },
  201. toLastView(visitedViews, view) {
  202. const latestView = visitedViews.slice(-1)[0]
  203. if (latestView) {
  204. this.$router.push(latestView.fullPath)
  205. } else {
  206. // now the default is to redirect to the home page if there is no tags-view,
  207. // you can adjust it according to your needs.
  208. if (view.name === 'Dashboard') {
  209. // to reload home page
  210. this.$router.replace({ path: '/redirect' + view.fullPath })
  211. } else {
  212. this.$router.push('/')
  213. }
  214. }
  215. },
  216. openMenu(tag, e) {
  217. const menuMinWidth = 105
  218. const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
  219. const offsetWidth = this.$el.offsetWidth // container width
  220. const maxLeft = offsetWidth - menuMinWidth // left boundary
  221. const left = e.clientX - offsetLeft + 15 // 15: margin right
  222. if (left > maxLeft) {
  223. this.left = maxLeft
  224. } else {
  225. this.left = left
  226. }
  227. this.top = e.clientY
  228. this.visible = true
  229. this.selectedTag = tag
  230. },
  231. closeMenu() {
  232. this.visible = false
  233. },
  234. handleScroll() {
  235. this.closeMenu()
  236. }
  237. }
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. .tags-view-container {
  242. height: 34px;
  243. width: 100%;
  244. background: #fff;
  245. border-bottom: 1px solid #d8dce5;
  246. box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 0 3px 0 rgba(0, 0, 0, .04);
  247. .tags-view-wrapper {
  248. .tags-view-item {
  249. display: inline-block;
  250. position: relative;
  251. cursor: pointer;
  252. height: 26px;
  253. line-height: 26px;
  254. border: 1px solid #d8dce5;
  255. color: #495060;
  256. background: #fff;
  257. padding: 0 8px;
  258. font-size: 12px;
  259. margin-left: 5px;
  260. margin-top: 4px;
  261. &:first-of-type {
  262. margin-left: 15px;
  263. }
  264. &:last-of-type {
  265. margin-right: 15px;
  266. }
  267. &.active {
  268. background-color: #42b983;
  269. color: #fff;
  270. border-color: #42b983;
  271. &::before {
  272. content: '';
  273. background: #fff;
  274. display: inline-block;
  275. width: 8px;
  276. height: 8px;
  277. border-radius: 50%;
  278. position: relative;
  279. margin-right: 2px;
  280. }
  281. }
  282. }
  283. }
  284. .contextmenu {
  285. margin: 0;
  286. background: #fff;
  287. z-index: 3000;
  288. position: absolute;
  289. list-style-type: none;
  290. padding: 5px 0;
  291. border-radius: 4px;
  292. font-size: 12px;
  293. font-weight: 400;
  294. color: #333;
  295. box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, .3);
  296. li {
  297. margin: 0;
  298. padding: 7px 16px;
  299. cursor: pointer;
  300. &:hover {
  301. background: #eee;
  302. }
  303. }
  304. }
  305. }
  306. </style>
  307. <style lang="scss">
  308. //reset element css of el-icon-close
  309. .tags-view-wrapper {
  310. .tags-view-item {
  311. .el-icon-close {
  312. width: 16px;
  313. height: 16px;
  314. vertical-align: 2px;
  315. border-radius: 50%;
  316. text-align: center;
  317. transition: all .3s cubic-bezier(.645, .045, .355, 1);
  318. transform-origin: 100% 50%;
  319. &:before {
  320. transform: scale(.6);
  321. display: inline-block;
  322. vertical-align: -3px;
  323. }
  324. &:hover {
  325. background-color: #b4bccc;
  326. color: #fff;
  327. }
  328. }
  329. }
  330. }
  331. </style>

src\store\modules\tagsView.js

  1. const state = {
  2. visitedViews: [],
  3. cachedViews: []
  4. }
  5. const mutations = {
  6. // ADD_VISITED_VIEW: (state, view) => {
  7. // if (state.visitedViews.some(v => v.path === view.path)) return
  8. // state.visitedViews.push(
  9. // Object.assign({}, view, {
  10. // title: view.meta.title || 'no-name'
  11. // })
  12. // )
  13. // },
  14. ADD_VISITED_VIEW: (state, view) => {
  15. if (state.visitedViews.some(v => v.path === view.path)) {
  16. // 路径一样,因为参数不同,打开新的页面
  17. if(view.query && view.query.metaTitle) {
  18. let list = state.visitedViews.filter(v => v.query && v.query.metaTitle && v.query.metaTitle == view.query.metaTitle)
  19. if(list.length > 0) {
  20. return
  21. }
  22. } else {
  23. return
  24. }
  25. }
  26. state.visitedViews.push(
  27. Object.assign({}, view, {
  28. title: view.query && view.query.metaTitle ? view.query.metaTitle:(view.meta.title || 'no-name')
  29. })
  30. )
  31. },
  32. ADD_CACHED_VIEW: (state, view) => {
  33. if (state.cachedViews.includes(view.name)) return
  34. if (view.meta && !view.meta.noCache) {
  35. state.cachedViews.push(view.name)
  36. }
  37. },
  38. DEL_VISITED_VIEW: (state, view) => {
  39. for (const [i, v] of state.visitedViews.entries()) {
  40. if (v.path === view.path) {
  41. state.visitedViews.splice(i, 1)
  42. break
  43. }
  44. }
  45. },
  46. DEL_CACHED_VIEW: (state, view) => {
  47. const index = state.cachedViews.indexOf(view.name)
  48. index > -1 && state.cachedViews.splice(index, 1)
  49. },
  50. DEL_OTHERS_VISITED_VIEWS: (state, view) => {
  51. state.visitedViews = state.visitedViews.filter(v => {
  52. return v.meta.affix || v.path === view.path
  53. })
  54. },
  55. DEL_OTHERS_CACHED_VIEWS: (state, view) => {
  56. const index = state.cachedViews.indexOf(view.name)
  57. if (index > -1) {
  58. state.cachedViews = state.cachedViews.slice(index, index + 1)
  59. } else {
  60. state.cachedViews = []
  61. }
  62. },
  63. DEL_ALL_VISITED_VIEWS: state => {
  64. // keep affix tags
  65. const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
  66. state.visitedViews = affixTags
  67. },
  68. DEL_ALL_CACHED_VIEWS: state => {
  69. state.cachedViews = []
  70. },
  71. UPDATE_VISITED_VIEW: (state, view) => {
  72. for (let v of state.visitedViews) {
  73. if (v.path === view.path) {
  74. v = Object.assign(v, view)
  75. break
  76. }
  77. }
  78. },
  79. DEL_RIGHT_VIEWS: (state, view) => {
  80. const index = state.visitedViews.findIndex(v => v.path === view.path)
  81. if (index === -1) {
  82. return
  83. }
  84. state.visitedViews = state.visitedViews.filter((item, idx) => {
  85. if (idx <= index || (item.meta && item.meta.affix)) {
  86. return true
  87. }
  88. const i = state.cachedViews.indexOf(item.name)
  89. if (i > -1) {
  90. state.cachedViews.splice(i, 1)
  91. }
  92. return false
  93. })
  94. },
  95. DEL_LEFT_VIEWS: (state, view) => {
  96. const index = state.visitedViews.findIndex(v => v.path === view.path)
  97. if (index === -1) {
  98. return
  99. }
  100. state.visitedViews = state.visitedViews.filter((item, idx) => {
  101. if (idx >= index || (item.meta && item.meta.affix)) {
  102. return true
  103. }
  104. const i = state.cachedViews.indexOf(item.name)
  105. if (i > -1) {
  106. state.cachedViews.splice(i, 1)
  107. }
  108. return false
  109. })
  110. }
  111. }
  112. const actions = {
  113. addView({ dispatch }, view) {
  114. dispatch('addVisitedView', view)
  115. dispatch('addCachedView', view)
  116. },
  117. addVisitedView({ commit }, view) {
  118. commit('ADD_VISITED_VIEW', view)
  119. },
  120. addCachedView({ commit }, view) {
  121. commit('ADD_CACHED_VIEW', view)
  122. },
  123. delView({ dispatch, state }, view) {
  124. return new Promise(resolve => {
  125. dispatch('delVisitedView', view)
  126. dispatch('delCachedView', view)
  127. resolve({
  128. visitedViews: [...state.visitedViews],
  129. cachedViews: [...state.cachedViews]
  130. })
  131. })
  132. },
  133. delVisitedView({ commit, state }, view) {
  134. return new Promise(resolve => {
  135. commit('DEL_VISITED_VIEW', view)
  136. resolve([...state.visitedViews])
  137. })
  138. },
  139. delCachedView({ commit, state }, view) {
  140. return new Promise(resolve => {
  141. commit('DEL_CACHED_VIEW', view)
  142. resolve([...state.cachedViews])
  143. })
  144. },
  145. delOthersViews({ dispatch, state }, view) {
  146. return new Promise(resolve => {
  147. dispatch('delOthersVisitedViews', view)
  148. dispatch('delOthersCachedViews', view)
  149. resolve({
  150. visitedViews: [...state.visitedViews],
  151. cachedViews: [...state.cachedViews]
  152. })
  153. })
  154. },
  155. delOthersVisitedViews({ commit, state }, view) {
  156. return new Promise(resolve => {
  157. commit('DEL_OTHERS_VISITED_VIEWS', view)
  158. resolve([...state.visitedViews])
  159. })
  160. },
  161. delOthersCachedViews({ commit, state }, view) {
  162. return new Promise(resolve => {
  163. commit('DEL_OTHERS_CACHED_VIEWS', view)
  164. resolve([...state.cachedViews])
  165. })
  166. },
  167. delAllViews({ dispatch, state }, view) {
  168. return new Promise(resolve => {
  169. dispatch('delAllVisitedViews', view)
  170. dispatch('delAllCachedViews', view)
  171. resolve({
  172. visitedViews: [...state.visitedViews],
  173. cachedViews: [...state.cachedViews]
  174. })
  175. })
  176. },
  177. delAllVisitedViews({ commit, state }) {
  178. return new Promise(resolve => {
  179. commit('DEL_ALL_VISITED_VIEWS')
  180. resolve([...state.visitedViews])
  181. })
  182. },
  183. delAllCachedViews({ commit, state }) {
  184. return new Promise(resolve => {
  185. commit('DEL_ALL_CACHED_VIEWS')
  186. resolve([...state.cachedViews])
  187. })
  188. },
  189. updateVisitedView({ commit }, view) {
  190. commit('UPDATE_VISITED_VIEW', view)
  191. },
  192. delRightTags({ commit }, view) {
  193. return new Promise(resolve => {
  194. commit('DEL_RIGHT_VIEWS', view)
  195. resolve([...state.visitedViews])
  196. })
  197. },
  198. delLeftTags({ commit }, view) {
  199. return new Promise(resolve => {
  200. commit('DEL_LEFT_VIEWS', view)
  201. resolve([...state.visitedViews])
  202. })
  203. },
  204. }
  205. export default {
  206. namespaced: true,
  207. state,
  208. mutations,
  209. actions
  210. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/401889
推荐阅读
相关标签
  

闽ICP备14008679号