import * as Pinia from "pinia"; import uViewPro, { httpPlugin } from "uview-pro"; import { createSSRApp } from "vue"; import { DEFAULT_LOCALE } from "@/common/locale-const"; import themes from "@/common/uview-pro.theme"; import { enUS, mergeDbLocaleMessages, zhCN } from "@/locale"; // #ifdef H5 import { registerCleanUrls } from "@/router/h5-clean-url"; import { setupUnknownPathFallback } from "@/router/nav-guard"; // #endif import store from "@/stores"; import App from "./App.vue"; import { httpInterceptor, httpRequestConfig } from "./common/http.interceptor"; import "uno.css"; // #ifdef H5 // 为 /login、/dashboard 追加短地址路由记录,必须早于 uni-h5 创建 router registerCleanUrls(); // 地址栏是一个路由表里不存在的地址时,uni 只会白屏加一条 "No match found",这里兜底跳 404 setupUnknownPathFallback(); // #endif export function createApp() { const app = createSSRApp(App); app.use(uViewPro, { theme: { themes, defaultTheme: "green", defaultDarkMode: "light", }, locale: { locales: [zhCN, enUS], defaultLocale: DEFAULT_LOCALE, }, }); app.use(httpPlugin, { requestConfig: httpRequestConfig, interceptor: httpInterceptor, }); app.use(store); // 拉取数据库翻译并合并进本地语言包(不 await,避免接口慢/失败阻塞启动) mergeDbLocaleMessages(); return { app, Pinia, }; }