Skip to content

Commit 276e82c

Browse files
committed
REVIEW 单点登录界面
1 parent 0f0ba8b commit 276e82c

File tree

6 files changed

+162
-196
lines changed

6 files changed

+162
-196
lines changed

src/api/login/index.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import request from '@/config/axios'
22
import { getRefreshToken } from '@/utils/auth'
33
import type { UserLoginVO } from './types'
4-
import { service } from '@/config/axios/service'
5-
6-
export interface CodeImgResult {
7-
captchaOnOff: boolean
8-
img: string
9-
uuid: string
10-
}
114

125
export interface SmsCodeVO {
136
mobile: string
@@ -74,51 +67,3 @@ export const getCode = (data) => {
7467
export const reqCheck = (data) => {
7568
return request.postOriginal({ url: 'system/captcha/check', data })
7669
}
77-
78-
// ========== OAUTH 2.0 相关 ==========
79-
export type scopesType = string[]
80-
export interface paramsType {
81-
responseType: string
82-
clientId: string
83-
redirectUri: string
84-
state: string
85-
scopes: scopesType
86-
}
87-
export const getAuthorize = (clientId) => {
88-
return request.get({ url: '/system/oauth2/authorize?clientId=' + clientId })
89-
}
90-
91-
export function authorize(
92-
responseType: string,
93-
clientId: string,
94-
redirectUri: string,
95-
state: string,
96-
autoApprove: boolean,
97-
checkedScopes: scopesType,
98-
uncheckedScopes: scopesType
99-
) {
100-
// 构建 scopes
101-
const scopes = {}
102-
for (const scope of checkedScopes) {
103-
scopes[scope] = true
104-
}
105-
for (const scope of uncheckedScopes) {
106-
scopes[scope] = false
107-
}
108-
// 发起请求
109-
return service({
110-
url: '/system/oauth2/authorize',
111-
headers: {
112-
'Content-type': 'application/x-www-form-urlencoded'
113-
},
114-
params: {
115-
response_type: responseType,
116-
client_id: clientId,
117-
redirect_uri: redirectUri,
118-
state: state,
119-
auto_approve: autoApprove,
120-
scope: JSON.stringify(scopes)
121-
},
122-
method: 'post'
123-
})
124-
}

src/api/login/oauth2/index.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import request from '@/config/axios'
2+
3+
// 获得授权信息
4+
export const getAuthorize = (clientId: string) => {
5+
return request.get({ url: '/system/oauth2/authorize?clientId=' + clientId })
6+
}
7+
8+
// 发起授权
9+
export const authorize = (
10+
responseType: string,
11+
clientId: string,
12+
redirectUri: string,
13+
state: string,
14+
autoApprove: boolean,
15+
checkedScopes: string[],
16+
uncheckedScopes: string[]
17+
) => {
18+
// 构建 scopes
19+
const scopes = {}
20+
for (const scope of checkedScopes) {
21+
scopes[scope] = true
22+
}
23+
for (const scope of uncheckedScopes) {
24+
scopes[scope] = false
25+
}
26+
// 发起请求
27+
return request.post({
28+
url: '/system/oauth2/authorize',
29+
headers: {
30+
'Content-type': 'application/x-www-form-urlencoded'
31+
},
32+
params: {
33+
response_type: responseType,
34+
client_id: clientId,
35+
redirect_uri: redirectUri,
36+
state: state,
37+
auto_approve: autoApprove,
38+
scope: JSON.stringify(scopes)
39+
}
40+
})
41+
}

src/api/login/types.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,3 @@ export type UserVO = {
2626
loginIp: string
2727
loginDate: string
2828
}
29-
30-
export type UserInfoVO = {
31-
permissions: []
32-
roles: []
33-
user: {
34-
avatar: string
35-
id: number
36-
nickname: string
37-
}
38-
}
39-
40-
export type TentantNameVO = {
41-
name: string
42-
}

src/locales/zh-CN.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,6 @@ export default {
129129
btnMobile: '手机登录',
130130
btnQRCode: '二维码登录',
131131
qrcode: '扫描二维码登录',
132-
sso: {
133-
user: {
134-
read: '访问你的个人信息',
135-
write: '修改你的个人信息'
136-
}
137-
},
138132
btnRegister: '注册',
139133
SmsSendMsg: '验证码已发送'
140134
},

src/types/auto-components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ declare module '@vue/runtime-core' {
2121
Descriptions: typeof import('./../components/Descriptions/src/Descriptions.vue')['default']
2222
Dialog: typeof import('./../components/Dialog/src/Dialog.vue')['default']
2323
DictTag: typeof import('./../components/DictTag/src/DictTag.vue')['default']
24+
DocAlert: typeof import('./../components/DocAlert/index.vue')['default']
2425
Echart: typeof import('./../components/Echart/src/Echart.vue')['default']
2526
Editor: typeof import('./../components/Editor/src/Editor.vue')['default']
2627
ElBadge: typeof import('element-plus/es')['ElBadge']

0 commit comments

Comments
 (0)