4141 <q-card-section >
4242 <div class =" flex flex-row" >
4343 <q-chip
44- v-for =" (tag, index) in routeTags "
44+ v-for =" (tag, index) in articleRouteTags "
4545 :key =" index"
4646 icon =" las la-location-arrow"
47- color =" teal-10 "
48- text-color =" white"
47+ color =" green-4 "
48+ : text-color =" tag.removable ? 'red' : ' white' "
4949 clickable
50- @click.stop =" $router.push(tag.route)"
50+ :removable =" tag.removable"
51+ @click.stop ="
52+ $router.push({
53+ path: tag.route,
54+ query: {
55+ ...route.query,
56+ },
57+ })
58+ "
59+ @remove ="
60+ $router.push({
61+ path: tag.removedRoute,
62+ query: {
63+ ...route.query,
64+ },
65+ })
66+ "
5167 >
5268 {{ tag.tag }}
5369 </q-chip >
5470 <q-chip
5571 v-for =" (tag, index) in article?.tags"
5672 :key =" index"
5773 icon =" las la-tag"
58- color =" lime-10 "
59- text-color =" white"
74+ color =" blue-4 "
75+ : text-color =" queryTags.includes(tag) ? 'red' : ' white' "
6076 clickable
77+ :removable =" queryTags.includes(tag)"
6178 @click.stop ="
6279 $router.push({
6380 path: route.path,
6481 query: {
65- tags: tag,
82+ ...route.query,
83+ tags: queryTags.includes(tag)
84+ ? queryTags.filter((i) => i !== tag)
85+ : [tag, ...queryTags].join(),
86+ },
87+ })
88+ "
89+ @remove ="
90+ $router.push({
91+ path: route.path,
92+ query: {
93+ ...route.query,
94+ tags: queryTags.filter((i) => i !== tag),
6695 },
6796 })
6897 "
@@ -80,6 +109,7 @@ import MarkdownRender from "./MarkdownRender.vue";
80109const $fmt = useFormat ();
81110
82111const route = useRoute ();
112+ const { getPagePathArray } = useLocalePage ();
83113
84114const props = defineProps ({
85115 article: {
@@ -88,13 +118,27 @@ const props = defineProps({
88118 },
89119});
90120
121+ const queryTags = computed (() => {
122+ return (
123+ route .query .tags
124+ ?.toString ()
125+ ?.split ?.(" ," )
126+ ?.filter ?.((i : string ) => !! i ) || []
127+ );
128+ });
129+
91130const routeTags = computed (() => {
131+ const route = getPagePathArray (true );
132+ return route ?.filter ?.((i : string ) => !! i && ! i .endsWith (" .md" ));
133+ });
134+
135+ const articleRouteTags = computed (() => {
92136 const route = props .article ?.route || " " ;
93137 const items = route
94138 ?.split ?.(" /" )
95- ?.filter ?.((i : string ) => !! i && i . indexOf (" .md" ) < 0 );
139+ ?.filter ?.((i : string ) => !! i && ! i . endsWith (" .md" ));
96140 const prefix = items .slice (0 , 2 ) || [];
97- const tags = items .slice (2 ) || [];
141+ const tags = items .slice (prefix . length ) || [];
98142 return tags .map ((i : string ) => {
99143 const index = tags .indexOf (i );
100144 const routes = [];
@@ -103,6 +147,8 @@ const routeTags = computed(() => {
103147 return {
104148 tag: i ,
105149 route: " /" + routes .join (" /" ),
150+ removable: routeTags .value .includes (i ),
151+ removedRoute: " /" + routes .slice (0 , prefix .length + index ).join (" /" ),
106152 };
107153 });
108154});
0 commit comments