diff --git a/.env.example b/.env.example index 873ff68..5a95d73 100644 --- a/.env.example +++ b/.env.example @@ -8,4 +8,7 @@ BOOTSTRAP_ADMIN_USERNAME=admin BOOTSTRAP_ADMIN_PASSWORD=123456qaz GITHUB_CLIENT_ID=your_github_client_id GITHUB_CLIENT_SECRET=your_github_client_secret +GITEA_CLIENT_ID=your_gitea_client_id +GITEA_CLIENT_SECRET=your_gitea_client_secret +GITEA_URL=https://gitea.com APP_URL=http://localhost:3399 \ No newline at end of file diff --git a/app/pages/auth/login.vue b/app/pages/auth/login.vue index dec62ae..a9d2f50 100644 --- a/app/pages/auth/login.vue +++ b/app/pages/auth/login.vue @@ -7,21 +7,6 @@ const route = useRoute() const { $toast } = useNuxtApp() const redirect = computed(() => route.query.redirect as string || '/') -onMounted(() => { - const url = new URL(window.location.href) - if (url.searchParams.get('oauth_success') === '1') { - refresh(true) - router.push('/') - } - if (url.searchParams.get('oauth_error')) { - const error = url.searchParams.get('oauth_error') - console.error('OAuth error:', error) - url.searchParams.delete('oauth_error') - window.history.replaceState({}, document.title, url.href); - $toast.error(`OAuth 登录失败: ${error}`) - } -}) - const loginForm = reactive({ username: '', password: '', @@ -43,6 +28,10 @@ async function loginWithGithub() { window.location.href = '/api/auth/oauth/github/authorize'; } +async function loginWithGitea() { + window.location.href = '/api/auth/oauth/gitea/authorize'; +} + async function fetchCaptcha() { captcha.loading = true try { @@ -82,6 +71,7 @@ async function handleLogin() { onMounted(() => { fetchCaptcha() + const url = new URL(window.location.href) if (url.searchParams.get('oauth_success') === '1') { refresh(true) @@ -90,6 +80,9 @@ onMounted(() => { if (url.searchParams.get('oauth_error')) { const error = url.searchParams.get('oauth_error') console.error('OAuth error:', error) + url.searchParams.delete('oauth_error') + window.history.replaceState({}, document.title, url.href) + $toast.error(`OAuth 登录失败: ${error}`) } }) @@ -155,12 +148,22 @@ onMounted(() => { - +
+ + + +