从旧 WebVue 移植的地基部分: - 登录页(RSA+MD5 密码加密、redirect 回跳、中英文切换)与登录后落地页 - 401 / 403 / 404 错误页 + error-panel 通用外壳(文案走 ErrorPage 语言包) - 登录守卫双链路:uni.addInterceptor 拦站内跳转,页面级 onShow 复核冷启动深链 - 单一请求链路 common/http.interceptor:JWT 唯一来源、401 并发刷新单例、 业务异常识别、HTTP 403 跳无权限页 - H5 干净短地址:initRouter 前向 __uniRoutes 追加克隆记录(router/h5-clean-url) - 路由登记表 router/routes.ts(PAGE_PATHS / pageUrl / PAGE_PERMISSIONS) 与新增页面四步登记约定(src/md/page-routing.md) - i18n:uView Pro 语言包 + 后端词条合并,双取值(后端 zh-cn/en,包名 zh-CN/en-US) - 后端接口层 service/ 与数据模型 data/auto/ 为生成器产物,不手改 不入库的内容: - 摘除脚手架残留的 Harmony 签名密码(manifest.json signingConfigs 与 harmony-configs/build-profile.json5 的 keyPassword / storePassword 已置空) - 忽略 node_modules、dist、unpackage、.hbuilderx、.agents、pnpm-lock.yaml 及根目录临时截图
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
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,
|
|
};
|
|
}
|