itube-specs 0.0.322 → 0.0.324
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composables/use-fetch-channels-by-model.ts +36 -0
- package/composables/use-fetch-popular-tags-by-model-name.ts +23 -0
- package/composables/use-fetch-videos-by-model-and-channel.ts +48 -0
- package/composables/use-fetch-videos-by-model-and-tag.ts +48 -0
- package/package.json +1 -1
- package/types/chips-item.d.ts +1 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useRoute } from 'vue-router';
|
|
2
|
+
import { EAsyncData, ELanguage } from '../runtime';
|
|
3
|
+
import type { IChannelCard, PaginatedResponse } from '../types';
|
|
4
|
+
|
|
5
|
+
export const useFetchChannelsByModel = (
|
|
6
|
+
apiMethod: (...args: any[]) => Promise<PaginatedResponse<IChannelCard>>
|
|
7
|
+
) => {
|
|
8
|
+
const lang = useI18n().locale.value as ELanguage;
|
|
9
|
+
const route = useRoute();
|
|
10
|
+
const slug = useSlug();
|
|
11
|
+
const key = EAsyncData.ChannelsByModel;
|
|
12
|
+
const stateKey = computed(() => `data-${key}-${slug.value}-${lang}`);
|
|
13
|
+
|
|
14
|
+
const { data, status, error } = useAsyncData<PaginatedResponse<IChannelCard>>(
|
|
15
|
+
key,
|
|
16
|
+
() => useApiFetcher<PaginatedResponse<IChannelCard>>(
|
|
17
|
+
stateKey.value,
|
|
18
|
+
apiMethod,
|
|
19
|
+
lang,
|
|
20
|
+
{
|
|
21
|
+
page: 1,
|
|
22
|
+
},
|
|
23
|
+
slug.value,
|
|
24
|
+
)(),
|
|
25
|
+
{
|
|
26
|
+
watch: [
|
|
27
|
+
() => {
|
|
28
|
+
const currentQuery = route.query;
|
|
29
|
+
return JSON.stringify(currentQuery);
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return { data, status, error };
|
|
36
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EAsyncData, ELanguage } from '../runtime';
|
|
2
|
+
import type { IPopularTagsModel } from '../types';
|
|
3
|
+
|
|
4
|
+
export const useFetchPopularTagsByModelName = (
|
|
5
|
+
apiMethod: (...args: any[]) => Promise<IPopularTagsModel[]>
|
|
6
|
+
) => {
|
|
7
|
+
const lang = useI18n().locale.value as ELanguage;
|
|
8
|
+
const slug = useSlug();
|
|
9
|
+
const key = EAsyncData.PopularTagsByModel;
|
|
10
|
+
const stateKey = computed(() => `data-${key}-${slug.value}-${lang}`);
|
|
11
|
+
|
|
12
|
+
const { data, status, error } = useAsyncData<IPopularTagsModel[]>(
|
|
13
|
+
key,
|
|
14
|
+
() => useApiFetcher<IPopularTagsModel[]>(
|
|
15
|
+
stateKey.value,
|
|
16
|
+
apiMethod,
|
|
17
|
+
lang,
|
|
18
|
+
slug.value,
|
|
19
|
+
)()
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return { data, status, error };
|
|
23
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { convertString, EAsyncData, ELanguage, getSelectedQuery } from '../runtime';
|
|
2
|
+
import type { IVideoCard, PaginatedResponse } from '../types';
|
|
3
|
+
import { selectAddedItems, selectDurationItems, sortItemsDefault } from '../lib';
|
|
4
|
+
import { useRoute } from 'vue-router';
|
|
5
|
+
|
|
6
|
+
export const useFetchVideosByModelAndChannel = async (apiMethod: (...args: any[]) => Promise<PaginatedResponse<IVideoCard>>) => {
|
|
7
|
+
const route = useRoute();
|
|
8
|
+
const { locale } = useI18n();
|
|
9
|
+
const lang = locale.value as ELanguage;
|
|
10
|
+
const slug = useSlug();
|
|
11
|
+
const channel = computed(() => {
|
|
12
|
+
const tagRaw = route.params['channel'];
|
|
13
|
+
const slug = convertString().fromSlug(String(tagRaw));
|
|
14
|
+
return Array.isArray(slug) ? slug[ 0 ] : slug;
|
|
15
|
+
});
|
|
16
|
+
const filters = computed(() => useGetVideosFilterRequest(route, selectDurationItems, selectAddedItems));
|
|
17
|
+
const key = EAsyncData.VideosByModelAndChannel;
|
|
18
|
+
const stateKey = computed(() => `data-${key}-${slug.value}-${channel.value}-${JSON.stringify(route.query)}-${lang}`);
|
|
19
|
+
|
|
20
|
+
const { data, status, error } = await useAsyncData<PaginatedResponse<IVideoCard>>(
|
|
21
|
+
key,
|
|
22
|
+
() => useApiFetcher<PaginatedResponse<IVideoCard>>(
|
|
23
|
+
stateKey.value,
|
|
24
|
+
apiMethod,
|
|
25
|
+
{
|
|
26
|
+
page: Number(route.query[ 'page' ]) || 1,
|
|
27
|
+
'per-page': 48,
|
|
28
|
+
},
|
|
29
|
+
filters.value,
|
|
30
|
+
slug.value,
|
|
31
|
+
channel.value,
|
|
32
|
+
lang,
|
|
33
|
+
getSelectedQuery(route, sortItemsDefault) || '-popularity'
|
|
34
|
+
)(),
|
|
35
|
+
{
|
|
36
|
+
watch: [
|
|
37
|
+
() => {
|
|
38
|
+
if (route.query) {
|
|
39
|
+
const currentQuery = route.query;
|
|
40
|
+
return JSON.stringify(currentQuery);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return { data, status, error };
|
|
48
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { convertString, EAsyncData, ELanguage, getSelectedQuery } from '../runtime';
|
|
2
|
+
import type { IVideoCard, PaginatedResponse } from '../types';
|
|
3
|
+
import { selectAddedItems, selectDurationItems, sortItemsDefault } from '../lib';
|
|
4
|
+
import { useRoute } from 'vue-router';
|
|
5
|
+
|
|
6
|
+
export const useFetchVideosByModelAndTag = async (apiMethod: (...args: any[]) => Promise<PaginatedResponse<IVideoCard>>) => {
|
|
7
|
+
const route = useRoute();
|
|
8
|
+
const { locale } = useI18n();
|
|
9
|
+
const lang = locale.value as ELanguage;
|
|
10
|
+
const slug = useSlug();
|
|
11
|
+
const tag = computed(() => {
|
|
12
|
+
const tagRaw = route.params['tag'];
|
|
13
|
+
const slug = convertString().fromSlug(String(tagRaw));
|
|
14
|
+
return Array.isArray(slug) ? slug[ 0 ] : slug;
|
|
15
|
+
});
|
|
16
|
+
const filters = computed(() => useGetVideosFilterRequest(route, selectDurationItems, selectAddedItems));
|
|
17
|
+
const key = EAsyncData.VideosByModelAndTag;
|
|
18
|
+
const stateKey = computed(() => `data-${key}-${slug.value}-${tag.value}-${JSON.stringify(route.query)}-${lang}`);
|
|
19
|
+
|
|
20
|
+
const { data, status, error } = await useAsyncData<PaginatedResponse<IVideoCard>>(
|
|
21
|
+
key,
|
|
22
|
+
() => useApiFetcher<PaginatedResponse<IVideoCard>>(
|
|
23
|
+
stateKey.value,
|
|
24
|
+
apiMethod,
|
|
25
|
+
{
|
|
26
|
+
page: Number(route.query[ 'page' ]) || 1,
|
|
27
|
+
'per-page': 48,
|
|
28
|
+
},
|
|
29
|
+
filters.value,
|
|
30
|
+
slug.value,
|
|
31
|
+
tag.value,
|
|
32
|
+
lang,
|
|
33
|
+
getSelectedQuery(route, sortItemsDefault) || '-popularity'
|
|
34
|
+
)(),
|
|
35
|
+
{
|
|
36
|
+
watch: [
|
|
37
|
+
() => {
|
|
38
|
+
if (route.query) {
|
|
39
|
+
const currentQuery = route.query;
|
|
40
|
+
return JSON.stringify(currentQuery);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return { data, status, error };
|
|
48
|
+
};
|
package/package.json
CHANGED