删除dashboard过滤相关的冗余代码
This commit is contained in:
parent
67019666b9
commit
a135223579
@ -16,8 +16,7 @@ const getBackendUrl = () => {
|
|||||||
} else {
|
} else {
|
||||||
// 生产环境:使用绝对 URL
|
// 生产环境:使用绝对 URL
|
||||||
const backendUrl = import.meta.env.VITE_JINGROW_BACKEND_URL || 'https://cloud.jingrow.com'
|
const backendUrl = import.meta.env.VITE_JINGROW_BACKEND_URL || 'https://cloud.jingrow.com'
|
||||||
// 确保 URL 不以 /dashboard 结尾(API 路径应该直接在根路径下)
|
return backendUrl
|
||||||
return backendUrl.replace(/\/dashboard\/?$/, '')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,12 +18,7 @@ import {
|
|||||||
// 从环境变量或配置获取 OAuth2 配置
|
// 从环境变量或配置获取 OAuth2 配置
|
||||||
const getOAuth2Config = () => {
|
const getOAuth2Config = () => {
|
||||||
// 从环境变量或配置中获取
|
// 从环境变量或配置中获取
|
||||||
let backendUrl = import.meta.env.VITE_JINGROW_BACKEND_URL || 'https://cloud.jingrow.com'
|
const backendUrl = import.meta.env.VITE_JINGROW_BACKEND_URL || 'https://cloud.jingrow.com'
|
||||||
|
|
||||||
// 确保 URL 不以 /dashboard 结尾(API 路径应该直接在根路径下)
|
|
||||||
// 如果用户设置了 /dashboard,自动移除
|
|
||||||
backendUrl = backendUrl.replace(/\/dashboard\/?$/, '')
|
|
||||||
|
|
||||||
const clientId = import.meta.env.VITE_OAUTH2_CLIENT_ID || 'i679osfadt'
|
const clientId = import.meta.env.VITE_OAUTH2_CLIENT_ID || 'i679osfadt'
|
||||||
const redirectUri = `${window.location.origin}/oauth/callback`
|
const redirectUri = `${window.location.origin}/oauth/callback`
|
||||||
|
|
||||||
@ -80,7 +75,6 @@ export async function getAuthorizationUrl(state?: string): Promise<string> {
|
|||||||
...(state && { state })
|
...(state && { state })
|
||||||
})
|
})
|
||||||
|
|
||||||
// 确保 API 路径正确(不应该包含 /dashboard)
|
|
||||||
const apiPath = '/api/action/jingrow.integrations.oauth2.authorize'
|
const apiPath = '/api/action/jingrow.integrations.oauth2.authorize'
|
||||||
const authUrl = `${config.backendUrl}${apiPath}?${params.toString()}`
|
const authUrl = `${config.backendUrl}${apiPath}?${params.toString()}`
|
||||||
|
|
||||||
@ -216,7 +210,6 @@ export async function refreshAccessToken(): Promise<TokenInfo> {
|
|||||||
* 撤销 token
|
* 撤销 token
|
||||||
*/
|
*/
|
||||||
export async function revokeToken(token?: string, tokenTypeHint: 'access_token' | 'refresh_token' = 'access_token'): Promise<void> {
|
export async function revokeToken(token?: string, tokenTypeHint: 'access_token' | 'refresh_token' = 'access_token'): Promise<void> {
|
||||||
const config = getOAuth2Config()
|
|
||||||
const tokenToRevoke = token || (tokenTypeHint === 'access_token' ? getAccessToken() : getRefreshToken())
|
const tokenToRevoke = token || (tokenTypeHint === 'access_token' ? getAccessToken() : getRefreshToken())
|
||||||
|
|
||||||
if (!tokenToRevoke) {
|
if (!tokenToRevoke) {
|
||||||
@ -254,7 +247,6 @@ export async function revokeToken(token?: string, tokenTypeHint: 'access_token'
|
|||||||
* 获取用户信息(OpenID Connect userinfo)
|
* 获取用户信息(OpenID Connect userinfo)
|
||||||
*/
|
*/
|
||||||
export async function getUserInfo(): Promise<any> {
|
export async function getUserInfo(): Promise<any> {
|
||||||
const config = getOAuth2Config()
|
|
||||||
const accessToken = getAccessToken()
|
const accessToken = getAccessToken()
|
||||||
|
|
||||||
if (!accessToken) {
|
if (!accessToken) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user