From c11d56da2928a02dadaef832c164605bfa6ddb2d Mon Sep 17 00:00:00 2001 From: Soybean Date: Sun, 24 Mar 2024 15:39:41 +0800 Subject: [PATCH] feat(projects): add auth example --- .env | 5 +- src/components/common/exception-base.vue | 7 +- src/hooks/business/auth.ts | 21 ++++ src/locales/langs/en-us.ts | 15 ++- src/locales/langs/zh-cn.ts | 9 ++ src/router/elegant/imports.ts | 2 + src/router/elegant/routes.ts | 32 +++++- src/router/elegant/transform.ts | 2 + src/router/guard/permission.ts | 7 +- src/store/modules/auth/index.ts | 15 ++- src/store/modules/auth/shared.ts | 8 +- src/store/modules/route/index.ts | 2 + src/store/modules/route/shared.ts | 7 +- src/typings/api.d.ts | 1 + src/typings/app.d.ts | 7 ++ src/typings/elegant-router.d.ts | 4 + src/typings/env.d.ts | 2 + .../_builtin/login/modules/pwd-login.vue | 40 ++++++++ src/views/function/super-page/index.vue | 7 ++ src/views/function/toggle-auth/index.vue | 98 +++++++++++++++++++ 20 files changed, 269 insertions(+), 22 deletions(-) create mode 100644 src/hooks/business/auth.ts create mode 100644 src/views/function/super-page/index.vue create mode 100644 src/views/function/toggle-auth/index.vue diff --git a/.env b/.env index 76b49edc..3f7b9be8 100644 --- a/.env +++ b/.env @@ -12,7 +12,7 @@ VITE_ICON_PREFIX=icon VITE_ICON_LOCAL_PREFIX=icon-local # auth route mode: static | dynamic -VITE_AUTH_ROUTE_MODE=static +VITE_AUTH_ROUTE_MODE=dynamic # static auth route home VITE_ROUTE_HOME=home @@ -37,3 +37,6 @@ VITE_SERVICE_MODAL_LOGOUT_CODES=7777,7778 # token expired codes of backend service, when the code is received, it will refresh the token and resend the request VITE_SERVICE_EXPIRED_TOKEN_CODES=9999,9998 + +# when the route mode is static, the defined super role +VITE_STATIC_SUPER_ROLE=R_SUPER diff --git a/src/components/common/exception-base.vue b/src/components/common/exception-base.vue index a861d3ae..4b1dfc27 100644 --- a/src/components/common/exception-base.vue +++ b/src/components/common/exception-base.vue @@ -1,6 +1,7 @@ diff --git a/src/views/function/super-page/index.vue b/src/views/function/super-page/index.vue new file mode 100644 index 00000000..2a654c50 --- /dev/null +++ b/src/views/function/super-page/index.vue @@ -0,0 +1,7 @@ + + + + + diff --git a/src/views/function/toggle-auth/index.vue b/src/views/function/toggle-auth/index.vue new file mode 100644 index 00000000..bf1b38be --- /dev/null +++ b/src/views/function/toggle-auth/index.vue @@ -0,0 +1,98 @@ + + + + +