File tree Expand file tree Collapse file tree 12 files changed +181
-3
lines changed
components/editor/aside/project Expand file tree Collapse file tree 12 files changed +181
-3
lines changed Original file line number Diff line number Diff line change 1
- VITE_PROJECT_EMPTY = __NOT_CREATED__
1
+ VITE_PROJECT_EMPTY = __NOT_CREATED__
2
+ VITE_LOCAL_STORAGE = __BETTER_WRITE__
Original file line number Diff line number Diff line change 4
4
</template >
5
5
6
6
<script setup lang="ts">
7
+ import { onMounted } from ' vue'
7
8
import { useI18n } from ' vue-i18n'
8
9
import { useStart } from ' @/use/start'
10
+ import { useIndexedDB } from ' @/use/storage/indexed'
9
11
10
12
const { t } = useI18n ()
11
13
12
14
useStart ().init ()
15
+
16
+ onMounted (() => {})
13
17
</script >
Original file line number Diff line number Diff line change 18
18
<AsideProjectNew />
19
19
<AsidePageNew v-if =" store.state.project.name !== useEnv().projectEmpty()" />
20
20
<AsideLine v-if =" store.state.project.name !== useEnv().projectEmpty()" />
21
+ <AsideLoadProject />
22
+ <AsideSaveProject
23
+ v-if =" store.state.project.name !== useEnv().projectEmpty()"
24
+ />
25
+ <AsideLine v-if =" store.state.project.name !== useEnv().projectEmpty()" />
21
26
<AsideGeneratePDF
22
27
v-if =" store.state.project.name !== useEnv().projectEmpty()"
23
28
/>
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <InjectButtonInstance class =" wb-aside-button" @click.prevent =" onSaveProject" >
3
+ {{ t('editor.aside.project.load.title') }}
4
+ </InjectButtonInstance >
5
+ </template >
6
+
7
+ <script setup lang="ts">
8
+ import { useI18n } from ' vue-i18n'
9
+ import { useLocalStorage } from ' @/use/storage/local'
10
+ import { useStore } from ' vuex'
11
+ import { nextTick } from ' vue'
12
+
13
+ const store = useStore ()
14
+
15
+ const onSaveProject = async () => {
16
+ const context = useLocalStorage ().getProject ()
17
+
18
+ store .commit (' project/load' , context .project )
19
+ await nextTick
20
+
21
+ store .commit (' context/load' , store .state .project .pages [0 ])
22
+ }
23
+
24
+ const { t } = useI18n ()
25
+ </script >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <InjectButtonInstance class =" wb-aside-button" @click.prevent =" onSaveProject" >
3
+ {{ t('editor.aside.project.save.title') }}
4
+ </InjectButtonInstance >
5
+ </template >
6
+
7
+ <script setup lang="ts">
8
+ import { useI18n } from ' vue-i18n'
9
+ import { useLocalStorage } from ' @/use/storage/local'
10
+ import { useStore } from ' vuex'
11
+
12
+ const store = useStore ()
13
+
14
+ const onSaveProject = () => {
15
+ useLocalStorage ().setProject ({
16
+ project: store .state .project ,
17
+ editor: store .state .editor ,
18
+ })
19
+ }
20
+
21
+ const { t } = useI18n ()
22
+ </script >
Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ export default {
22
22
} ,
23
23
project : {
24
24
title : 'Projeto' ,
25
+ save : {
26
+ title : 'Salvar Projeto' ,
27
+ } ,
28
+ load : {
29
+ title : 'Carregar Projeto' ,
30
+ } ,
25
31
blocked : 'Crie ou carregue um projeto!!!' ,
26
32
page : {
27
33
new : {
Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ export default {
22
22
} ,
23
23
project : {
24
24
title : 'Project' ,
25
+ save : {
26
+ title : 'Save Project' ,
27
+ } ,
28
+ load : {
29
+ title : 'Load Project' ,
30
+ } ,
25
31
blocked : 'Create or load a project!!!' ,
26
32
page : {
27
33
new : {
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import { ProjectState } from '@/types/project'
2
2
import { useText } from '@/use/text'
3
3
import { useFormat } from '@/use/format'
4
4
import { ContextState , ContextStatePageContent } from '@/types/context'
5
- import { useI18n } from 'vue-i18n'
6
5
7
6
export default {
8
7
namespaced : true ,
@@ -18,6 +17,16 @@ export default {
18
17
pageLoaded : 0 ,
19
18
} as ProjectState ) ,
20
19
mutations : {
20
+ load ( state : any , payload : ProjectState ) {
21
+ state . name = payload . name
22
+ state . nameRaw = payload . nameRaw
23
+ state . version = payload . version
24
+ state . totalPagesCreated = payload . totalPagesCreated
25
+ state . main = payload . main
26
+ state . summary = payload . summary
27
+ state . pages = payload . pages
28
+ state . pageLoaded = payload . pageLoaded
29
+ } ,
21
30
create ( state : any , payload : Record < any , any > ) {
22
31
state . name = useText ( ) . kebab ( payload . name )
23
32
state . nameRaw = payload . name
Original file line number Diff line number Diff line change 1
1
import { ContextState } from '@/types/context'
2
+ import { EditorState } from './editor'
2
3
3
4
export interface ProjectState {
4
5
name : string
@@ -10,3 +11,8 @@ export interface ProjectState {
10
11
pages : Array < ContextState >
11
12
pageLoaded : number
12
13
}
14
+
15
+ export interface ProjectObject {
16
+ project : ProjectState
17
+ editor : EditorState
18
+ }
Original file line number Diff line number Diff line change @@ -5,5 +5,9 @@ export const useEnv: Callback<any> = () => {
5
5
return import . meta. env . VITE_PROJECT_EMPTY as string
6
6
}
7
7
8
- return { projectEmpty }
8
+ const projectLocalStorage = ( ) => {
9
+ return import . meta. env . VITE_LOCAL_STORAGE as string
10
+ }
11
+
12
+ return { projectEmpty, projectLocalStorage }
9
13
}
You can’t perform that action at this time.
0 commit comments