1
1
<template >
2
- <b-container
3
- v-if =" indexationId && hasData"
4
- fluid
5
- style =" max-height : calc (100% - 35px ); flex-grow : 1 "
6
- class =" d-flex flex-column"
7
- >
8
- <template v-if =" tabNames [activeTab ] === ' Page gallery' "
9
- ><Gallery :images =" images" />
10
- <upload-widget
11
- v-if =" showUploadWidget"
12
- :folder-name =" indexationId"
13
- @done ="
14
- showUploadWidget = !showUploadWidget;
15
- loadIndexation(indexationId);
16
- "
17
- @abort =" showUploadWidget = !showUploadWidget"
18
- />
19
- <b-button
20
- v-show =" !showUploadWidget"
21
- @click =" showUploadWidget = !showUploadWidget"
22
- >
23
- {{ $t("Upload page files") }}
24
- </b-button >
25
- </template >
26
- <Book v-else-if =" tabNames[activeTab] === 'Book'" />
27
- <TextEditor v-else-if =" tabNames[activeTab] === 'Text editor'"
28
- /></b-container >
29
- <b-container >
30
- <b-container
31
- v-if =" activeTab !== undefined"
32
- class =" start-0 bottom-0 mw-100 pt-2 h-5"
33
- style =" height : 35px "
34
- ><b-tabs v-model:model-value =" activeTab" align =" center"
35
- ><b-tab
36
- v-for =" tabName of tabNames"
37
- :key =" tabName"
38
- :title =" $t(tabName)" /></b-tabs ></b-container
39
- ></b-container >
2
+ <b-row v-if =" indexationId && hasData" class =" d-flex h-100" >
3
+ <b-col :cols =" 6" >
4
+ <template v-if =" tabNames [activeTab ] === ' Page gallery' "
5
+ ><Gallery :images =" images" />
6
+ <upload-widget
7
+ v-if =" showUploadWidget"
8
+ :folder-name =" indexationId"
9
+ @done ="
10
+ showUploadWidget = !showUploadWidget;
11
+ loadIndexation(indexationId);
12
+ "
13
+ @abort =" showUploadWidget = !showUploadWidget"
14
+ />
15
+ <b-button
16
+ v-show =" !showUploadWidget"
17
+ @click =" showUploadWidget = !showUploadWidget"
18
+ >
19
+ {{ $t("Upload page files") }}
20
+ </b-button >
21
+ </template >
22
+ <Book
23
+ v-else-if =" tabNames[activeTab] === 'Book' && coverRatio"
24
+ ref =" bookComponent"
25
+ v-model:book =" book"
26
+ v-model:current-page =" bookCurrentPage"
27
+ :cover-height =" coverHeight"
28
+ :cover-ratio =" coverRatio"
29
+ :urls =" indexation!.pages.map(({ url }) => url)"
30
+ :with-table-of-contents =" false" />
31
+ <TextEditor v-else-if =" tabNames[activeTab] === 'Text editor'" />
32
+ <b-container
33
+ v-if =" activeTab !== undefined"
34
+ class =" start-0 bottom-0 mw-100 pt-2 h-5"
35
+ style =" height : 35px "
36
+ ><b-tabs v-model:model-value =" activeTab" align =" center"
37
+ ><b-tab
38
+ v-for =" tabName of tabNames"
39
+ :key =" tabName"
40
+ :title =" $t(tabName)" /></b-tabs ></b-container
41
+ ></b-col >
42
+
43
+ <b-col :cols =" 6" >
44
+ <table-of-contents
45
+ v-model =" bookCurrentPage"
46
+ :indexation =" indexation"
47
+ :shown-pages =" shownPages"
48
+ /></b-col >
49
+ </b-row >
40
50
</template >
41
51
42
52
<script setup lang="ts">
53
+ import { components as webComponents , type PageFlip } from " ~web" ;
43
54
import { suggestions } from " ~/stores/suggestions" ;
44
55
import { tabs } from " ~/stores/tabs" ;
45
56
57
+ const { Book } = webComponents ;
58
+
59
+ const book = ref <PageFlip | undefined >(undefined );
60
+ const bookCurrentPage = ref (0 );
61
+ const coverWidth = ref (1000 );
62
+ const coverRatio = ref <number | undefined >(undefined );
63
+ const coverHeight = computed (
64
+ () => coverRatio .value && coverWidth .value * coverRatio .value ,
65
+ );
66
+
46
67
const showUploadWidget = ref (false );
47
68
const route = useRoute ();
48
69
@@ -62,6 +83,18 @@ const { indexation } = storeToRefs(suggestions());
62
83
63
84
const hasData = ref (false );
64
85
86
+ const shownPages = computed (() =>
87
+ book .value
88
+ ? [
89
+ ... new Set ([
90
+ book .value .getCurrentPageIndex (),
91
+ (book .value as unknown as { pages: { currentSpreadIndex: number } })!
92
+ .pages .currentSpreadIndex * 2 ,
93
+ ]),
94
+ ]
95
+ : [],
96
+ );
97
+
65
98
const images = computed (() =>
66
99
indexation .value ?.pages .map (({ url }) => ({
67
100
url ,
@@ -96,6 +129,15 @@ watch(
96
129
)
97
130
.flat (),
98
131
);
132
+ const firstPageDimensions: { output: { height: number ; width: number } } =
133
+ await (
134
+ await fetch (
135
+ " https://res.cloudinary.com/dl7hskxab/image/upload/pg_1/fl_getinfo/v1729876637/dumili/brunoperel/20241025T171702824/Picsou_magazine_529_11zon_krzady.png" ,
136
+ )
137
+ ).json ();
138
+ debugger ;
139
+ coverRatio .value =
140
+ firstPageDimensions .output .height / firstPageDimensions .output .width ;
99
141
hasData .value = true ;
100
142
},
101
143
{ immediate: true },
0 commit comments