Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

⚑ Lazy load all config editing things

Alicia Sykes160888f1a078
diff --git a/src/components/LinkItems/Item.vue b/src/components/LinkItems/Item.vue
index dd3401d6..020235f1 100644
--- a/src/components/LinkItems/Item.vue
+++ b/src/components/LinkItems/Item.vue
@@ -60,12 +60,14 @@
</template>
<script>
+import { defineAsyncComponent } from 'vue';
import Icon from '@/components/LinkItems/ItemIcon.vue';
import ItemOpenMethodIcon from '@/components/LinkItems/ItemOpenMethodIcon';
import StatusIndicator from '@/components/LinkItems/StatusIndicator';
-import EditItem from '@/components/InteractiveEditor/EditItem';
import MoveItemTo from '@/components/InteractiveEditor/MoveItemTo';
import ContextMenu from '@/components/LinkItems/ItemContextMenu';
+
+const EditItem = defineAsyncComponent(() => import('@/components/InteractiveEditor/EditItem.vue'));
import StoreKeys from '@/utils/StoreMutations';
import ItemMixin from '@/mixins/ItemMixin';
import EditModeIcon from '@/assets/interface-icons/interactive-editor-edit-mode.svg';
diff --git a/src/components/LinkItems/ItemIcon.vue b/src/components/LinkItems/ItemIcon.vue
index 187b1045..dbed7ebf 100644
--- a/src/components/LinkItems/ItemIcon.vue
+++ b/src/components/LinkItems/ItemIcon.vue
@@ -12,7 +12,7 @@
<path v-if="siPath" :d="siPath" />
</svg>
<!-- Standard image asset icon -->
- <img v-else-if="icon" :src="iconPath" @error="imageNotFound"
+ <img v-else-if="icon" :src="iconPath" @error="imageNotFound" loading="lazy"
:class="`tile-icon ${size} ${broken ? 'broken' : ''}`"
/>
<!-- Icon could not load/ broken url -->
@@ -31,7 +31,12 @@ import { faviconApi as defaultFaviconApi, faviconApiEndpoints, iconCdns } from '
// simple-icons is heavy. So lazy load and then share across instances
let simpleIconsPromise = null;
const loadSimpleIcons = () => {
- if (!simpleIconsPromise) simpleIconsPromise = import('simple-icons');
+ if (!simpleIconsPromise) {
+ simpleIconsPromise = import('simple-icons').catch((err) => {
+ simpleIconsPromise = null;
+ throw err;
+ });
+ }
return simpleIconsPromise;
};
@@ -196,13 +201,19 @@ export default {
const host = encodeURI(url) || Math.random().toString();
return (cdn || iconCdns.generative).replace('{icon}', asciiHash(host));
},
- /* Loads SVG path for simple-icons ID. Only loads SI module on first use */
+ /* Loads SVG path for simple-icons ID. Only loads SI module on first use */
async resolveSimpleIcon() {
if (this.iconType !== 'si' || !this.icon) {
this.siPath = '';
return;
}
- const mod = await loadSimpleIcons();
+ let mod;
+ try {
+ mod = await loadSimpleIcons();
+ } catch (e) {
+ this.imageNotFound('Failed to load simple-icons module');
+ return;
+ }
const imageName = this.icon.charAt(3).toUpperCase() + this.icon.slice(4);
const icon = mod[`si${imageName}`];
if (!icon) {
diff --git a/src/components/LinkItems/Section.vue b/src/components/LinkItems/Section.vue
index 61d3ce79..de9efaa0 100644
--- a/src/components/LinkItems/Section.vue
+++ b/src/components/LinkItems/Section.vue
@@ -98,14 +98,16 @@
</template>
<script>
+import { defineAsyncComponent } from 'vue';
import router from '@/router';
import Item from '@/components/LinkItems/Item.vue';
import SubItemGroup from '@/components/LinkItems/SubItemGroup.vue';
import WidgetBase from '@/components/Widgets/WidgetBase';
import Collapsable from '@/components/LinkItems/Collapsable.vue';
import IframeModal from '@/components/LinkItems/IframeModal.vue';
-import EditSection from '@/components/InteractiveEditor/EditSection.vue';
import ContextMenu from '@/components/LinkItems/SectionContextMenu.vue';
+
+const EditSection = defineAsyncComponent(() => import('@/components/InteractiveEditor/EditSection.vue'));
import ErrorHandler from '@/utils/logging/ErrorHandler';
import sortItems from '@/utils/SortItems';
import { makeRoutePath, viewFromPath } from '@/utils/config/ConfigHelpers';
diff --git a/src/views/Home.vue b/src/views/Home.vue
index d872a3ed..10f33f7d 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -51,12 +51,10 @@
</template>
<script>
+import { defineAsyncComponent } from 'vue';
import HomeMixin from '@/mixins/HomeMixin';
import SettingsContainer from '@/components/Settings/SettingsContainer.vue';
import Section from '@/components/LinkItems/Section.vue';
-import EditModeSaveMenu from '@/components/InteractiveEditor/EditModeSaveMenu.vue';
-import ExportConfigMenu from '@/components/InteractiveEditor/ExportConfigMenu.vue';
-import AddNewSection from '@/components/InteractiveEditor/AddNewSectionLauncher.vue';
import NotificationThing from '@/components/Settings/LocalConfigWarning.vue';
import StoreKeys from '@/utils/StoreMutations';
import { modalNames } from '@/utils/config/defaults';
@@ -66,6 +64,10 @@ import {
import ErrorHandler from '@/utils/logging/ErrorHandler';
import BackIcon from '@/assets/interface-icons/back-arrow.svg';
+const EditModeSaveMenu = defineAsyncComponent(() => import('@/components/InteractiveEditor/EditModeSaveMenu.vue'));
+const ExportConfigMenu = defineAsyncComponent(() => import('@/components/InteractiveEditor/ExportConfigMenu.vue'));
+const AddNewSection = defineAsyncComponent(() => import('@/components/InteractiveEditor/AddNewSectionLauncher.vue'));
+
export default {
name: 'home',
mixins: [HomeMixin],