import schoolTheme from "~/assets/school/theme.json"; import { composSystemTheme } from "~/composables/composSystemTheme"; // بارگذاری خودکار تمام فایل‌های theme.json موجود در پوشه assets/* const themeModules = import.meta.glob>("~/assets/*/theme.json", { eager: true, import: "default", }); export const themes: Record = { school: schoolTheme, }; // نگاشت تمام پروژه‌ها بر اساس نام پوشه (school, hamyar, ...) for (const [path, moduleContent] of Object.entries(themeModules)) { const match = path.match(/assets\/([^/]+)\/theme\.json/); if (match && match[1]) { themes[match[1]] = moduleContent; } } export default defineNuxtPlugin(async (nuxtApp) => { const config = useRuntimeConfig(); // کلید سیستم از فایل .env فعال (پیش‌فرض: school) const systemKey = (config.public.NUXT_PUBLIC_SYSTEM as string) || "school"; const theme = themes[systemKey] || themes.school || schoolTheme; // ارائه به تمام کانتکست‌های Nuxt nuxtApp.provide("theme", theme); nuxtApp.provide("themeKey", systemKey); nuxtApp.provide("allThemes", themes); if (import.meta.client) { const systemTheme = composSystemTheme(); await systemTheme.applyTheme(theme); } });