From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/api/login/oauth2/index.ts | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/src/api/login/oauth2/index.ts b/src/api/login/oauth2/index.ts
new file mode 100644
index 0000000..f4a67fb
--- /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)
+ }
+ })
+}
--
Gitblit v1.8.0