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