import App from "./App"; import uviewPlus from "uview-plus"; import { createPinia } from "pinia"; import { messages } from "./locale/index"; import { interpolateTemplate } from "./locale/utils"; import vEllipsis from './directives/v-ellipsis' import { createI18n } from "vue-i18n"; import { routeInterceptor } from '@/utils/routeInterceptor.js' import { lang } from '@/composables/config' import { watch } from "vue"; import vT from './directives/v-t' export const i18n = createI18n({ legacy: false, allowComposition: true, locale: lang.value || "cn", messages, }); globalThis.__i18n = i18n const pinia = createPinia(); // #ifdef VUE3 import { createSSRApp } from "vue"; export function createApp() { const app = createSSRApp(App); app.directive('ellipsis', vEllipsis); app.use(uviewPlus); app.use(pinia); app.use(i18n); app.directive('t', vT); // 保持 locale 与存储 lang 同步(可选) watch(() => lang.value, (val) => { if (!val) return; if (i18n?.global?.locale?.value !== undefined) { i18n.global.locale.value = val; } }, { immediate: true, flush: 'sync' }); routeInterceptor.install(); return { app }; } // #endif