Skip to content

Commit 122606c

Browse files
committed
fix: install vite 7 and resolve conflicts with new version
1 parent be4ac3b commit 122606c

File tree

8 files changed

+348
-164
lines changed

8 files changed

+348
-164
lines changed

adminforth/spa/package-lock.json

Lines changed: 298 additions & 140 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/spa/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"@rushstack/eslint-patch": "^1.14.1",
3737
"@tsconfig/node20": "^20.1.6",
3838
"@types/node": "^20.19.24",
39-
"@vitejs/plugin-vue": "^5.2.4",
39+
"@vitejs/plugin-vue": "^6.0.2",
4040
"@vue/eslint-config-typescript": "^13.0.0",
4141
"@vue/tsconfig": "^0.8.1",
4242
"autoprefixer": "^10.4.21",
@@ -51,7 +51,7 @@
5151
"sass": "^1.93.3",
5252
"tailwindcss": "^3.4.18",
5353
"typescript": "~5.9.3",
54-
"vite": "^5.4.21",
54+
"vite": "^7.2.4",
5555
"vue-i18n-extract": "^2.0.7",
5656
"vue-tsc": "^2.2.12",
5757
"vue3-json-viewer": "^2.4.1"

adminforth/spa/src/components/Sidebar.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@
2222
}"
2323
>
2424
<img
25-
:src="loadFile(coreStore.config?.brandLogo || '@/assets/logo.svg')"
25+
:src="imgUrl"
2626
:alt="`${ coreStore.config?.brandName } Logo`"
2727
class="af-logo h-8 me-3"
2828
:class="{
29-
'hidden': !(coreStore.config?.showBrandLogoInSidebar !== false && (!iconOnlySidebarEnabled || !isSidebarIconOnly || (isSidebarIconOnly && isSidebarHovering))) }"
29+
'hidden': !(coreStore.config?.showBrandLogoInSidebar !== false && (!iconOnlySidebarEnabled || !isSidebarIconOnly || (isSidebarIconOnly && isSidebarHovering)))
30+
}"
31+
/>
32+
<img
33+
:src="iconOnlySidebar"
34+
:alt="`${ coreStore.config?.brandName } Logo`"
35+
class="af-sidebar-icon-only-logo h-8"
36+
:class="{
37+
'hidden': !(coreStore.config?.showBrandLogoInSidebar !== false && coreStore.config?.iconOnlySidebar?.logo && iconOnlySidebarEnabled && isSidebarIconOnly && !isSidebarHovering)
38+
}"
3039
/>
31-
<img :src="loadFile(coreStore.config?.iconOnlySidebar?.logo || '')" :alt="`${ coreStore.config?.brandName } Logo`" class="af-sidebar-icon-only-logo h-8" :class="{ 'hidden': !(coreStore.config?.showBrandLogoInSidebar !== false && coreStore.config?.iconOnlySidebar?.logo && iconOnlySidebarEnabled && isSidebarIconOnly && !isSidebarHovering) }" />
3240
<span
3341
v-if="coreStore.config?.showBrandNameInSidebar && (!iconOnlySidebarEnabled || !isSidebarIconOnly || (isSidebarIconOnly && isSidebarHovering))"
3442
class="af-title self-center text-lightNavbarText-size font-semibold sm:text-lightNavbarText-size whitespace-nowrap dark:text-darkSidebarText text-lightSidebarText"
@@ -320,6 +328,14 @@ const coreStore = useCoreStore();
320328
const opened = ref<(string|number)[]>([]);
321329
const sidebarAside = ref(null);
322330
331+
const imgUrl = ref<string>('');
332+
const iconOnlySidebar = ref<string>('');
333+
334+
onMounted(async () => {
335+
imgUrl.value = await loadFile(coreStore.config?.brandLogo || '@/assets/logo.svg') as string;
336+
iconOnlySidebar.value = await loadFile(coreStore.config?.iconOnlySidebar?.logo || '') as string;
337+
});
338+
323339
const smQuery = window.matchMedia('(min-width: 640px)');
324340
const isMobile = ref(!smQuery.matches);
325341
const iconOnlySidebarEnabled = computed(() => props.forceIconOnly === true || coreStore.config?.iconOnlySidebar?.enabled !== false);

adminforth/spa/src/utils.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,27 +82,28 @@ export function getIcon(icon: string) {
8282
return resolveComponent(compName);
8383
}
8484

85-
export const loadFile = (file: string) => {
85+
export const loadFile = async (file: string) => {
8686
if (file.startsWith('http')) {
8787
return file;
8888
}
89-
console.log('file', file);
9089
let path;
9190
let baseUrl = '';
91+
const files = import.meta.glob('/**/*', { import: 'default' });
92+
9293
if (file.startsWith('@/')) {
93-
path = file.replace('@/', '');
94-
console.log('path', path);
95-
const fileModulePath = `./${path}`;
96-
console.log('imort.meta.url', import.meta.url);
97-
baseUrl = new URL(`./${path}` ,import.meta.url).href;
98-
console.log('baseUrl', baseUrl);
94+
path = file.replace('@/', '/src/');
9995
} else if (file.startsWith('@@/')) {
100-
path = file.replace('@@/', '');
101-
const fileModulePath = `./${path}`;
102-
baseUrl = new URL(`./${path}`, new URL(import.meta.url).origin + new URL(import.meta.url).pathname).href;
96+
path = file.replace('@@/', '/src/custom/');
97+
} else {
98+
path = `./${file}`;
99+
}
100+
101+
const match = files[path];
102+
if (!match) {
103+
console.error(`File ${file} not found`);
103104
} else {
104-
const fileModulePath = `./${file}`;
105-
baseUrl = new URL(`./${file}`, new URL(import.meta.url).origin + new URL(import.meta.url).pathname).href;
105+
const result = await match();
106+
baseUrl = typeof result === 'string' ? result : '';
106107
}
107108
return baseUrl;
108109
}

adminforth/spa/src/views/LoginView.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<template>
22
<div class="relative flex items-center justify-center min-h-screen bg-lightHtml dark:bg-darkHtml w-screen h-screen"
33
:style="coreStore.config?.loginBackgroundImage && backgroundPosition === 'over' ? {
4-
'background-image': 'url(' + loadFile(coreStore.config?.loginBackgroundImage) + ')',
4+
'background-image': 'url(' + backgroundImage + ')',
55
'background-size': 'cover',
66
'background-position': 'center',
77
'background-blend-mode': coreStore.config?.removeBackgroundBlendMode ? 'normal' : 'darken'
88
}: {}"
99
>
1010

1111
<img v-if="coreStore.config?.loginBackgroundImage && backgroundPosition !== 'over'"
12-
:src="loadFile(coreStore.config?.loginBackgroundImage)"
12+
:src="backgroundImage"
1313
class="position-absolute top-0 left-0 h-screen object-cover w-0"
1414
:class="{
1515
'1/2': 'md:w-1/2',
@@ -158,6 +158,7 @@ const backgroundPosition = computed(() => {
158158
return coreStore.config?.loginBackgroundPosition || '1/2';
159159
});
160160
161+
const backgroundImage = ref<string>('');
161162
162163
onBeforeMount(() => {
163164
if (localStorage.getItem('isAuthorized') === 'true') {
@@ -173,6 +174,9 @@ onBeforeMount(() => {
173174
174175
onMounted(async () => {
175176
coreStore.getLoginFormConfig();
177+
if (coreStore.config?.loginBackgroundImage) {
178+
backgroundImage.value = await loadFile(coreStore.config?.loginBackgroundImage) as string;
179+
}
176180
if (coreStore.config?.demoCredentials) {
177181
const [demoUsername, demoPassword] = coreStore.config.demoCredentials.split(':');
178182
username.value = demoUsername;

adminforth/spa/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,7 @@ export default defineConfig({
9292
},
9393
},
9494
},
95+
optimizeDeps: {
96+
exclude: ['@vitejs/plugin-vue']
97+
}
9598
})

dev-demo/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ export const admin = new AdminForth({
131131
customLayout: true,
132132
}}
133133
}],
134-
134+
iconOnlySidebar: {
135+
logo: '@/assets/logo.svg',
136+
},
135137
vueUsesFile: '@@/vueUses.ts', // @@ is alias to custom directory,
136138
brandName: 'New Reality',
137139
showBrandNameInSidebar: true,

dev-demo/resources/users.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ export default {
8282
// // return true;
8383
// return adminUser.dbUser.email !== "adminforth";
8484
// },
85-
// usersFilterToAllowSkipSetup: (adminUser: AdminUser) => {
86-
// return adminUser.dbUser.email === "adminforth";
87-
// },
85+
usersFilterToAllowSkipSetup: (adminUser: AdminUser) => {
86+
return adminUser.dbUser.email === "adminforth";
87+
},
8888
passkeys: {
8989
credentialResourceID: "passkeys",
9090
credentialIdFieldName: "credential_id",

0 commit comments

Comments
 (0)