mirror of
				https://gitee.com/hhyykk/ipms-sjy-ui.git
				synced 2025-10-31 18:28:44 +08:00 
			
		
		
		
	| @@ -1,16 +1,19 @@ | ||||
| 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 | ||||
|   scene: number | ||||
| } | ||||
|  | ||||
| export interface SmsLoginVO { | ||||
|   mobile: string | ||||
|   code: string | ||||
| @@ -71,3 +74,51 @@ 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' | ||||
|   }) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 芋道源码
					芋道源码