From cf1b83d3f1f1dfc40991d1108e7c27c9ec466886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=A0=E9=BE=99?= Date: Sat, 23 Apr 2022 19:23:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9B=86=E6=88=90=E5=A4=9A=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AppIcons/index.js | 5 + src/layout/components/tags/ContextMenu.vue | 129 +++++++++++++++++++++ src/layout/components/tags/index.vue | 59 +++++++--- src/store/modules/tags/index.js | 42 ++++++- 4 files changed, 212 insertions(+), 23 deletions(-) create mode 100644 src/layout/components/tags/ContextMenu.vue diff --git a/src/components/AppIcons/index.js b/src/components/AppIcons/index.js index ea46f76..51a2608 100644 --- a/src/components/AppIcons/index.js +++ b/src/components/AppIcons/index.js @@ -8,5 +8,10 @@ export { default as IconLink } from '~icons/mdi/link-variant' export { default as IconAlert } from '~icons/mdi/alert-circle-outline' export { default as IconCircle } from '~icons/mdi/circle-outline' export { default as IconMenu } from '~icons/mdi/menu' +export { default as IconRefresh } from '~icons/mdi/refresh' +export { default as IconClose } from '~icons/mdi/close' +export { default as IconExpand } from '~icons/mdi/arrow-expand-horizontal' +export { default as IconExpandLeft } from '~icons/mdi/arrow-expand-left' +export { default as IconExpandRight } from '~icons/mdi/arrow-expand-right' export { default as IconLogo } from './IconLogo.vue' diff --git a/src/layout/components/tags/ContextMenu.vue b/src/layout/components/tags/ContextMenu.vue new file mode 100644 index 0000000..97a9e9f --- /dev/null +++ b/src/layout/components/tags/ContextMenu.vue @@ -0,0 +1,129 @@ + + + + diff --git a/src/layout/components/tags/index.vue b/src/layout/components/tags/index.vue index df13f1b..f115886 100644 --- a/src/layout/components/tags/index.vue +++ b/src/layout/components/tags/index.vue @@ -2,56 +2,77 @@
{{ tag.title }}
+ diff --git a/src/store/modules/tags/index.js b/src/store/modules/tags/index.js index 715a2f4..16be158 100644 --- a/src/store/modules/tags/index.js +++ b/src/store/modules/tags/index.js @@ -1,5 +1,6 @@ import { defineStore } from 'pinia' import { tagsSS, activeTag, tags, WITHOUT_TAG_PATHS } from './helpers' +import { router } from '@/router' export const useTagsStore = defineStore('tag', { state() { @@ -13,14 +14,47 @@ export const useTagsStore = defineStore('tag', { this.activeTag = path tagsSS.set('activeTag', path) }, + setTags(tags) { + this.tags = tags + tagsSS.set('tags', tags) + }, addTag(tag = {}) { + this.setActiveTag(tag.path) if (WITHOUT_TAG_PATHS.includes(tag.path) || this.tags.some((item) => item.path === tag.path)) return - this.tags.push(tag) - tagsSS.set('tags', this.tags) + this.setTags([...this.tags, tag]) }, removeTag(path) { - this.tags = this.tags.filter((tag) => tag.path !== path) - tagsSS.set('tags', this.tags) + if (path === this.activeTag) { + const activeIndex = this.tags.findIndex((item) => item.path === path) + if (activeIndex > 0) { + router.push(this.tags[activeIndex - 1].path) + } else { + router.push(this.tags[activeIndex + 1].path) + } + } + this.setTags(this.tags.filter((tag) => tag.path !== path)) + }, + removeOther(curPath = this.activeTag) { + this.setTags(this.tags.filter((tag) => tag.path === curPath)) + if (curPath !== this.activeTag) { + router.push(this.tags[this.tags.length - 1].path) + } + }, + removeLeft(curPath) { + const curIndex = this.tags.findIndex((item) => item.path === curPath) + const filterTags = this.tags.filter((item, index) => index >= curIndex) + this.setTags(filterTags) + if (!filterTags.find((item) => item.path === this.activeTag)) { + router.push(filterTags[filterTags.length - 1].path) + } + }, + removeRight(curPath) { + const curIndex = this.tags.findIndex((item) => item.path === curPath) + const filterTags = this.tags.filter((item, index) => index <= curIndex) + this.setTags(filterTags) + if (!filterTags.find((item) => item.path === this.activeTag)) { + router.push(filterTags[filterTags.length - 1].path) + } }, }, })