itube-specs 0.0.222 → 0.0.224

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.
@@ -27,24 +27,15 @@
27
27
  </template>
28
28
 
29
29
  <div class="s-filter-popup__filters">
30
- <template
30
+ <SSelect
31
31
  v-for="(item, index) in scheme"
32
+ :name="item.title"
32
33
  :key="`scheme-${index}`"
33
- >
34
- <SInput
35
- v-if="item.type === 'input'"
36
- v-model="filterValue[item.name.toLowerCase()]"
37
- :label="item?.label"
38
- />
39
- <SSelect
40
- v-if="item.type === 'select'"
41
- :name="item.title"
42
- v-model="filterValue[item.name.toLowerCase()]"
43
- :items="item.items"
44
- :label="item?.label"
45
- :placeholder="item.placeholder"
46
- />
47
- </template>
34
+ v-model="filterValue[item.title.toLowerCase()]"
35
+ :items="item.items"
36
+ :label="item?.label"
37
+ :placeholder="item.placeholder"
38
+ />
48
39
  </div>
49
40
 
50
41
  <template #footer>
@@ -67,7 +58,7 @@
67
58
  </template>
68
59
 
69
60
  <script setup lang="ts">
70
- import type { FilterSchemeType, ISelectItem } from '../../types';
61
+ import type { IFilterScheme, ISelectItem } from '../../types';
71
62
 
72
63
  const { t } = useI18n()
73
64
 
@@ -75,7 +66,7 @@ const props = defineProps<{
75
66
  addedItems: ISelectItem[]
76
67
  durationItems: ISelectItem[]
77
68
  modelValue: boolean
78
- scheme: FilterSchemeType
69
+ scheme: IFilterScheme[]
79
70
  count: number
80
71
  }>()
81
72
 
@@ -86,20 +77,20 @@ const filterValue = ref({} as Record<string, string>);
86
77
  const route = useRoute();
87
78
 
88
79
  const categoriesFromQuery = route.query.categories
89
- ? (typeof route.query.categories === 'string'
90
- ? route.query.categories.split(',')
91
- : route.query.categories.flatMap(cat => cat.split(',')))
92
- : [];
80
+ ? (typeof route.query.categories === 'string'
81
+ ? route.query.categories.split(',')
82
+ : route.query.categories.flatMap(cat => cat.split(',')))
83
+ : [];
93
84
 
94
85
  categoriesFromQuery.forEach(str => {
95
86
  const [key, ...rest] = str.split('_');
96
87
  if (key && rest.length > 0) {
97
- filterValue.value[key] = rest.join('_');
88
+ filterValue.value[ key ] = rest.join('_');
98
89
  }
99
90
  });
100
91
 
101
- durationValue.value = route.query['duration'] as string || '';
102
- addedValue.value = route.query['added'] as string || '';
92
+ durationValue.value = route.query[ 'duration' ] as string || '';
93
+ addedValue.value = route.query[ 'added' ] as string || '';
103
94
 
104
95
  const emit = defineEmits<{
105
96
  (eventName: 'update:modelValue', value: boolean): void
@@ -116,7 +107,7 @@ const router = useRouter();
116
107
 
117
108
  function saveResult() {
118
109
  const oldQuery = { ...route.query };
119
- delete oldQuery['page'];
110
+ delete oldQuery[ 'page' ];
120
111
 
121
112
  const mainFiltersValue = {
122
113
  ...(durationValue.value ? { duration: durationValue.value } : {}),
@@ -130,8 +121,8 @@ function saveResult() {
130
121
  };
131
122
 
132
123
  const categories = Object.entries(filterValue.value)
133
- .filter(([, value]) => typeof value === 'string' && value.length > 0)
134
- .map(([key, value]) => `${key}_${value}`);
124
+ .filter(([, value]) => typeof value === 'string' && value.length > 0)
125
+ .map(([key, value]) => `${key}_${value}`);
135
126
 
136
127
  const categoriesString = categories.join(',');
137
128
 
@@ -162,5 +153,5 @@ const filterTitle = computed(() => {
162
153
  return count > 0 ? `${filterText}: ${count}` : t('filter')
163
154
  })
164
155
 
165
- const isFiltered = computed(() => !!route.query['categories']);
156
+ const isFiltered = computed(() => !!route.query[ 'categories' ]);
166
157
  </script>
@@ -21,7 +21,7 @@
21
21
  </template>
22
22
 
23
23
  <script setup lang="ts">
24
- import type { ButtonSizes, ButtonThemes, FilterSchemeType } from '../../types';
24
+ import type { ButtonSizes, ButtonThemes, IFilterScheme } from '../../types';
25
25
  import type { LocationQuery } from '#vue-router';
26
26
  import type { ISelectItem } from '../../types';
27
27
 
@@ -29,7 +29,7 @@ const route = useRoute();
29
29
  const filterOpen = ref(false);
30
30
 
31
31
  defineProps<{
32
- scheme: FilterSchemeType
32
+ scheme: IFilterScheme[]
33
33
  addedItems: ISelectItem[]
34
34
  durationItems: ISelectItem[]
35
35
  buttonSize?: ButtonSizes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.222",
4
+ "version": "0.0.224",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {
@@ -1,37 +1,11 @@
1
- import type { ISelectItem, ITabItem } from '../types';
1
+ import type { ISelectItem } from '../types';
2
2
 
3
- export type FilterSchemeItemType =
4
- | 'select'
5
- | 'input'
6
- | 'tabs'
7
-
8
- interface IFilterSchemeItemBase {
9
- type: FilterSchemeItemType
3
+ export interface IFilterScheme {
10
4
  title: string
11
5
  className?: string
12
6
  label?: string
13
7
  wide?: boolean
14
8
  fixed?: boolean
15
- }
16
-
17
- interface IFilterSchemeItemSelect extends IFilterSchemeItemBase {
18
- type: 'select'
19
9
  items: ISelectItem[]
20
10
  placeholder: string
21
11
  }
22
-
23
- interface IFilterSchemeItemTabs extends IFilterSchemeItemBase {
24
- type: 'tabs'
25
- items: ITabItem[]
26
- }
27
-
28
- interface IFilterSchemeItemInput extends IFilterSchemeItemBase {
29
- type: 'input'
30
- }
31
-
32
- export type FilterSchemeItem =
33
- | IFilterSchemeItemSelect
34
- | IFilterSchemeItemInput
35
- | IFilterSchemeItemTabs
36
-
37
- export type FilterSchemeType = FilterSchemeItem[]
@@ -1,77 +0,0 @@
1
- import { selectDurationItems, sortItemsDefault, selectAddedItems } from '../lib/';
2
- import { EAsyncData, ELanguage, getSelectedQuery, ApiHelper } from '../runtime';
3
- import { useRoute } from 'vue-router';
4
- import type { IVideoCard, PaginatedResponse, RequestPagination, IRequestVideoFilter } from '../types';
5
-
6
- async function getListByNiche(
7
- pagination: RequestPagination,
8
- videosFilter: IRequestVideoFilter,
9
- lang: ELanguage,
10
- order: string,
11
- niche = 'gay',
12
- ): Promise<PaginatedResponse<IVideoCard>> {
13
- return await ApiHelper.fetch(
14
- '/videos/list-by-niche',
15
- {
16
- method: 'POST',
17
- headers: {
18
- 'X-Niche': niche,
19
- 'X-Language': lang,
20
- 'X-Cache-Time': '259200',
21
- 'Content-Type': 'application/json',
22
- },
23
- params: {
24
- ...pagination,
25
- order,
26
- },
27
- body: {
28
- filter_request: videosFilter,
29
- max_limit: 0,
30
- }
31
- },
32
- );
33
- }
34
-
35
- export const useFetchVideos = async () => {
36
- const route = useRoute();
37
- const { locale } = useI18n();
38
- const lang = locale.value as ELanguage;
39
- const perPage = 48;
40
-
41
- const { data, status, error } = await useAsyncData<PaginatedResponse<IVideoCard>>(
42
- EAsyncData.Videos,
43
- fetchData,
44
- {
45
- watch: [
46
- () => {
47
- if (route.query) {
48
- const currentQuery = route.query;
49
- return JSON.stringify(currentQuery);
50
- }
51
- },
52
- ],
53
- }
54
- );
55
-
56
- async function fetchData() {
57
- try {
58
- return await getListByNiche(
59
- {
60
- page: Number(route.query[ 'page' ]) || 1,
61
- [ 'per-page' ]: perPage,
62
- },
63
- useGetVideosFilterRequest(route, selectDurationItems, selectAddedItems),
64
- lang,
65
- getSelectedQuery(route, sortItemsDefault) || '-popularity,-primary_thumb_rank'
66
- );
67
- } catch (err) {
68
- throw createError({
69
- statusCode: 500,
70
- statusMessage: 'Error fetching videos',
71
- message: err instanceof Error ? err.message : 'An unknown error occurred',
72
- });
73
- }
74
- }
75
-
76
- return { data, status, error };
77
- };