mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-25 07:30:46 +08:00
feat: request google login while refresh
This commit is contained in:
@@ -8,8 +8,9 @@ import './assets/toast.css'
|
||||
// Use Sugar theme from vue-toast-notification for better toast styling.
|
||||
// If you prefer Bootstrap style, replace with theme-bootstrap.css instead.
|
||||
import { useToast } from 'vue-toastification'
|
||||
import { checkToken, clearToken } from './utils/auth'
|
||||
import { checkToken, clearToken, isLogin } from './utils/auth'
|
||||
import { initTheme } from './utils/theme'
|
||||
import { loginWithGoogle } from './utils/google'
|
||||
|
||||
// Configurable API domain and port
|
||||
// export const API_DOMAIN = 'http://127.0.0.1'
|
||||
@@ -47,4 +48,10 @@ checkToken().then(valid => {
|
||||
if (!valid) {
|
||||
clearToken()
|
||||
}
|
||||
|
||||
if (!isLogin()) {
|
||||
setTimeout(() => {
|
||||
loginWithGoogle()
|
||||
}, 3000)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -50,3 +50,11 @@ export async function googleSignIn(redirect_success, redirect_not_approved) {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export function loginWithGoogle() {
|
||||
googleSignIn(() => {
|
||||
this.$router.push('/')
|
||||
}, (token) => {
|
||||
this.$router.push('/signup-reason?token=' + token)
|
||||
})
|
||||
}
|
||||
@@ -111,7 +111,7 @@ import { ref, onMounted, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { stripMarkdown } from '../utils/markdown'
|
||||
import { API_BASE_URL } from '../main'
|
||||
import { getToken } from '../utils/auth'
|
||||
import { getToken, isLogin } from '../utils/auth'
|
||||
import TimeManager from '../utils/time'
|
||||
import CategorySelect from '../components/CategorySelect.vue'
|
||||
import TagSelect from '../components/TagSelect.vue'
|
||||
@@ -120,6 +120,7 @@ import ArticleCategory from '../components/ArticleCategory.vue'
|
||||
import SearchDropdown from '../components/SearchDropdown.vue'
|
||||
import { hatch } from 'ldrs'
|
||||
import { isMobile } from '../utils/screen'
|
||||
import { loginWithGoogle } from '../utils/google'
|
||||
hatch.register()
|
||||
|
||||
|
||||
@@ -364,6 +365,12 @@ export default {
|
||||
onMounted(async () => {
|
||||
await loadOptions()
|
||||
fetchContent()
|
||||
if (!isLogin()) {
|
||||
//
|
||||
}
|
||||
setTimeout(() => {
|
||||
loginWithGoogle()
|
||||
}, 3000)
|
||||
})
|
||||
|
||||
watch([selectedCategory, selectedTags], () => {
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<script>
|
||||
import { API_BASE_URL, toast } from '../main'
|
||||
import { setToken, loadCurrentUser } from '../utils/auth'
|
||||
import { googleSignIn } from '../utils/google'
|
||||
import { loginWithGoogle } from '../utils/google'
|
||||
import { githubAuthorize } from '../utils/github'
|
||||
import { discordAuthorize } from '../utils/discord'
|
||||
import { twitterAuthorize } from '../utils/twitter'
|
||||
@@ -61,6 +61,9 @@ import BaseInput from '../components/BaseInput.vue'
|
||||
export default {
|
||||
name: 'LoginPageView',
|
||||
components: { BaseInput },
|
||||
setup() {
|
||||
return { loginWithGoogle }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
username: '',
|
||||
@@ -99,16 +102,7 @@ export default {
|
||||
toast.error('登录失败')
|
||||
}
|
||||
},
|
||||
loginWithGoogle() {
|
||||
googleSignIn(
|
||||
() => {
|
||||
this.$router.push('/')
|
||||
},
|
||||
(token) => {
|
||||
this.$router.push('/signup-reason?token=' + token)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
loginWithGithub() {
|
||||
githubAuthorize()
|
||||
},
|
||||
@@ -117,7 +111,7 @@ export default {
|
||||
},
|
||||
loginWithTwitter() {
|
||||
twitterAuthorize()
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
</div>
|
||||
|
||||
<div class="other-signup-page-content">
|
||||
<div class="signup-page-button" @click="signupWithGoogle">
|
||||
<div class="signup-page-button" @click="loginWithGoogle">
|
||||
<img class="signup-page-button-icon" src="../assets/icons/google.svg" alt="Google Logo" />
|
||||
<div class="signup-page-button-text">Google 注册</div>
|
||||
</div>
|
||||
@@ -89,7 +89,7 @@
|
||||
|
||||
<script>
|
||||
import { API_BASE_URL, toast } from '../main'
|
||||
import { googleSignIn } from '../utils/google'
|
||||
import { loginWithGoogle } from '../utils/google'
|
||||
import { githubAuthorize } from '../utils/github'
|
||||
import { discordAuthorize } from '../utils/discord'
|
||||
import { twitterAuthorize } from '../utils/twitter'
|
||||
@@ -97,7 +97,9 @@ import BaseInput from '../components/BaseInput.vue'
|
||||
export default {
|
||||
name: 'SignupPageView',
|
||||
components: { BaseInput },
|
||||
|
||||
setup() {
|
||||
return { loginWithGoogle }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
emailStep: 0,
|
||||
@@ -201,13 +203,6 @@ export default {
|
||||
toast.error('注册失败')
|
||||
}
|
||||
},
|
||||
signupWithGoogle() {
|
||||
googleSignIn(() => {
|
||||
this.$router.push('/')
|
||||
}, (token) => {
|
||||
this.$router.push('/signup-reason?token=' + token)
|
||||
})
|
||||
},
|
||||
signupWithGithub() {
|
||||
githubAuthorize()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user