diff --git a/src/api/login/index.ts b/src/api/login/index.ts index 24f356ed..536f6a66 100644 --- a/src/api/login/index.ts +++ b/src/api/login/index.ts @@ -1,13 +1,6 @@ import request from '@/config/axios' import { getRefreshToken } from '@/utils/auth' import type { UserLoginVO } from './types' -import { service } from '@/config/axios/service' - -export interface CodeImgResult { - captchaOnOff: boolean - img: string - uuid: string -} export interface SmsCodeVO { mobile: string @@ -74,51 +67,3 @@ export const getCode = (data) => { export const reqCheck = (data) => { return request.postOriginal({ url: 'system/captcha/check', data }) } - -// ========== OAUTH 2.0 相关 ========== -export type scopesType = string[] -export interface paramsType { - responseType: string - clientId: string - redirectUri: string - state: string - scopes: scopesType -} -export const getAuthorize = (clientId) => { - return request.get({ url: '/system/oauth2/authorize?clientId=' + clientId }) -} - -export function authorize( - responseType: string, - clientId: string, - redirectUri: string, - state: string, - autoApprove: boolean, - checkedScopes: scopesType, - uncheckedScopes: scopesType -) { - // 构建 scopes - const scopes = {} - for (const scope of checkedScopes) { - scopes[scope] = true - } - for (const scope of uncheckedScopes) { - scopes[scope] = false - } - // 发起请求 - return service({ - url: '/system/oauth2/authorize', - headers: { - 'Content-type': 'application/x-www-form-urlencoded' - }, - params: { - response_type: responseType, - client_id: clientId, - redirect_uri: redirectUri, - state: state, - auto_approve: autoApprove, - scope: JSON.stringify(scopes) - }, - method: 'post' - }) -} diff --git a/src/api/login/oauth2/index.ts b/src/api/login/oauth2/index.ts new file mode 100644 index 00000000..aef1820d --- /dev/null +++ b/src/api/login/oauth2/index.ts @@ -0,0 +1,41 @@ +import request from '@/config/axios' + +// 获得授权信息 +export const getAuthorize = (clientId: string) => { + return request.get({ url: '/system/oauth2/authorize?clientId=' + clientId }) +} + +// 发起授权 +export const authorize = ( + responseType: string, + clientId: string, + redirectUri: string, + state: string, + autoApprove: boolean, + checkedScopes: string[], + uncheckedScopes: string[] +) => { + // 构建 scopes + const scopes = {} + for (const scope of checkedScopes) { + scopes[scope] = true + } + for (const scope of uncheckedScopes) { + scopes[scope] = false + } + // 发起请求 + return request.post({ + url: '/system/oauth2/authorize', + headers: { + 'Content-type': 'application/x-www-form-urlencoded' + }, + params: { + response_type: responseType, + client_id: clientId, + redirect_uri: redirectUri, + state: state, + auto_approve: autoApprove, + scope: JSON.stringify(scopes) + } + }) +} diff --git a/src/api/login/types.ts b/src/api/login/types.ts index 1a91aecc..b2173f72 100644 --- a/src/api/login/types.ts +++ b/src/api/login/types.ts @@ -26,17 +26,3 @@ export type UserVO = { loginIp: string loginDate: string } - -export type UserInfoVO = { - permissions: [] - roles: [] - user: { - avatar: string - id: number - nickname: string - } -} - -export type TentantNameVO = { - name: string -} diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index da706bb3..cc4bb47e 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -129,12 +129,6 @@ export default { btnMobile: '手机登录', btnQRCode: '二维码登录', qrcode: '扫描二维码登录', - sso: { - user: { - read: '访问你的个人信息', - write: '修改你的个人信息' - } - }, btnRegister: '注册', SmsSendMsg: '验证码已发送' }, diff --git a/src/types/auto-components.d.ts b/src/types/auto-components.d.ts index 431f086f..caea7348 100644 --- a/src/types/auto-components.d.ts +++ b/src/types/auto-components.d.ts @@ -21,6 +21,7 @@ declare module '@vue/runtime-core' { Descriptions: typeof import('./../components/Descriptions/src/Descriptions.vue')['default'] Dialog: typeof import('./../components/Dialog/src/Dialog.vue')['default'] DictTag: typeof import('./../components/DictTag/src/DictTag.vue')['default'] + DocAlert: typeof import('./../components/DocAlert/index.vue')['default'] Echart: typeof import('./../components/Echart/src/Echart.vue')['default'] Editor: typeof import('./../components/Editor/src/Editor.vue')['default'] ElBadge: typeof import('element-plus/es')['ElBadge'] diff --git a/src/views/Login/components/SSOLogin.vue b/src/views/Login/components/SSOLogin.vue index 8efd57f9..acaf38a5 100644 --- a/src/views/Login/components/SSOLogin.vue +++ b/src/views/Login/components/SSOLogin.vue @@ -1,178 +1,178 @@