从旧 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 及根目录临时截图
54 lines
1.8 KiB
Vue
54 lines
1.8 KiB
Vue
<script setup lang="ts">
|
||
// 403 无权限页,移植自旧 WebVue 的 views/error/page403.vue
|
||
// 谁来跳:请求层拿到 HTTP 403(common/http.interceptor)时带原地址跳本页;
|
||
// 页面级权限校验(旧 setupPermissionGuard)等 PAGE_PERMISSIONS 接入后接在 nav-guard
|
||
import { onLoad } from "@dcloudio/uni-app";
|
||
import { useLocale } from "uview-pro";
|
||
import { computed, ref } from "vue";
|
||
import { goLoginWithRedirect } from "@/router/nav-guard";
|
||
import { decodeQueryPath, pageUrl } from "@/router/routes";
|
||
|
||
const { t } = useLocale();
|
||
|
||
/** 出错的地址:跳页时用 ?from= 带过来 */
|
||
const fromPath = ref("");
|
||
onLoad((options) => {
|
||
fromPath.value = decodeQueryPath(options?.from);
|
||
});
|
||
|
||
const reasons = computed(() => [
|
||
t("ErrorPage.r403_1"),
|
||
t("ErrorPage.r403_2"),
|
||
t("ErrorPage.r403_3"),
|
||
t("ErrorPage.r403_4"),
|
||
]);
|
||
|
||
/** 重新登录:权限随令牌一起下发,变更后必须重登才会生效 */
|
||
function handleRelogin() {
|
||
goLoginWithRedirect(fromPath.value);
|
||
}
|
||
|
||
/** 回首页:首页本身只要求登录,不要求具体功能权限 */
|
||
function handleGoHome() {
|
||
uni.reLaunch({ url: pageUrl("dashboard") });
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<error-panel
|
||
code="403" tone="amber" :badge="t('ErrorPage.badge403')" :title="t('ErrorPage.title403')"
|
||
:description="t('ErrorPage.desc403')" :reasons="reasons" :from="fromPath" :hint="t('ErrorPage.hint403')"
|
||
>
|
||
<template #icon>
|
||
<u-icon name="warning-fill" size="52" color="#ffffff" />
|
||
</template>
|
||
<template #actions>
|
||
<u-button
|
||
type="primary" size="large" shape="circle" :text="t('ErrorPage.reloginBut')"
|
||
@click="handleRelogin"
|
||
/>
|
||
<u-button size="large" shape="circle" :text="t('ErrorPage.goHomeBut')" @click="handleGoHome" />
|
||
</template>
|
||
</error-panel>
|
||
</template>
|