Skip to content

Commit 3b7ddb4

Browse files
committed
fix: optimize Home loading
Fix part of #330
1 parent d5f4dcb commit 3b7ddb4

3 files changed

Lines changed: 53 additions & 50 deletions

File tree

src/components/CollapsibleToolMenu.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ const themeVars = useThemeVars();
182182
:collapsed-icon-size="22"
183183
:options="tools"
184184
:indent="8"
185-
:default-expand-all="true"
186185
/>
187186
</div>
188187
</div>

src/pages/Home.custom.vue

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<script setup lang="ts">
2+
import VueMarkdown from 'vue-markdown-render';
3+
import { useTheme } from '../ui/c-link/c-link.theme';
4+
5+
const linkTheme = useTheme();
6+
7+
const homeCustomMarkdown = ref('');
8+
const base = import.meta.env.BASE_URL ?? '/';
9+
10+
const res = await fetch(`${base}home.custom.md`);
11+
if (res.ok) {
12+
homeCustomMarkdown.value = await res.text();
13+
}
14+
</script>
15+
16+
<template>
17+
<div v-if="homeCustomMarkdown" class="home-custom-md">
18+
<VueMarkdown :source="homeCustomMarkdown" />
19+
</div>
20+
</template>
21+
22+
<style scoped lang="less">
23+
::v-deep(.home-custom-md) a {
24+
line-height: inherit;
25+
font-family: inherit;
26+
font-size: inherit;
27+
border: none;
28+
cursor: pointer;
29+
text-decoration: none;
30+
font-weight: 400;
31+
color: v-bind('linkTheme.default.textColor');
32+
border-radius: 4px;
33+
transition: color cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
34+
35+
outline-offset: 1px;
36+
37+
&:hover {
38+
color: v-bind('linkTheme.default.hover.textColor');
39+
}
40+
41+
&:active {
42+
color: v-bind('linkTheme.default.textColor');
43+
}
44+
45+
&:focus {
46+
color: v-bind('linkTheme.default.outline.color');
47+
}
48+
}
49+
</style>

src/pages/Home.page.vue

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@ import { IconDragDrop, IconHeart } from '@tabler/icons-vue';
33
import { useHead } from '@vueuse/head';
44
import { computed, nextTick, onMounted, onUnmounted, ref } from 'vue';
55
import Draggable from 'vuedraggable';
6-
import VueMarkdown from 'vue-markdown-render';
76
import ColoredCard from '../components/ColoredCard.vue';
87
import ToolCard from '../components/ToolCard.vue';
8+
import HomeCustom from './Home.custom.vue';
99
import { useToolStore } from '@/tools/tools.store';
1010
import { config } from '@/config';
11-
import { useTheme } from '../ui/c-link/c-link.theme';
12-
13-
const base = import.meta.env.BASE_URL ?? '/';
14-
15-
const homeCustomMarkdown = ref('');
1611
1712
const { t } = useI18n();
1813
@@ -55,9 +50,6 @@ useHead({
5550
});
5651
5752
const favoriteTools = computed(() => toolStore.favoriteTools);
58-
59-
const linkTheme = useTheme();
60-
6153
const isOrderingFavorites = ref(false);
6254
6355
window.addEventListener('contextmenu', (e) => {
@@ -121,16 +113,6 @@ onMounted(() => {
121113
);
122114
loadingObserver.observe(loadingIndicator);
123115
}
124-
125-
fetch(`${base}home.custom.md`).then((r) => {
126-
if (r.ok) {
127-
r.text().then((t) => {
128-
if (t) {
129-
homeCustomMarkdown.value = t;
130-
}
131-
});
132-
}
133-
});
134116
});
135117
});
136118
@@ -193,9 +175,9 @@ onUnmounted(() => {
193175
</div>
194176
</div>
195177

196-
<div v-if="homeCustomMarkdown" class="home-custom-md">
197-
<VueMarkdown :source="homeCustomMarkdown" />
198-
</div>
178+
<Suspense>
179+
<HomeCustom />
180+
</Suspense>
199181

200182
<h3 class="mb-5px mt-25px font-500 text-neutral-400">
201183
{{ $t('home.categories.allTools') }}
@@ -249,31 +231,4 @@ onUnmounted(() => {
249231
transform: scale(1.0);
250232
}
251233
}
252-
253-
::v-deep(.home-custom-md) a {
254-
line-height: inherit;
255-
font-family: inherit;
256-
font-size: inherit;
257-
border: none;
258-
cursor: pointer;
259-
text-decoration: none;
260-
font-weight: 400;
261-
color: v-bind('linkTheme.default.textColor');
262-
border-radius: 4px;
263-
transition: color cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
264-
265-
outline-offset: 1px;
266-
267-
&:hover {
268-
color: v-bind('linkTheme.default.hover.textColor');
269-
}
270-
271-
&:active {
272-
color: v-bind('linkTheme.default.textColor');
273-
}
274-
275-
&:focus {
276-
color: v-bind('linkTheme.default.outline.color');
277-
}
278-
}
279234
</style>

0 commit comments

Comments
 (0)