-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Amateur0x1/feature/login
feat: add OAuth implementation
- Loading branch information
Showing
6 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { useEffect } from 'react' | ||
import { useLocation } from 'react-router-dom' | ||
|
||
const Callback = () => { | ||
const location = useLocation() | ||
useEffect(() => { | ||
const searchParams = new URLSearchParams(location.search) | ||
const code = searchParams.get('code') | ||
|
||
if (code) { | ||
fetch(`http://183.131.108.116:3000/auth/github?code=${code}`) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
console.log('User info:', data) | ||
// 在此处处理用户信息,例如保存到状态或重定向到其他页面 | ||
}) | ||
.catch((error) => { | ||
console.error('Error fetching user info:', error) | ||
}) | ||
} | ||
// setTimeout(() => { | ||
// window.location.href = '/' | ||
// }, 5000) // 5000 毫秒即 5 秒 | ||
}) | ||
|
||
return ( | ||
<div> | ||
<p>Redirecting...5s后自动跳转回去</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Callback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,6 @@ export default defineConfig({ | |
}, | ||
server: { | ||
host: true, | ||
port: 5000, | ||
port: 3000, | ||
}, | ||
}) |