From 6114c3d6c5432e528d5879a938a8672172dbcfda Mon Sep 17 00:00:00 2001 From: lbw Date: Tue, 14 Feb 2023 13:03:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AE=E9=A1=B9=E6=8A=BD?= =?UTF-8?q?=E5=8F=96=E8=87=B3ENV=20=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E4=B8=AD=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 20 +++++- src/api/login/index.ts | 13 ++-- src/layout/navBars/breadcrumb/user.vue | 99 +++++++++++++------------- src/stores/themeConfig.ts | 6 +- src/stores/userInfo.ts | 8 +-- src/types/pinia.d.ts | 2 - src/views/login/index.vue | 41 ++++++----- 7 files changed, 101 insertions(+), 88 deletions(-) diff --git a/.env b/.env index 301d2415..9af53db1 100644 --- a/.env +++ b/.env @@ -1,5 +1,14 @@ -# port 端口号 -VITE_PORT = 8888 +# 前端加密密钥 +VITE_PWD_ENC_KEY='pigxpigxpigxpigx' + +# OAUTH2 密码模式客户端信息 +VITE_OAUTH2_PASSWORD_CLIENT='pig:pig' + +# OAUTH2 短信客户端信息 +VITE_OAUTH2_MOBILE_CLIENT='app:app' + +# OAUTH2 社交登录客户端信息 +VITE_OAUTH2_SOCIAL_CLIENT='social:social' # ADMIN 服务地址 VITE_ADMIN_PROXY_PATH = http://localhost:9999 @@ -7,5 +16,12 @@ VITE_ADMIN_PROXY_PATH = http://localhost:9999 # 代码生成服务地址 VITE_GEN_PROXY_PATH = http://localhost:5003 +# 是否开启websocket 消息接受, +VITE_WEBSOCKET_ENABLE = false + +# 是否开启注册 +VITE_REGISTER_ENABLE = false + # 代码代码前缀 VITE_PUBLIC_PATH = / + diff --git a/src/api/login/index.ts b/src/api/login/index.ts index 93158f4d..b56b94de 100644 --- a/src/api/login/index.ts +++ b/src/api/login/index.ts @@ -8,7 +8,8 @@ import { useUserInfo } from "/@/stores/userInfo"; * @param data */ export const login = (data: any) => { - let basicAuth = 'Basic ' + window.btoa('pig:pig') + const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_PASSWORD_CLIENT) + Session.set('basicAuth', basicAuth) return request({ url: '/admin/oauth2/token', method: 'post', @@ -24,7 +25,8 @@ export const login = (data: any) => { export const loginByMobile = (mobile: any, code: any) => { const grant_type = 'mobile' const scope = 'server' - let basicAuth = 'Basic ' + window.btoa('app:app') + const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_MOBILE_CLIENT) + Session.set('basicAuth', basicAuth) return request({ url: '/admin/oauth2/token', @@ -41,7 +43,8 @@ export const loginByMobile = (mobile: any, code: any) => { export const loginBySocial = (state: string, code: string) => { const grant_type = 'mobile' const scope = 'server' - let basicAuth = 'Basic ' + window.btoa('social:social') + const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_SOCIAL_CLIENT) + Session.set('basicAuth', basicAuth) return request({ url: '/admin/oauth2/token', @@ -66,7 +69,7 @@ export const refreshTokenApi = (refresh_token: string) => { const grant_type = 'refresh_token' const scope = 'server' // 获取当前选中的 basic 认证信息 - let basicAuth = 'Basic ' + window.btoa('pig:pig') + const basicAuth = Session.get('basicAuth') return request({ url: '/admin/oauth2/token', @@ -85,7 +88,7 @@ export const refreshTokenApi = (refresh_token: string) => { * @param refreshLock */ export const checkToken = (refreshTime: number, refreshLock: boolean) => { - let basicAuth = 'Basic ' + window.btoa('pig:pig') + const basicAuth = Session.get('basicAuth') request({ url: '/admin/token/check_token', headers: { diff --git a/src/layout/navBars/breadcrumb/user.vue b/src/layout/navBars/breadcrumb/user.vue index 011a2d4c..42d578b4 100644 --- a/src/layout/navBars/breadcrumb/user.vue +++ b/src/layout/navBars/breadcrumb/user.vue @@ -7,27 +7,24 @@
- +