This repository has been archived by the owner on Mar 26, 2023. It is now read-only.
generated from cawa-93/vite-electron-builder
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Отображение срока подписки на anime365
- Loading branch information
Showing
6 changed files
with
146 additions
and
69 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
packages/renderer/src/pages/Options/OptionsAnime365/Anime365SubscribeStatus.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script lang="ts" setup> | ||
import {asyncComputed} from '@vueuse/core'; | ||
import {getSubscribeStatus} from '/@/utils/videoProvider/providers/anime365/getSubscribeStatus'; | ||
import {formatDate} from '/@/utils/formatDate'; | ||
import {computed, ref} from 'vue'; | ||
import ButtonSpinner from '/@/components/ButtonSpinner.vue'; | ||
const props = defineProps({ | ||
accessToken: { | ||
type: String, | ||
required: false, | ||
default: undefined, | ||
}, | ||
}); | ||
const isLoading = ref(true); | ||
const subscribe = asyncComputed(() => getSubscribeStatus(props.accessToken), null, isLoading); | ||
const premiumUntilFormatted = computed(() => formatDate( | ||
subscribe.value?.premiumUntil | ||
? Date.parse(subscribe.value?.premiumUntil) | ||
: 0), | ||
); | ||
</script> | ||
|
||
<template> | ||
<template v-if="isLoading"> | ||
<p style="height: 56px"> | ||
<button-spinner /> | ||
Загрузка ... | ||
</p> | ||
</template> | ||
<ul v-else-if="subscribe"> | ||
<li v-if="subscribe.isLogined"> | ||
<span class="win-icon"></span>Аккаунт подключён | ||
</li> | ||
<li v-else> | ||
<span class="win-icon text-red"></span>Нет ключа доступа | ||
</li> | ||
|
||
<li v-if="subscribe.isPremium"> | ||
<span class="win-icon"></span>Подписка оформлена до {{ premiumUntilFormatted }} | ||
</li> | ||
<li v-else> | ||
<span class="win-icon text-red"></span>Подписка не оформлена | ||
</li> | ||
</ul> | ||
</template> | ||
|
||
<style scoped> | ||
li { | ||
@apply flex gap-2; | ||
display: flex; | ||
} | ||
.win-icon { | ||
@apply text-lg; | ||
color: #268926; | ||
} | ||
.win-icon.text-red { | ||
color: #c94d3e; | ||
} | ||
</style> |
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
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
19 changes: 19 additions & 0 deletions
19
packages/renderer/src/utils/videoProvider/providers/anime365/getSubscribeStatus.ts
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 @@ | ||
import {API_BASE, isFailureResponse, request} from '/@/utils/videoProvider/providers/anime365/utils'; | ||
|
||
interface SubscribeStatus { | ||
isLogined: boolean, | ||
name: string, | ||
isPremium: boolean | ||
premiumUntil: string | ||
} | ||
|
||
export async function getSubscribeStatus(access_token?: string, options?: RequestInit) { | ||
const requestURL = new URL('me', API_BASE); | ||
const apiResponse = await request<SubscribeStatus>(requestURL, access_token, options); | ||
|
||
if (isFailureResponse(apiResponse)) { | ||
throw apiResponse; | ||
} | ||
|
||
return apiResponse.data; | ||
} |