Skip to content

Commit c4aeb1b

Browse files
author
robotism
committed
update
1 parent ee5d592 commit c4aeb1b

File tree

5 files changed

+72
-21
lines changed

5 files changed

+72
-21
lines changed

src/app.vue

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<template>
2-
<div class="min-h-screen min-w-screen">
3-
<NuxtRouteAnnouncer />
4-
<NuxtLoadingIndicator />
5-
<NuxtLayout name="home">
6-
<NuxtPage />
7-
</NuxtLayout>
8-
</div>
2+
<Suspense>
3+
<template #default>
4+
<div class="min-h-screen min-w-screen">
5+
<NuxtRouteAnnouncer />
6+
<NuxtLoadingIndicator />
7+
<NuxtLayout name="home">
8+
<NuxtPage />
9+
</NuxtLayout>
10+
</div>
11+
</template>
12+
<template #fallback> Loading... </template>
13+
</Suspense>
914
</template>
1015

1116
<script lang="ts" setup>

src/components/article/ArticleItem.vue

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,57 @@
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";
80109
const $fmt = useFormat();
81110
82111
const route = useRoute();
112+
const { getPagePathArray } = useLocalePage();
83113
84114
const 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+
91130
const 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
});

src/layouts/home.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
minHeight: `calc(100vh - ${$env.style.header.height} - ${$env.style.footer.height})`,
2222
}"
2323
>
24-
<BreadCrumbs />
2524
<AppMain />
2625
</q-page>
2726
</q-page-container>
@@ -41,6 +40,4 @@
4140
import AppHeader from "~/layouts/home/AppHeader.vue";
4241
import AppMain from "~/layouts/home/AppMain.vue";
4342
import AppFooter from "~/layouts/home/AppFooter.vue";
44-
45-
import BreadCrumbs from "~/components/tool/BreadCrumbs.vue";
4643
</script>

src/layouts/home/AppMain.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<template>
22
<div class="min-w-screen">
3+
<BreadCrumbs />
34
<NuxtPage />
45
</div>
56
</template>
67

7-
<script lang="ts" setup></script>
8+
<script lang="ts" setup>
9+
import BreadCrumbs from "~/components/tool/BreadCrumbs.vue";
10+
</script>

src/pages/articles/[...slug].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const { data: articles } = await useAsyncData(
3131
);
3232
3333
if (typeof route.query?.tags === "string") {
34-
const tags = (route.query.tags as string).split(",");
34+
const tags = (route.query.tags as string).split(",").filter((i) => !!i);
3535
for (const tag of tags) {
3636
query.where("tags", "LIKE", '%"' + tag + '"%');
3737
}

0 commit comments

Comments
 (0)