-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
138 additions
and
17 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,15 @@ | ||
<template> | ||
<div class="sm:mx-auto sm:w-full sm:max-w-md"> | ||
<div class="u-bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10"> | ||
<div> | ||
<div class="relative"> | ||
<div class="absolute inset-0 flex items-center"> | ||
<div class="w-full border-t border-gray-300" /> | ||
</div> | ||
<el-divider>登录账户</el-divider> | ||
</div> | ||
<slot /> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
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,42 @@ | ||
<!-- | ||
* @Author: 白雾茫茫丶<baiwumm.com> | ||
* @Date: 2024-06-06 18:00:33 | ||
* @LastEditors: 白雾茫茫丶<baiwumm.com> | ||
* @LastEditTime: 2024-06-07 08:59:59 | ||
* @Description: 注销用户 | ||
--> | ||
<template> | ||
<client-only> | ||
<el-tooltip content="注销用户"> | ||
<el-button v-if="user" circle text @click="logout"> | ||
<Icon name="ri:logout-box-r-line" class="h-5 w-5" /> | ||
</el-button> | ||
</el-tooltip> | ||
</client-only> | ||
</template> | ||
<script setup lang="ts"> | ||
import { ElMessageBox } from 'element-plus' | ||
const client = useSupabaseClient() | ||
const user = useSupabaseUser() | ||
// 注销用户 | ||
const logout = async () => { | ||
ElMessageBox.alert('确认注销当前用户吗?', '温馨提示', { | ||
confirmButtonText: '确定', | ||
beforeClose: async (action, instance, done) => { | ||
if (action === 'confirm') { | ||
instance.confirmButtonLoading = true | ||
await client.auth.signOut().then(() => { | ||
done() | ||
instance.confirmButtonLoading = false | ||
navigateTo('/') | ||
}) | ||
} | ||
if (action === 'cancel') { | ||
done() | ||
} | ||
} | ||
}) | ||
} | ||
</script> |
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,17 @@ | ||
<!-- | ||
* @Author: 白雾茫茫丶<baiwumm.com> | ||
* @Date: 2024-06-06 17:53:32 | ||
* @LastEditors: 白雾茫茫丶<baiwumm.com> | ||
* @LastEditTime: 2024-06-07 09:10:05 | ||
* @Description: 当前登录用户头像 | ||
--> | ||
<template> | ||
<client-only> | ||
<el-button v-if="user" circle text> | ||
<el-avatar :src="user.user_metadata.avatar_url" :size="20" /> | ||
</el-button> | ||
</client-only> | ||
</template> | ||
<script setup lang="ts"> | ||
const user = useSupabaseUser() | ||
</script> |
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,19 @@ | ||
<script setup lang="ts"> | ||
const user = useSupabaseUser() | ||
watch( | ||
user, | ||
() => { | ||
if (user.value) { | ||
return navigateTo('/') | ||
} | ||
}, | ||
{ immediate: true } | ||
) | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<p class="u-text-black">Redirecting...</p> | ||
</div> | ||
</template> |
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,32 @@ | ||
<script setup lang="ts"> | ||
const colorMode = useColorMode() | ||
const user = useSupabaseUser() | ||
const { auth } = useSupabaseClient() | ||
const redirectTo = `${useRuntimeConfig().public.baseUrl}/confirm` | ||
watchEffect(() => { | ||
if (user.value) { | ||
navigateTo('/') | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="min-h-full flex flex-col justify-center py-12 sm:px-6 lg:px-8"> | ||
<h2 class="my-6 text-center text-3xl font-extrabold u-text-white">登录您的账户</h2> | ||
<el-card class="sm:mx-auto sm:w-full sm:max-w-md"> | ||
<el-divider>请选择</el-divider> | ||
<el-button | ||
type="primary" | ||
size="large" | ||
:dark="colorMode.value === 'dark'" | ||
class="w-full" | ||
@click="auth.signInWithOAuth({ provider: 'github', options: { redirectTo } })" | ||
> | ||
<Icon name="i-simple-icons-github" class="h-5 w-5 mr-2" /> | ||
Github | ||
</el-button> | ||
</el-card> | ||
</div> | ||
</template> |