-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
6109dfb
commit 8d22780
Showing
31 changed files
with
403 additions
and
401 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
!*.vue | ||
!*.ts | ||
!*.js | ||
!tsconfig.json |
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 was deleted.
Oops, something went wrong.
84 changes: 0 additions & 84 deletions
84
src/resources/js/Components/DataTable/EasyTableWrapper.vue
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
src/resources/js/Components/Telegram/TelegramLoginWidget.vue
This file was deleted.
Oops, something went wrong.
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,72 @@ | ||
<script setup lang="ts"> | ||
import { onMounted, onUnmounted, ref } from 'vue'; | ||
import { RequestAccess, WidgetSize } from '@/types/telegram/enums'; | ||
import { TelegramUser } from '@/types/telegram/types'; | ||
type Props = { | ||
bot: string; | ||
size: WidgetSize; | ||
radius: number; | ||
showUserPicture: boolean; | ||
accessType: RequestAccess; | ||
}; | ||
type WithRedirect = Props & { | ||
type: 'redirect'; | ||
redirectUrl: string; | ||
}; | ||
type WithCallback = Props & { | ||
type: 'callback'; | ||
callback: (user: TelegramUser) => void; | ||
}; | ||
const widgetUrl = 'https://telegram.org/js/telegram-widget.js?22'; | ||
const telegramWidget = ref<HTMLElement | null>(null); | ||
const props = withDefaults(defineProps<Partial<WithRedirect | WithCallback>>(), { | ||
bot: 'anilibrary_bot', | ||
size: WidgetSize.Medium, | ||
radius: 14, | ||
showUserPicture: false, | ||
accessType: RequestAccess.Write, | ||
}); | ||
const createLoginWidget = (): HTMLElement => { | ||
const script = document.createElement('script'); | ||
script.async = true; | ||
script.src = widgetUrl; | ||
script.setAttribute('data-telegram-login', props.bot); | ||
script.setAttribute('data-size', props.size.toString()); | ||
script.setAttribute('data-radius', props.radius.toString()); | ||
script.setAttribute('data-userpic', props.showUserPicture.toString()); | ||
script.setAttribute('data-request-access', props.accessType); | ||
if (props.type === 'redirect') { | ||
script.setAttribute('data-auth-url', route((props as WithRedirect).redirectUrl)); | ||
return script; | ||
} | ||
window.onTelegramAuth = (props as WithCallback).callback; | ||
script.setAttribute('data-onauth', 'onTelegramAuth(user)'); | ||
return script; | ||
}; | ||
onMounted(() => { | ||
(telegramWidget.value as HTMLElement)!.appendChild(createLoginWidget()); | ||
}); | ||
onUnmounted(() => { | ||
if (window.onTelegramAuth) { | ||
delete window.onTelegramAuth; | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div ref="telegramWidget"></div> | ||
</template> | ||
|
||
<style scoped></style> |
5 changes: 3 additions & 2 deletions
5
...esources/js/Components/Theme/Switcher.vue → ...resources/js/Components/ThemeSwitcher.vue
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
Oops, something went wrong.